-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SNOW-952817: Reflect doesn't work with mixed case schema #458
Comments
hi and thank you for submitting this issue and especially for sharing the patch ! i believe it could be caused by the same underlying cause which causes #388 can this be a possible duplicate ? |
This is a duplicate of both #388 and #276. We have been using the patch and it is working for us, with the same change applied to
|
thank you for confirming it @fordhoka (and also happy to hear you have a working workaround) |
Thanks @sfc-gh-dszmolka. When can we expect this patch to be included in a release? |
At this moment, I don't have any estimated timeline attached to this one unfortunately; but will keep the relevant open issues updated |
I think the approach of closing issues without a patch is strange. It is much easier to track progress if issues are open until they are fixed. What is the holdback in fixing this issue, I've already submitted a patch? |
only reason for closing this is because this is a duplicate but happy to reopen it. is there a PR perhaps? if so, that would be more than appreciated and helpful - I can try to get the connector team to review it. if not, that's also not a problem and we'll get there. there's quite a backlog for us to work through as you probably noticed, but we're now trying to dedicate more resources and love to this repo as well. so hoping that things will get better over time and thank you for bearing with us. |
Well, while we are waiting for this to be fixed I'm monkey patching my code. Perhaps it can be useful for others. import snowflake.sqlalchemy.snowdialect as sd
from sqlalchemy import exc as sa_exc
from sqlalchemy.sql import text
# Patching get_sequence_names method
@sd.reflection.cache
def get_sequence_names_patched(self, connection, schema=None, **kw):
sql_command = "SHOW SEQUENCES {}".format(
f"IN SCHEMA \"{self.denormalize_name(schema)}\"" if schema else ""
)
try:
cursor = connection.execute(text(sql_command))
return [self.normalize_name(row[0]) for row in cursor]
except sa_exc.ProgrammingError as pe:
if pe.orig.errno == 2003:
# Schema does not exist
return []
# Patching _get_table_comment method
def _get_table_comment_patched(self, connection, table_name, schema=None, **kw):
"""
Returns comment of table in a dictionary as described by SQLAlchemy spec.
"""
sql_command = (
"SHOW /* sqlalchemy:_get_table_comment */ "
"TABLES LIKE '{}'{}".format(
table_name,
f" IN SCHEMA \"{self.denormalize_name(schema)}\"" if schema else "",
)
)
cursor = connection.execute(text(sql_command))
return cursor.fetchone()
# Patching _get_view_comment method
def _get_view_comment_patched(self, connection, table_name, schema=None, **kw):
"""
Returns comment of view in a dictionary as described by SQLAlchemy spec.
"""
sql_command = (
"SHOW /* sqlalchemy:_get_view_comment */ "
"VIEWS LIKE '{}'{}".format(
table_name,
f" IN SCHEMA \"{self.denormalize_name(schema)}\"" if schema else "",
)
)
cursor = connection.execute(text(sql_command))
return cursor.fetchone()
# Apply patches by replacing the original methods
sd.SnowflakeDialect.get_sequence_names = get_sequence_names_patched
sd.SnowflakeDialect._get_table_comment = _get_table_comment_patched
sd.SnowflakeDialect._get_view_comment = _get_view_comment_patched |
Please answer these questions before submitting your issue. Thanks!
What operating system and processor architecture are you using?
Linux-5.4.0-1074-azure-x86_64-with-glibc2.17
What are the component versions in the environment (
pip freeze
)?What did you do?
What did you expect to see?
The tables containing
control
should be listed. Instead i get this error:Can you set logging to DEBUG and collect the logs?
Better, I have a suggested patch:
So, qoute the schema name seems to do the trick.
The text was updated successfully, but these errors were encountered: