Skip to content

Commit 991b25d

Browse files
authored
Fix!: move cron to metadata hash (#1600)
1 parent 0cfc593 commit 991b25d

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"requests",
4747
"rich[jupyter]",
4848
"ruamel.yaml",
49-
"sqlglot~=18.15.0",
49+
"sqlglot~=18.16.1",
5050
],
5151
extras_require={
5252
"bigquery": [

sqlmesh/core/model/definition.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -749,14 +749,13 @@ def _data_hash_values(self) -> t.List[str]:
749749
data = [
750750
str(self.sorted_python_env),
751751
*self.kind.data_hash_values,
752-
self.cron,
753752
self.storage_format,
754753
str(self.lookback),
755754
*(expr.sql() for expr in (self.partitioned_by or [])),
756755
*(self.clustered_by or []),
757756
self.stamp,
758757
self.physical_schema,
759-
str(self.interval_unit_) if self.interval_unit_ is not None else None,
758+
str(self.interval_unit) if self.interval_unit is not None else None,
760759
]
761760

762761
for column_name, column_type in (self.columns_to_types_ or {}).items():
@@ -791,6 +790,7 @@ def metadata_hash(self, audits: t.Dict[str, ModelAudit]) -> str:
791790
self.dialect,
792791
self.owner,
793792
self.description,
793+
self.cron,
794794
str(self.start) if self.start else None,
795795
str(self.retention) if self.retention else None,
796796
str(self.batch_size) if self.batch_size is not None else None,

tests/core/engine_adapter/test_mssql.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def test_insert_overwrite_by_time_partition_supports_insert_overwrite_pandas(
110110
[(1, "2022-01-01"), (2, "2022-01-02")],
111111
)
112112
assert to_sql_calls(adapter) == [
113-
f"""IF NOT EXISTS (SELECT * FROM information_schema.tables WHERE table_name = '__temp_test_table_{temp_table_id}') EXEC('CREATE TABLE "__temp_test_table_{temp_table_id}" ("a" INTEGER, "ds" TEXT)');""",
113+
f"""IF NOT EXISTS (SELECT * FROM information_schema.tables WHERE table_name = '__temp_test_table_{temp_table_id}') EXEC('CREATE TABLE "__temp_test_table_{temp_table_id}" ("a" INTEGER, "ds" VARCHAR(MAX))');""",
114114
f"""MERGE INTO "test_table" AS "__MERGE_TARGET__" USING (SELECT "a", "ds" FROM (SELECT "a", "ds" FROM "__temp_test_table_{temp_table_id}") AS "_subquery" WHERE "ds" BETWEEN '2022-01-01' AND '2022-01-02') AS "__MERGE_SOURCE__" ON (1 = 0) WHEN NOT MATCHED BY SOURCE AND "ds" BETWEEN '2022-01-01' AND '2022-01-02' THEN DELETE WHEN NOT MATCHED THEN INSERT ("a", "ds") VALUES ("a", "ds");""",
115115
f'DROP TABLE IF EXISTS "__temp_test_table_{temp_table_id}";',
116116
]
@@ -143,7 +143,7 @@ def test_insert_overwrite_by_time_partition_replace_where_pandas(
143143
)
144144

145145
assert to_sql_calls(adapter) == [
146-
f"""IF NOT EXISTS (SELECT * FROM information_schema.tables WHERE table_name = '__temp_test_table_{temp_table_id}') EXEC('CREATE TABLE "__temp_test_table_{temp_table_id}" ("a" INTEGER, "ds" TEXT)');""",
146+
f"""IF NOT EXISTS (SELECT * FROM information_schema.tables WHERE table_name = '__temp_test_table_{temp_table_id}') EXEC('CREATE TABLE "__temp_test_table_{temp_table_id}" ("a" INTEGER, "ds" VARCHAR(MAX))');""",
147147
f"""MERGE INTO "test_table" AS "__MERGE_TARGET__" USING (SELECT "a", "ds" FROM (SELECT "a", "ds" FROM "__temp_test_table_{temp_table_id}") AS "_subquery" WHERE "ds" BETWEEN '2022-01-01' AND '2022-01-02') AS "__MERGE_SOURCE__" ON (1 = 0) WHEN NOT MATCHED BY SOURCE AND "ds" BETWEEN '2022-01-01' AND '2022-01-02' THEN DELETE WHEN NOT MATCHED THEN INSERT ("a", "ds") VALUES ("a", "ds");""",
148148
f'DROP TABLE IF EXISTS "__temp_test_table_{temp_table_id}";',
149149
]
@@ -190,7 +190,7 @@ def test_create_table(make_mocked_engine_adapter: t.Callable):
190190
adapter.create_table("test_table", columns_to_types)
191191

192192
adapter.cursor.execute.assert_called_once_with(
193-
"""IF NOT EXISTS (SELECT * FROM information_schema.tables WHERE table_name = 'test_table') EXEC('CREATE TABLE "test_table" ("cola" INTEGER, "colb" TEXT)');"""
193+
"""IF NOT EXISTS (SELECT * FROM information_schema.tables WHERE table_name = 'test_table') EXEC('CREATE TABLE "test_table" ("cola" INTEGER, "colb" VARCHAR(MAX))');"""
194194
)
195195

196196

@@ -209,7 +209,7 @@ def test_create_table_properties(make_mocked_engine_adapter: t.Callable):
209209
)
210210

211211
adapter.cursor.execute.assert_called_once_with(
212-
"""IF NOT EXISTS (SELECT * FROM information_schema.tables WHERE table_name = 'test_table') EXEC('CREATE TABLE "test_table" ("cola" INTEGER, "colb" TEXT)');"""
212+
"""IF NOT EXISTS (SELECT * FROM information_schema.tables WHERE table_name = 'test_table') EXEC('CREATE TABLE "test_table" ("cola" INTEGER, "colb" VARCHAR(MAX))');"""
213213
)
214214

215215

@@ -321,7 +321,7 @@ def test_create_table_primary_key(make_mocked_engine_adapter: t.Callable):
321321
adapter.create_table("test_table", columns_to_types, primary_key=("cola", "colb"))
322322

323323
adapter.cursor.execute.assert_called_once_with(
324-
"""IF NOT EXISTS (SELECT * FROM information_schema.tables WHERE table_name = 'test_table') EXEC('CREATE TABLE "test_table" ("cola" INTEGER, "colb" TEXT, PRIMARY KEY ("cola", "colb"))');"""
324+
"""IF NOT EXISTS (SELECT * FROM information_schema.tables WHERE table_name = 'test_table') EXEC('CREATE TABLE "test_table" ("cola" INTEGER, "colb" VARCHAR(MAX), PRIMARY KEY ("cola", "colb"))');"""
325325
)
326326

327327

tests/core/test_snapshot.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,8 @@ def test_fingerprint(model: Model, parent_model: Model):
512512
fingerprint = fingerprint_from_node(model, nodes={})
513513

514514
original_fingerprint = SnapshotFingerprint(
515-
data_hash="3811098861",
516-
metadata_hash="3858405978",
515+
data_hash="3271791330",
516+
metadata_hash="1583920325",
517517
)
518518

519519
assert fingerprint == original_fingerprint
@@ -559,8 +559,8 @@ def test_fingerprint_seed_model():
559559
)
560560

561561
expected_fingerprint = SnapshotFingerprint(
562-
data_hash="3270932819",
563-
metadata_hash="1017437962",
562+
data_hash="3369758245",
563+
metadata_hash="3176816456",
564564
)
565565

566566
model = load_sql_based_model(expressions, path=Path("./examples/sushi/models/test_model.sql"))
@@ -599,8 +599,8 @@ def test_fingerprint_jinja_macros(model: Model):
599599
}
600600
)
601601
original_fingerprint = SnapshotFingerprint(
602-
data_hash="2864998504",
603-
metadata_hash="3858405978",
602+
data_hash="3383317328",
603+
metadata_hash="1583920325",
604604
)
605605

606606
fingerprint = fingerprint_from_node(model, nodes={})

0 commit comments

Comments
 (0)