-
Notifications
You must be signed in to change notification settings - Fork 166
Open
Labels
bugSomething isn't workingSomething isn't workingduplicateThis issue or pull request already existsThis issue or pull request already existsstatus-triage_doneInitial triage done, will be further handled by the driver teamInitial triage done, will be further handled by the driver team
Description
Please answer these questions before submitting your issue. Thanks!
- What version of Python are you using?
Python 3.8.16 (default, Jan 17 2023, 23:13:24)
[GCC 11.2.0]
-
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)?
snowflake-connector-python==2.7.9
snowflake-sqlalchemy==1.4.6
SQLAlchemy==1.4.35
-
What did you do?
from snowflake.sqlalchemy import URL from sqlalchemy import create_engine from sqlalchemy import MetaData engine = create_engine( URL( account=ACCOUNT, user=secrets[USR_KEY], password=secrets[PASS_KEY], database=DATABASE_NAME, schema=SCHEMA_NAME, warehouse=warehouse, role=ROLE, ) ) meta_data = MetaData(engine) meta_data.reflect(only=lambda l, _: 'control' in l, views=True, schema="EPS_CO_Technical") print(meta_data.tables.keys()) -
What did you expect to see?
The tables containing
controlshould be listed. Instead i get this error:ProgrammingError: (snowflake.connector.errors.ProgrammingError) 002043 (02000): SQL compilation error: Object does not exist, or operation cannot be performed. [SQL: SHOW /* sqlalchemy:_get_table_comment */ TABLES LIKE '_controlTable_MapPocPrice' IN SCHEMA EPS_CO_Technical] (Background on this error at: https://sqlalche.me/e/14/f405) -
Can you set logging to DEBUG and collect the logs?
Better, I have a suggested patch:
diff --git a/snowdialect.py b/anaconda/envs/azureml_py38/lib/python3.8/site-packages/snowflake/sqlalchemy/snowdialect.py --- a/snowdialect.py +++ b/anaconda/envs/azureml_py38/lib/python3.8/site-packages/snowflake/sqlalchemy/snowdialect.py @@ -813,7 +813,7 @@ class SnowflakeDialect(default.DefaultDialect): "SHOW /* sqlalchemy:_get_table_comment */ " "TABLES LIKE '{}'{}".format( table_name, - f" IN SCHEMA {self.normalize_name(schema)}" if schema else "", + f" IN SCHEMA \"{self.denormalize_name(schema)}\"" if schema else "", ) ) cursor = connection.execute(text(sql_command)) @@ -827,7 +827,7 @@ class SnowflakeDialect(default.DefaultDialect): "SHOW /* sqlalchemy:_get_view_comment */ " "VIEWS LIKE '{}'{}".format( table_name, - f" IN SCHEMA {self.normalize_name(schema)}" if schema else "", + f" IN SCHEMA \"{self.denormalize_name(schema)}\"" if schema else "", ) ) cursor = connection.execute(text(sql_command))
So, qoute the schema name seems to do the trick.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingduplicateThis issue or pull request already existsThis issue or pull request already existsstatus-triage_doneInitial triage done, will be further handled by the driver teamInitial triage done, will be further handled by the driver team