fakesnow 0.9.9__py3-none-any.whl → 0.9.11__py3-none-any.whl

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/fakes.py CHANGED
@@ -193,6 +193,7 @@ class FakeSnowflakeCursor:
193
193
  .transform(transforms.show_users)
194
194
  .transform(transforms.create_user)
195
195
  .transform(transforms.sha256)
196
+ .transform(transforms.create_clone)
196
197
  )
197
198
 
198
199
  def _execute(
@@ -629,7 +630,12 @@ class FakeSnowflakeConnection:
629
630
  df[col] = df[col].apply(lambda x: json.dumps(x) if isinstance(x, (dict, list)) else x)
630
631
 
631
632
  escaped_cols = ",".join(f'"{col}"' for col in df.columns.to_list())
632
- self._duck_conn.execute(f"INSERT INTO {table_name}({escaped_cols}) SELECT * FROM df")
633
+ name = table_name
634
+ if schema:
635
+ table_name = f"{schema}.{table_name}"
636
+ if database:
637
+ name = f"{database}.{table_name}"
638
+ self._duck_conn.execute(f"INSERT INTO {name}({escaped_cols}) SELECT * FROM df")
633
639
 
634
640
  return self._duck_conn.fetchall()[0][0]
635
641
 
fakesnow/transforms.py CHANGED
@@ -55,6 +55,27 @@ def array_agg_within_group(expression: exp.Expression) -> exp.Expression:
55
55
  return expression
56
56
 
57
57
 
58
+ def create_clone(expression: exp.Expression) -> exp.Expression:
59
+ """Transform create table clone to create table as select."""
60
+
61
+ if (
62
+ isinstance(expression, exp.Create)
63
+ and str(expression.args.get("kind")).upper() == "TABLE"
64
+ and (clone := expression.find(exp.Clone))
65
+ ):
66
+ return exp.Create(
67
+ this=expression.this,
68
+ kind="TABLE",
69
+ expression=exp.Select(
70
+ expressions=[
71
+ exp.Star(),
72
+ ],
73
+ **{"from": exp.From(this=clone.this)},
74
+ ),
75
+ )
76
+ return expression
77
+
78
+
58
79
  # TODO: move this into a Dialect as a transpilation
59
80
  def create_database(expression: exp.Expression, db_path: Path | None = None) -> exp.Expression:
60
81
  """Transform create database to attach database.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fakesnow
3
- Version: 0.9.9
3
+ Version: 0.9.11
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
@@ -220,7 +220,7 @@ Requires-Dist: pandas-stubs ; extra == 'dev'
220
220
  Requires-Dist: snowflake-connector-python[pandas,secure-local-storage] ; extra == 'dev'
221
221
  Requires-Dist: pre-commit ~=3.4 ; extra == 'dev'
222
222
  Requires-Dist: pytest ~=8.0 ; extra == 'dev'
223
- Requires-Dist: ruff ~=0.3.2 ; extra == 'dev'
223
+ Requires-Dist: ruff ~=0.4.2 ; extra == 'dev'
224
224
  Requires-Dist: twine ~=5.0 ; extra == 'dev'
225
225
  Requires-Dist: snowflake-sqlalchemy ~=1.5.0 ; extra == 'dev'
226
226
  Provides-Extra: notebook
@@ -357,7 +357,7 @@ For more detail see [tests/test_fakes.py](tests/test_fakes.py)
357
357
  ## Caveats
358
358
 
359
359
  - The order of rows is non deterministic and may not match Snowflake unless ORDER BY is fully specified.
360
- - A more liberal Snowflake SQL dialect than a real Snowflake instance is supported, ie: some queries might pass using fakesnow that a real Snowflake instance would reject.
360
+ - A more liberal Snowflake SQL dialect than used by a real Snowflake instance is supported, ie: some queries might pass using fakesnow that a real Snowflake instance would reject.
361
361
 
362
362
  ## Contributing
363
363
 
@@ -3,16 +3,16 @@ fakesnow/__main__.py,sha256=GDrGyNTvBFuqn_UfDjKs7b3LPtU6gDv1KwosVDrukIM,76
3
3
  fakesnow/checks.py,sha256=-QMvdcrRbhN60rnzxLBJ0IkUBWyLR8gGGKKmCS0w9mA,2383
4
4
  fakesnow/cli.py,sha256=9qfI-Ssr6mo8UmIlXkUAOz2z2YPBgDsrEVaZv9FjGFs,2201
5
5
  fakesnow/expr.py,sha256=CAxuYIUkwI339DQIBzvFF0F-m1tcVGKEPA5rDTzmH9A,892
6
- fakesnow/fakes.py,sha256=k9i3xohKfgS55ABexd06ubqtTDsc36asoSGv_kzzdxg,29442
6
+ fakesnow/fakes.py,sha256=OBoFJ7lSwB3hkcqcd7UZIcWO5Kaxg41JAt_eYRDahE0,29646
7
7
  fakesnow/fixtures.py,sha256=G-NkVeruSQAJ7fvSS2fR2oysUn0Yra1pohHlOvacKEk,455
8
8
  fakesnow/global_database.py,sha256=WTVIP1VhNvdCeX7TQncX1TRpGQU5rBf5Pbxim40zeSU,1399
9
9
  fakesnow/info_schema.py,sha256=CdIcGXHEQ_kmEAzdQKvA-PX41LA6wlK-4p1J45qgKYA,6266
10
10
  fakesnow/macros.py,sha256=pX1YJDnQOkFJSHYUjQ6ErEkYIKvFI6Ncz_au0vv1csA,265
11
11
  fakesnow/py.typed,sha256=B-DLSjYBi7pkKjwxCSdpVj2J02wgfJr-E7B1wOUyxYU,80
12
- fakesnow/transforms.py,sha256=5-JWBE4d6NDTqDSXDZjZXk1gSeK0sjHOZVy5RJPiPQA,50059
13
- fakesnow-0.9.9.dist-info/LICENSE,sha256=kW-7NWIyaRMQiDpryfSmF2DObDZHGR1cJZ39s6B1Svg,11344
14
- fakesnow-0.9.9.dist-info/METADATA,sha256=08vNDl-q6ssZOlj4X3w8R559uXZtDlN09d6XvgVS4mQ,17832
15
- fakesnow-0.9.9.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
16
- fakesnow-0.9.9.dist-info/entry_points.txt,sha256=2riAUgu928ZIHawtO8EsfrMEJhi-EH-z_Vq7Q44xKPM,47
17
- fakesnow-0.9.9.dist-info/top_level.txt,sha256=500evXI1IFX9so82cizGIEMHAb_dJNPaZvd2H9dcKTA,24
18
- fakesnow-0.9.9.dist-info/RECORD,,
12
+ fakesnow/transforms.py,sha256=oFNMsWygVz5-B98HMnrWznlxJoxl-DwoVCTdwHSdK_0,50670
13
+ fakesnow-0.9.11.dist-info/LICENSE,sha256=kW-7NWIyaRMQiDpryfSmF2DObDZHGR1cJZ39s6B1Svg,11344
14
+ fakesnow-0.9.11.dist-info/METADATA,sha256=Q7KmvgTl7DtgDOBevWk9TISq3RAR4eueYO4d_toNtb8,17841
15
+ fakesnow-0.9.11.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
16
+ fakesnow-0.9.11.dist-info/entry_points.txt,sha256=2riAUgu928ZIHawtO8EsfrMEJhi-EH-z_Vq7Q44xKPM,47
17
+ fakesnow-0.9.11.dist-info/top_level.txt,sha256=500evXI1IFX9so82cizGIEMHAb_dJNPaZvd2H9dcKTA,24
18
+ fakesnow-0.9.11.dist-info/RECORD,,