tekumara / fakesnow

Fake Snowflake Connector for Python. Run, mock and test Snowflake DB locally.
Apache License 2.0
108 stars 10 forks source link

fix: Allow connection with schema=information_schema #122

Closed DanCardin closed 3 months ago

DanCardin commented 3 months ago

With snowflake, it's sometimes (particularly with alembic) convenient to connect with schema='information_schema', so that all other schemas are required explicitly (since there's no public schema, and the weird way snowflake scoping works).

As-is without this PR, the duckdb information_schema is lowercased, and the auto-use-schema code in fakesnow would unconditionally .upper() the given schema, search for INFORMATION_SCHEMA, not find it, and then you'd get This session does not have a current schema. Call 'USE SCHEMA' when you wouldn't in real life.

It might perhaps be more ideal to somehow fully recreate the snowflake information_schema and replace it, because there are some differences with the duckdb version that i suspect will end up being irreconcilable, but it's not obvious to me how to do this, nor how much additional work it'd be so...just a thought.

tekumara commented 3 months ago

PS: yes having a fully recreated snowflake info schema makes sense to improve fidelity.