diff --git a/fakesnow/transforms.py b/fakesnow/transforms.py index 8496470..9e64382 100644 --- a/fakesnow/transforms.py +++ b/fakesnow/transforms.py @@ -309,7 +309,7 @@ def extract_comment_on_table(expression: exp.Expression) -> exp.Expression: if props := cast(exp.Properties, expression.args.get("properties")): other_props = [] for p in props.expressions: - if isinstance(p, exp.SchemaCommentProperty) and (isinstance(p.this, (exp.Literal, exp.Identifier))): + if isinstance(p, exp.SchemaCommentProperty) and (isinstance(p.this, (exp.Literal, exp.Var))): comment = p.this.this else: other_props.append(p) diff --git a/pyproject.toml b/pyproject.toml index f17070a..7e79242 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ dependencies = [ "duckdb~=0.10.0", "pyarrow", "snowflake-connector-python", - "sqlglot~=23.3.0", + "sqlglot~=23.12.2", ] [project.urls] diff --git a/tests/test_fakes.py b/tests/test_fakes.py index 8ebc7bd..c379e2f 100644 --- a/tests/test_fakes.py +++ b/tests/test_fakes.py @@ -1284,6 +1284,13 @@ def test_show_primary_keys(dcur: snowflake.connector.cursor.SnowflakeCursor): assert result3 == [] +def test_sqlglot_regression(cur: snowflake.connector.cursor.SnowflakeCursor): + assert cur.execute( + """with SOURCE_TABLE AS (SELECT '2024-01-01' AS start_date) + SELECT date(a.start_date) from SOURCE_TABLE AS a""" + ).fetchone() == (datetime.date(2024, 1, 1),) + + def test_sqlstate(cur: snowflake.connector.cursor.SnowflakeCursor): cur.execute("select 'hello world'") # sqlstate is None on success