langchain-ai / langchain

šŸ¦œšŸ”— Build context-aware reasoning applications
https://python.langchain.com
MIT License
95.18k stars 15.43k forks source link

community: failing unit test with sqlalchemy 2.0.36 #27627

Open baskaryan opened 4 weeks ago

baskaryan commented 4 weeks ago

Privileged issue

Issue Content

If you poetry lock langchain-community so that the current latest sqlalchemy version is installed you get failing unit tests: https://github.com/langchain-ai/langchain/actions/runs/11508741758/job/32037584608

=========================== short test summary info ============================
FAILED tests/unit_tests/test_sql_database_schema.py::test_table_info - sqlalchemy.exc.ProgrammingError: (duckdb.duckdb.CatalogException) Catalog Error: Type with name REGCLASS does not exist!
[SQL: SELECT pg_catalog.pg_class.relname, pg_catalog.pg_description.description 
FROM pg_catalog.pg_class LEFT OUTER JOIN pg_catalog.pg_description ON pg_catalog.pg_class.oid = pg_catalog.pg_description.objoid AND pg_catalog.pg_description.objsubid = $1 AND pg_catalog.pg_description.classoid = CAST($2 AS REGCLASS) JOIN pg_catalog.pg_namespace ON pg_catalog.pg_namespace.oid = pg_catalog.pg_class.relnamespace 
WHERE pg_catalog.pg_class.relkind = ANY (ARRAY[$3, $4, $5]) AND pg_catalog.pg_table_is_visible(pg_catalog.pg_class.oid) AND pg_catalog.pg_namespace.nspname != $6 AND pg_namespace.nspname = $7 AND pg_catalog.pg_class.relname IN ($8)]
[parameters: (0, 'pg_catalog.pg_class', 'r', 'p', 'f', 'pg_catalog', 'schema_a', 'user')]
(Background on this error at: https://sqlalche.me/e/20/f405)
FAILED tests/unit_tests/test_sql_database_schema.py::test_sql_database_run - sqlalchemy.exc.ProgrammingError: (duckdb.duckdb.CatalogException) Catalog Error: Type with name REGCLASS does not exist!
[SQL: SELECT pg_catalog.pg_class.relname, pg_catalog.pg_description.description 
FROM pg_catalog.pg_class LEFT OUTER JOIN pg_catalog.pg_description ON pg_catalog.pg_class.oid = pg_catalog.pg_description.objoid AND pg_catalog.pg_description.objsubid = $1 AND pg_catalog.pg_description.classoid = CAST($2 AS REGCLASS) JOIN pg_catalog.pg_namespace ON pg_catalog.pg_namespace.oid = pg_catalog.pg_class.relnamespace 
WHERE pg_catalog.pg_class.relkind = ANY (ARRAY[$3, $4, $5]) AND pg_catalog.pg_table_is_visible(pg_catalog.pg_class.oid) AND pg_catalog.pg_namespace.nspname != $6 AND pg_namespace.nspname = $7 AND pg_catalog.pg_class.relname IN ($8)]
[parameters: (0, 'pg_catalog.pg_class', 'r', 'p', 'f', 'pg_catalog', 'schema_a', 'user')]
(Background on this error at: https://sqlalche.me/e/20/f405)
========== 2 failed, 994 passed, 538 skipped, 704 warnings in 18.18s ===========
Aarya2004 commented 4 weeks ago

Hello @baskaryan! I'm investigating this error now. I'll add a comment when I have some clarity on some possible causes. Do you have any idea why this error may be thrown? (Just to know if you have an idea how to approach the fix)

Aarya2004 commented 4 weeks ago

It appears that this bug and the commit to fix it caused this code to error out (since it seems to be working fine with sqlalchemy v2.0.35). It seems that the REGCLASS typecasting done is not a type supported by duckdb and causes this error. I will be looking for workaround for this but if you have any suggestions on how to fix the issue, do let me know!

Edit: There was an issue brought up in the sqlalchemy repo: https://github.com/sqlalchemy/sqlalchemy/discussions/12011

Aarya2004 commented 2 weeks ago

Update: Got a PR going with the fixes to this issue. Once it's been approved and merged, this issue should be resolved. The PR - Mause/duckdb_engine#1147

Aarya2004 commented 2 weeks ago

Hello! We were able to merge our PR in the duckdb_engine repo (https://github.com/Mause/duckdb_engine/pull/1147). Once our updates are released, this issue should be fixed!