fakesnow 0.9.8__tar.gz → 0.9.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fakesnow-0.9.8 → fakesnow-0.9.9}/PKG-INFO +2 -2
- {fakesnow-0.9.8 → fakesnow-0.9.9}/fakesnow/transforms.py +14 -5
- {fakesnow-0.9.8 → fakesnow-0.9.9}/fakesnow.egg-info/PKG-INFO +2 -2
- {fakesnow-0.9.8 → fakesnow-0.9.9}/fakesnow.egg-info/requires.txt +1 -1
- {fakesnow-0.9.8 → fakesnow-0.9.9}/pyproject.toml +2 -2
- {fakesnow-0.9.8 → fakesnow-0.9.9}/tests/test_fakes.py +7 -0
- {fakesnow-0.9.8 → fakesnow-0.9.9}/tests/test_transforms.py +19 -0
- {fakesnow-0.9.8 → fakesnow-0.9.9}/LICENSE +0 -0
- {fakesnow-0.9.8 → fakesnow-0.9.9}/README.md +0 -0
- {fakesnow-0.9.8 → fakesnow-0.9.9}/fakesnow/__init__.py +0 -0
- {fakesnow-0.9.8 → fakesnow-0.9.9}/fakesnow/__main__.py +0 -0
- {fakesnow-0.9.8 → fakesnow-0.9.9}/fakesnow/checks.py +0 -0
- {fakesnow-0.9.8 → fakesnow-0.9.9}/fakesnow/cli.py +0 -0
- {fakesnow-0.9.8 → fakesnow-0.9.9}/fakesnow/expr.py +0 -0
- {fakesnow-0.9.8 → fakesnow-0.9.9}/fakesnow/fakes.py +0 -0
- {fakesnow-0.9.8 → fakesnow-0.9.9}/fakesnow/fixtures.py +0 -0
- {fakesnow-0.9.8 → fakesnow-0.9.9}/fakesnow/global_database.py +0 -0
- {fakesnow-0.9.8 → fakesnow-0.9.9}/fakesnow/info_schema.py +0 -0
- {fakesnow-0.9.8 → fakesnow-0.9.9}/fakesnow/macros.py +0 -0
- {fakesnow-0.9.8 → fakesnow-0.9.9}/fakesnow/py.typed +0 -0
- {fakesnow-0.9.8 → fakesnow-0.9.9}/fakesnow.egg-info/SOURCES.txt +0 -0
- {fakesnow-0.9.8 → fakesnow-0.9.9}/fakesnow.egg-info/dependency_links.txt +0 -0
- {fakesnow-0.9.8 → fakesnow-0.9.9}/fakesnow.egg-info/entry_points.txt +0 -0
- {fakesnow-0.9.8 → fakesnow-0.9.9}/fakesnow.egg-info/top_level.txt +0 -0
- {fakesnow-0.9.8 → fakesnow-0.9.9}/setup.cfg +0 -0
- {fakesnow-0.9.8 → fakesnow-0.9.9}/tests/test_checks.py +0 -0
- {fakesnow-0.9.8 → fakesnow-0.9.9}/tests/test_cli.py +0 -0
- {fakesnow-0.9.8 → fakesnow-0.9.9}/tests/test_expr.py +0 -0
- {fakesnow-0.9.8 → fakesnow-0.9.9}/tests/test_info_schema.py +0 -0
- {fakesnow-0.9.8 → fakesnow-0.9.9}/tests/test_patch.py +0 -0
- {fakesnow-0.9.8 → fakesnow-0.9.9}/tests/test_sqlalchemy.py +0 -0
- {fakesnow-0.9.8 → fakesnow-0.9.9}/tests/test_users.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: fakesnow
|
3
|
-
Version: 0.9.
|
3
|
+
Version: 0.9.9
|
4
4
|
Summary: Fake Snowflake Connector for Python. Run, mock and test Snowflake DB locally.
|
5
5
|
License: Apache License
|
6
6
|
Version 2.0, January 2004
|
@@ -213,7 +213,7 @@ License-File: LICENSE
|
|
213
213
|
Requires-Dist: duckdb~=0.10.0
|
214
214
|
Requires-Dist: pyarrow
|
215
215
|
Requires-Dist: snowflake-connector-python
|
216
|
-
Requires-Dist: sqlglot~=23.
|
216
|
+
Requires-Dist: sqlglot~=23.12.2
|
217
217
|
Provides-Extra: dev
|
218
218
|
Requires-Dist: build~=1.0; extra == "dev"
|
219
219
|
Requires-Dist: pandas-stubs; extra == "dev"
|
@@ -309,7 +309,7 @@ def extract_comment_on_table(expression: exp.Expression) -> exp.Expression:
|
|
309
309
|
if props := cast(exp.Properties, expression.args.get("properties")):
|
310
310
|
other_props = []
|
311
311
|
for p in props.expressions:
|
312
|
-
if isinstance(p, exp.SchemaCommentProperty) and (isinstance(p.this, (exp.Literal, exp.
|
312
|
+
if isinstance(p, exp.SchemaCommentProperty) and (isinstance(p.this, (exp.Literal, exp.Var))):
|
313
313
|
comment = p.this.this
|
314
314
|
else:
|
315
315
|
other_props.append(p)
|
@@ -360,10 +360,19 @@ def extract_text_length(expression: exp.Expression) -> exp.Expression:
|
|
360
360
|
|
361
361
|
if isinstance(expression, (exp.Create, exp.AlterTable)):
|
362
362
|
text_lengths = []
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
363
|
+
|
364
|
+
# exp.Select is for a ctas, exp.Schema is a plain definition
|
365
|
+
if cols := expression.find(exp.Select, exp.Schema):
|
366
|
+
expressions = cols.expressions
|
367
|
+
else:
|
368
|
+
# alter table
|
369
|
+
expressions = expression.args.get("actions") or []
|
370
|
+
for e in expressions:
|
371
|
+
if dts := [
|
372
|
+
dt for dt in e.find_all(exp.DataType) if dt.this in (exp.DataType.Type.VARCHAR, exp.DataType.Type.TEXT)
|
373
|
+
]:
|
374
|
+
col_name = e.alias if isinstance(e, exp.Alias) else e.name
|
375
|
+
if len(dts) == 1 and (dt_size := dts[0].find(exp.DataTypeParam)):
|
367
376
|
size = (
|
368
377
|
isinstance(dt_size.this, exp.Literal)
|
369
378
|
and isinstance(dt_size.this.this, str)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: fakesnow
|
3
|
-
Version: 0.9.
|
3
|
+
Version: 0.9.9
|
4
4
|
Summary: Fake Snowflake Connector for Python. Run, mock and test Snowflake DB locally.
|
5
5
|
License: Apache License
|
6
6
|
Version 2.0, January 2004
|
@@ -213,7 +213,7 @@ License-File: LICENSE
|
|
213
213
|
Requires-Dist: duckdb~=0.10.0
|
214
214
|
Requires-Dist: pyarrow
|
215
215
|
Requires-Dist: snowflake-connector-python
|
216
|
-
Requires-Dist: sqlglot~=23.
|
216
|
+
Requires-Dist: sqlglot~=23.12.2
|
217
217
|
Provides-Extra: dev
|
218
218
|
Requires-Dist: build~=1.0; extra == "dev"
|
219
219
|
Requires-Dist: pandas-stubs; extra == "dev"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
[project]
|
2
2
|
name = "fakesnow"
|
3
3
|
description = "Fake Snowflake Connector for Python. Run, mock and test Snowflake DB locally."
|
4
|
-
version = "0.9.
|
4
|
+
version = "0.9.9"
|
5
5
|
readme = "README.md"
|
6
6
|
license = { file = "LICENSE" }
|
7
7
|
classifiers = ["License :: OSI Approved :: MIT License"]
|
@@ -11,7 +11,7 @@ dependencies = [
|
|
11
11
|
"duckdb~=0.10.0",
|
12
12
|
"pyarrow",
|
13
13
|
"snowflake-connector-python",
|
14
|
-
"sqlglot~=23.
|
14
|
+
"sqlglot~=23.12.2",
|
15
15
|
]
|
16
16
|
|
17
17
|
[project.urls]
|
@@ -1284,6 +1284,13 @@ def test_show_primary_keys(dcur: snowflake.connector.cursor.SnowflakeCursor):
|
|
1284
1284
|
assert result3 == []
|
1285
1285
|
|
1286
1286
|
|
1287
|
+
def test_sqlglot_regression(cur: snowflake.connector.cursor.SnowflakeCursor):
|
1288
|
+
assert cur.execute(
|
1289
|
+
"""with SOURCE_TABLE AS (SELECT '2024-01-01' AS start_date)
|
1290
|
+
SELECT date(a.start_date) from SOURCE_TABLE AS a"""
|
1291
|
+
).fetchone() == (datetime.date(2024, 1, 1),)
|
1292
|
+
|
1293
|
+
|
1287
1294
|
def test_sqlstate(cur: snowflake.connector.cursor.SnowflakeCursor):
|
1288
1295
|
cur.execute("select 'hello world'")
|
1289
1296
|
# sqlstate is None on success
|
@@ -335,6 +335,25 @@ def test_extract_text_length() -> None:
|
|
335
335
|
assert e.sql() == sql
|
336
336
|
assert e.args["text_lengths"] == [("t1", 16777216), ("t2", 10), ("t3", 20)]
|
337
337
|
|
338
|
+
sql = "ALTER TABLE t1 ALTER COLUMN c4 SET DATA TYPE VARCHAR(50)"
|
339
|
+
e = sqlglot.parse_one(sql).transform(extract_text_length)
|
340
|
+
assert e.sql() == sql
|
341
|
+
assert e.args["text_lengths"] == [("c4", 50)]
|
342
|
+
|
343
|
+
# test column name is correct with alias
|
344
|
+
sql = """CREATE TABLE table1 AS (
|
345
|
+
SELECT CAST(C1 AS TEXT) AS K, CAST(C2 AS TEXT(10)) AS V
|
346
|
+
FROM (VALUES (1, 2)) AS T(C1, C2))"""
|
347
|
+
e = sqlglot.parse_one(sql).transform(extract_text_length)
|
348
|
+
assert e.args["text_lengths"] == [("K", 16777216), ("V", 10)]
|
349
|
+
|
350
|
+
# test ctas column name is correct for combined field
|
351
|
+
sql = """CREATE TABLE SOME_TABLE AS (
|
352
|
+
SELECT CAST(C1 AS TEXT) || '-' || CAST(C1 AS TEXT) AS K
|
353
|
+
FROM VALUES (1), (2) AS T (C1))"""
|
354
|
+
e = sqlglot.parse_one(sql).transform(extract_text_length)
|
355
|
+
assert e.args["text_lengths"] == [("K", 16777216)]
|
356
|
+
|
338
357
|
|
339
358
|
def test_flatten() -> None:
|
340
359
|
assert (
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|