Skip to content
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-1871391: SnowflakeDialect get_table_names is now returning dict_keys breaks compatibility #566

Open
salivian opened this issue Jan 2, 2025 · 1 comment
Labels
bug Something isn't working status-triage_done Initial triage done, will be further handled by the driver team

Comments

@salivian
Copy link

salivian commented Jan 2, 2025

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

@salivian salivian added bug Something isn't working needs triage labels Jan 2, 2025
@sfc-gh-dszmolka sfc-gh-dszmolka added status-triage_done Initial triage done, will be further handled by the driver team and removed needs triage labels Jan 3, 2025
@sfc-gh-dszmolka
Copy link
Contributor

hi - thanks for raising this. We'll take a look.

@sfc-gh-dszmolka sfc-gh-dszmolka changed the title SnowflakeDialect get_table_names is now returning dict_keys breaks compatibility SNOW-1871391: SnowflakeDialect get_table_names is now returning dict_keys breaks compatibility Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working status-triage_done Initial triage done, will be further handled by the driver team
Projects
None yet
Development

No branches or pull requests

2 participants