Skip to content

Commit

Permalink
chore(deps): update duckdb requirement from ~=1.0.0 to ~=1.1.3 (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] authored Nov 6, 2024
1 parent 88a0e05 commit ecd4d46
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
1 change: 1 addition & 0 deletions fakesnow/cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def _transform(self, expression: exp.Expression) -> exp.Expression:
.transform(transforms.extract_comment_on_columns)
.transform(transforms.information_schema_fs_columns_snowflake)
.transform(transforms.information_schema_fs_tables_ext)
.transform(transforms.information_schema_fs_views)
.transform(transforms.drop_schema_cascade)
.transform(transforms.tag)
.transform(transforms.semi_structured_types)
Expand Down
2 changes: 1 addition & 1 deletion fakesnow/info_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
# replicates https://docs.snowflake.com/sql-reference/info-schema/views
SQL_CREATE_INFORMATION_SCHEMA_VIEWS_VIEW = Template(
"""
create view if not exists ${catalog}.information_schema.views AS
create view if not exists ${catalog}.information_schema._fs_views AS
select
database_name as table_catalog,
schema_name as table_schema,
Expand Down
14 changes: 14 additions & 0 deletions fakesnow/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,20 @@ def information_schema_fs_tables_ext(expression: exp.Expression) -> exp.Expressi
return expression


def information_schema_fs_views(expression: exp.Expression) -> exp.Expression:
"""Use information_schema._fs_views to return Snowflake's version instead of duckdb's."""

if (
isinstance(expression, exp.Select)
and (tbl_exp := expression.find(exp.Table))
and tbl_exp.name.upper() == "VIEWS"
and tbl_exp.db.upper() == "INFORMATION_SCHEMA"
):
tbl_exp.set("this", exp.Identifier(this="_FS_VIEWS", quoted=False))

return expression


def integer_precision(expression: exp.Expression) -> exp.Expression:
"""Convert integers to bigint.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ classifiers = ["License :: OSI Approved :: MIT License"]
keywords = ["snowflake", "snowflakedb", "fake", "local", "mock", "testing"]
requires-python = ">=3.9"
dependencies = [
"duckdb~=1.0.0",
"duckdb~=1.1.3",
"pyarrow",
"snowflake-connector-python",
"sqlglot~=25.24.1",
Expand Down
7 changes: 0 additions & 7 deletions tests/test_fakes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1125,13 +1125,6 @@ def test_show_objects(dcur: snowflake.connector.cursor.SnowflakeCursor):
"name": "databases",
"schema_name": "information_schema",
},
{
"created_on": datetime.datetime(1970, 1, 1, 0, 0, tzinfo=pytz.utc),
"database_name": "DB1",
"kind": "VIEW",
"name": "views",
"schema_name": "information_schema",
},
]
assert [r.name for r in dcur.description] == ["created_on", "name", "kind", "database_name", "schema_name"]

Expand Down

0 comments on commit ecd4d46

Please sign in to comment.