sqlmesh 0.181.2.dev13__py3-none-any.whl → 0.181.2.dev15__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.
sqlmesh/_version.py CHANGED
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '0.181.2.dev13'
21
- __version_tuple__ = version_tuple = (0, 181, 2, 'dev13')
20
+ __version__ = version = '0.181.2.dev15'
21
+ __version_tuple__ = version_tuple = (0, 181, 2, 'dev15')
@@ -246,7 +246,12 @@ class EngineAdapter:
246
246
  assert isinstance(df, pd.DataFrame)
247
247
  num_rows = len(df.index)
248
248
  batch_size = sys.maxsize if batch_size == 0 else batch_size
249
+
250
+ # we need to ensure that the order of the columns in columns_to_types columns matches the order of the values
251
+ # they can differ if a user specifies columns() on a python model in a different order than what's in the DataFrame's emitted by that model
252
+ df = df[list(columns_to_types)]
249
253
  values = list(df.itertuples(index=False, name=None))
254
+
250
255
  return [
251
256
  SourceQuery(
252
257
  query_factory=partial(
@@ -218,10 +218,13 @@ class MSSQLEngineAdapter(
218
218
  # as later calls.
219
219
  if not self.table_exists(temp_table):
220
220
  columns_to_types_create = columns_to_types.copy()
221
- self._convert_df_datetime(df, columns_to_types_create)
221
+ ordered_df = df[
222
+ list(columns_to_types_create)
223
+ ] # reorder DataFrame so it matches columns_to_types
224
+ self._convert_df_datetime(ordered_df, columns_to_types_create)
222
225
  self.create_table(temp_table, columns_to_types_create)
223
226
  rows: t.List[t.Tuple[t.Any, ...]] = list(
224
- df.replace({np.nan: None}).itertuples(index=False, name=None) # type: ignore
227
+ ordered_df.replace({np.nan: None}).itertuples(index=False, name=None) # type: ignore
225
228
  )
226
229
  conn = self._connection_pool.get()
227
230
  conn.bulk_copy(temp_table.sql(dialect=self.dialect), rows)
@@ -288,8 +288,25 @@ class SnowflakeEngineAdapter(GetCurrentCatalogFromFunctionMixin, ClusteredByMixi
288
288
  is_snowpark_dataframe = snowpark and isinstance(df, snowpark.dataframe.DataFrame)
289
289
 
290
290
  def query_factory() -> Query:
291
+ # The catalog needs to be normalized before being passed to Snowflake's library functions because they
292
+ # just wrap whatever they are given in quotes without checking if its already quoted
293
+ database = (
294
+ normalize_identifiers(temp_table.catalog, dialect=self.dialect)
295
+ if temp_table.catalog
296
+ else None
297
+ )
298
+
291
299
  if is_snowpark_dataframe:
292
- df.createOrReplaceTempView(temp_table.sql(dialect=self.dialect, identify=True)) # type: ignore
300
+ temp_table.set("catalog", database)
301
+ df_renamed = df.rename(
302
+ {
303
+ col: exp.to_identifier(col).sql(dialect=self.dialect, identify=True)
304
+ for col in columns_to_types
305
+ }
306
+ ) # type: ignore
307
+ df_renamed.createOrReplaceTempView(
308
+ temp_table.sql(dialect=self.dialect, identify=True)
309
+ ) # type: ignore
293
310
  elif isinstance(df, pd.DataFrame):
294
311
  from snowflake.connector.pandas_tools import write_pandas
295
312
 
@@ -325,11 +342,7 @@ class SnowflakeEngineAdapter(GetCurrentCatalogFromFunctionMixin, ClusteredByMixi
325
342
  df,
326
343
  temp_table.name,
327
344
  schema=temp_table.db or None,
328
- database=normalize_identifiers(temp_table.catalog, dialect=self.dialect).sql(
329
- dialect=self.dialect
330
- )
331
- if temp_table.catalog
332
- else None,
345
+ database=database.sql(dialect=self.dialect) if database else None,
333
346
  chunk_size=self.DEFAULT_BATCH_SIZE,
334
347
  overwrite=True,
335
348
  table_type="temp",
@@ -279,10 +279,16 @@ class SparkEngineAdapter(
279
279
  ) -> PySparkDataFrame:
280
280
  pyspark_df = self.try_get_pyspark_df(generic_df)
281
281
  if pyspark_df:
282
+ if columns_to_types:
283
+ # ensure Spark dataframe column order matches columns_to_types
284
+ pyspark_df = pyspark_df.select(*columns_to_types)
282
285
  return pyspark_df
283
286
  df = self.try_get_pandas_df(generic_df)
284
287
  if df is None:
285
288
  raise SQLMeshError("Ensure PySpark DF can only be run on a PySpark or Pandas DataFrame")
289
+ if columns_to_types:
290
+ # ensure Pandas dataframe column order matches columns_to_types
291
+ df = df[list(columns_to_types)]
286
292
  kwargs = (
287
293
  dict(schema=self.sqlglot_to_spark_types(columns_to_types)) if columns_to_types else {}
288
294
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlmesh
3
- Version: 0.181.2.dev13
3
+ Version: 0.181.2.dev15
4
4
  Summary: Next-generation data transformation framework
5
5
  Author-email: "TobikoData Inc." <engineering@tobikodata.com>
6
6
  License: Apache License
@@ -243,8 +243,7 @@ Requires-Dist: pymssql; extra == "azuresql"
243
243
  Provides-Extra: bigquery
244
244
  Requires-Dist: google-cloud-bigquery[pandas]; extra == "bigquery"
245
245
  Requires-Dist: google-cloud-bigquery-storage; extra == "bigquery"
246
- Provides-Extra: bigframes
247
- Requires-Dist: bigframes>=1.32.0; extra == "bigframes"
246
+ Requires-Dist: bigframes>=1.32.0; extra == "bigquery"
248
247
  Provides-Extra: clickhouse
249
248
  Requires-Dist: clickhouse-connect; extra == "clickhouse"
250
249
  Provides-Extra: databricks
@@ -322,7 +321,7 @@ Requires-Dist: slack_sdk; extra == "slack"
322
321
  Provides-Extra: snowflake
323
322
  Requires-Dist: cryptography; extra == "snowflake"
324
323
  Requires-Dist: snowflake-connector-python[pandas,secure-local-storage]; extra == "snowflake"
325
- Requires-Dist: snowflake-snowpark-python; python_version < "3.12" and extra == "snowflake"
324
+ Requires-Dist: snowflake-snowpark-python; extra == "snowflake"
326
325
  Provides-Extra: trino
327
326
  Requires-Dist: trino; extra == "trino"
328
327
  Provides-Extra: web
@@ -1,5 +1,5 @@
1
1
  sqlmesh/__init__.py,sha256=DRovDXI-9D9xeYDP7t8Fq7mI31S2btlN-LHPOK3y7PA,7240
2
- sqlmesh/_version.py,sha256=gebTVi566k47-e0HTLTcDc8t8hEPYLViMd5_FGbf8ac,530
2
+ sqlmesh/_version.py,sha256=EToOtvjIAwPX3NLgVASWB6SZBskkOXmQpMqqL4DNou4,530
3
3
  sqlmesh/magics.py,sha256=9oY1Uz8uwsuTtPRg9HTYDxnGiJ7-OVRCpmCgAhbKHUU,39431
4
4
  sqlmesh/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  sqlmesh/cicd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -59,21 +59,21 @@ sqlmesh/core/config/ui.py,sha256=jsO-S6_d9NkLZGG5pT4mgKgxMF34KzkDociZAMvCX3U,278
59
59
  sqlmesh/core/engine_adapter/__init__.py,sha256=two_WTs4UnSNp-fscJh8vOunJq0Xi37EuDuMjKsKuNE,2281
60
60
  sqlmesh/core/engine_adapter/_typing.py,sha256=BAM_U7Vsi0k37XHu_nNnu3whXxuTVDey_uZe3aelKYY,1033
61
61
  sqlmesh/core/engine_adapter/athena.py,sha256=kVkGhDhjVd_8zsvq7B94kr_CHD0bct6XXFkhzrOjQOY,26158
62
- sqlmesh/core/engine_adapter/base.py,sha256=b6JU8b54JMi-Hnn6POlsg1t8IO_srKM2HFcyq6PXegU,99639
62
+ sqlmesh/core/engine_adapter/base.py,sha256=Ni9kF_ms6s5xKGPgroMAsxjqTvJmX1relpGaDAxYsuI,99947
63
63
  sqlmesh/core/engine_adapter/base_postgres.py,sha256=DOsOdCJyQAVfA9S0GznuH0J1bonMqYVP_yJLDYcxFYM,6772
64
64
  sqlmesh/core/engine_adapter/bigquery.py,sha256=mdgXlFOdyz6Qvno_io_9hm5QLEOQncLnT5itnOU7Ock,47845
65
65
  sqlmesh/core/engine_adapter/clickhouse.py,sha256=4ACsYsZ8-gvyCozwoEMEayTTUdMjmNea4xUkxtXw6R4,34907
66
66
  sqlmesh/core/engine_adapter/databricks.py,sha256=AbNbnt9nQdOd7lTov2zsKROZlzgV2fLvOYXam3cowvk,14507
67
67
  sqlmesh/core/engine_adapter/duckdb.py,sha256=FfNmBzLySDDi--nTlsSavTwdperCzhpYzDoroCilPcA,4900
68
68
  sqlmesh/core/engine_adapter/mixins.py,sha256=HMB0Z9O3p5jaTZMolKiWKqpVDZokf5GoI99YXwEJ8bc,22470
69
- sqlmesh/core/engine_adapter/mssql.py,sha256=cp5JRO-Nkb0Bf0LqU3ApKVJw6d8Ko03sgjoSB8LPGag,11619
69
+ sqlmesh/core/engine_adapter/mssql.py,sha256=N21kjLrvloxLPMCGloQx5Jew5SIddrCVq3lTrnl8coc,11788
70
70
  sqlmesh/core/engine_adapter/mysql.py,sha256=HnMtNjxnCVz3X3-uK8Im-BNgLo_viX6QH3Uo8rMfPeY,6935
71
71
  sqlmesh/core/engine_adapter/postgres.py,sha256=XWnV7MDndkCRokb7ih2yxXodw4W8E61yHbuWtRTFE3k,4570
72
72
  sqlmesh/core/engine_adapter/redshift.py,sha256=_rZWv4rchDAzB6m6idoV1NLHFBKK_gM4nlfeErqXEcE,16691
73
73
  sqlmesh/core/engine_adapter/risingwave.py,sha256=NXXuiPfbB5ZSp7igMqZpaX2c-5TYreOlIouPU7iCVJ8,936
74
74
  sqlmesh/core/engine_adapter/shared.py,sha256=NyF2osSJDWPp7KlJUBR4GZcS_cJFr4daUPvhGyp4XcQ,12909
75
- sqlmesh/core/engine_adapter/snowflake.py,sha256=LKiQq43JNukLcDq5OnKALpiZ0xjFK7fVJYJvlXHAWxo,23361
76
- sqlmesh/core/engine_adapter/spark.py,sha256=VOXStkBBZIzebPo_ivdQFvZtRMiWJHHo7h118Lh5Yt8,22384
75
+ sqlmesh/core/engine_adapter/snowflake.py,sha256=M0--yVpl8S9x1kjz7t-lcIORewtnA7dEPEd4oBehb7Q,23967
76
+ sqlmesh/core/engine_adapter/spark.py,sha256=NwtVkdvy39bD6gnrIvIzITa0g510KZOrP3jz0aMKjwI,22711
77
77
  sqlmesh/core/engine_adapter/trino.py,sha256=pZ2E1owyC6DPmkU3RkibR3CIE1gE-8fNd016YHh52II,14915
78
78
  sqlmesh/core/linter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
79
79
  sqlmesh/core/linter/definition.py,sha256=UL05OjFBfoLSYGWXNf4zjZYzIKr-OyFIMIcIh7RhR8s,5237
@@ -266,7 +266,7 @@ sqlmesh/utils/pandas.py,sha256=j_tYhuPcWpzuPceZZ6IhdTVbmxYyGJW7l4FHr4bQqjM,1824
266
266
  sqlmesh/utils/pydantic.py,sha256=ioaAzYF42PutEJRyAS11-AHguiCG3yWI6VRcTVa2G-g,10470
267
267
  sqlmesh/utils/rich.py,sha256=xNZyPCqEc4TAlJlsEthg-5eYUWpaizz0QjBzO7a1Yv4,1509
268
268
  sqlmesh/utils/yaml.py,sha256=np-WVcwmwsKghCgAj1OBBMsK1SXSRn4wR-H37cGiFr8,2282
269
- sqlmesh-0.181.2.dev13.dist-info/licenses/LICENSE,sha256=OlMefUjgWJdULtf84BLW0AZZcY8DwdgQqb_1j2862j8,11346
269
+ sqlmesh-0.181.2.dev15.dist-info/licenses/LICENSE,sha256=OlMefUjgWJdULtf84BLW0AZZcY8DwdgQqb_1j2862j8,11346
270
270
  web/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
271
271
  web/client/dist/index.html,sha256=yO5MoJN_pmodwLqC5Uq89JoZSis5xxeHTmEw-TlVwUE,5472
272
272
  web/client/dist/assets/Audits-Dt3QUYCw.js,sha256=26GaGzCP6oOh5tsDrjvkgDgVJrYnsenF_GRK_XF__8Q,997
@@ -383,8 +383,8 @@ web/server/api/endpoints/models.py,sha256=SzS5bshzdXyM6hb948sZ_3k-xhpGCHkxkb7pHz
383
383
  web/server/api/endpoints/modules.py,sha256=8hqqgonGay_mJmpCw0IdbjsPhWlQH2VLdKAqha-myac,468
384
384
  web/server/api/endpoints/plan.py,sha256=OYuQ_4dgbhG9ibTcX1a8mvYgH3ANxw9Fhbb4wg6QWqc,9222
385
385
  web/server/api/endpoints/table_diff.py,sha256=Wd5YxeKbZB7AkrDvqFgvV9ZQlnKYOF1n5W_w2EHE_Zw,2085
386
- sqlmesh-0.181.2.dev13.dist-info/METADATA,sha256=rm0vnt9L26-ikwSHwg3IVFvH86GnFciD-gGx7oHiGvs,25308
387
- sqlmesh-0.181.2.dev13.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
388
- sqlmesh-0.181.2.dev13.dist-info/entry_points.txt,sha256=pIYKtg-u-uO7BK_Y0qrdmfyj0bYrcMc3Xiqr5WE3VFk,121
389
- sqlmesh-0.181.2.dev13.dist-info/top_level.txt,sha256=bspjo5vjELQkuN0qKuTFIbsrUt3Zeo8D2mlKeHG1LdE,12
390
- sqlmesh-0.181.2.dev13.dist-info/RECORD,,
386
+ sqlmesh-0.181.2.dev15.dist-info/METADATA,sha256=ILT-rR2eaiEL98igaj4gVC8k1u4blqAWFmPA7xdO-_4,25253
387
+ sqlmesh-0.181.2.dev15.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
388
+ sqlmesh-0.181.2.dev15.dist-info/entry_points.txt,sha256=pIYKtg-u-uO7BK_Y0qrdmfyj0bYrcMc3Xiqr5WE3VFk,121
389
+ sqlmesh-0.181.2.dev15.dist-info/top_level.txt,sha256=bspjo5vjELQkuN0qKuTFIbsrUt3Zeo8D2mlKeHG1LdE,12
390
+ sqlmesh-0.181.2.dev15.dist-info/RECORD,,