Skip to content

SNOW-1871391: SnowflakeDialect get_table_names is now returning dict_keys breaks compatibilityΒ #566

@salivian

Description

@salivian

Please answer these questions before submitting your issue. Thanks!

  1. What version of Python are you using?
    Python 3.12.3

  2. What operating system and processor architecture are you using?
    Linux-6.8.0-35-generic-x86_64-with-glibc2.39

  3. What are the component versions in the environment (pip freeze)?
    langchain-community==0.3.13
    snowflake-sqlalchemy==1.7.2
    SQLAlchemy==2.0.31

  4. What did you do?

When creating a db connection in langchain, it calls snowflake-sqlalchemy and sqlalchemy inspector, it fails due to a recent change in get_table_names

File "....../py/lib/python3.12/site-packages/langchain_community/utilities/sql_database.py", line 139, in from_uri
return cls(create_engine(database_uri, **_engine_args), **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "....../py/lib/python3.12/site-packages/langchain_community/utilities/sql_database.py", line 75, in init
self._inspector.get_table_names(schema=schema)
TypeError: unsupported operand type(s) for +: 'dict_keys' and 'list'

The get_table_names in SnowflakeDialect has recently changed to return keys of a dictionary -> dict_keys
https://github.com/snowflakedb/snowflake-sqlalchemy/blob/main/src/snowflake/sqlalchemy/snowdialect.py#L758

However, sqlalchemy get_table_names returns a List[str]
https://docs.sqlalchemy.org/en/20/core/reflection.html#sqlalchemy.engine.reflection.Inspector.get_table_names

return list(ret) in L759 should fix the problem

Metadata

Metadata

Labels

bugSomething isn't workingstatus-fixed_awaiting_releaseThe issue has been fixed, its PR merged, and now awaiting the next release cycle of the connector.status-triage_doneInitial triage done, will be further handled by the driver team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions