File tree Expand file tree Collapse file tree 3 files changed +46
-1
lines changed
Expand file tree Collapse file tree 3 files changed +46
-1
lines changed Original file line number Diff line number Diff line change @@ -711,7 +711,7 @@ def data_hash_values(self) -> t.List[t.Optional[str]]:
711711 gen (self .valid_from_name ),
712712 gen (self .valid_to_name ),
713713 str (self .invalidate_hard_deletes ),
714- gen ( self .time_data_type ),
714+ self .time_data_type . sql ( self . dialect ),
715715 gen (self .batch_size ) if self .batch_size is not None else None ,
716716 ]
717717
Original file line number Diff line number Diff line change 1+ """Use sql(...) instead of gen when computing the data hash of the time data type."""
2+
3+
4+ def migrate (state_sync , ** kwargs ): # type: ignore
5+ pass
Original file line number Diff line number Diff line change @@ -9662,3 +9662,43 @@ def test_invalid_audit_reference():
96629662
96639663 with pytest .raises (ConfigError , match = "Audit 'not_nulll' is undefined" ):
96649664 load_sql_based_model (expressions )
9665+
9666+
9667+ def test_scd_time_data_type_does_not_cause_diff_after_deserialization () -> None :
9668+ for dialect in (
9669+ "athena" ,
9670+ "bigquery" ,
9671+ "clickhouse" ,
9672+ "databricks" ,
9673+ "duckdb" ,
9674+ "dune" ,
9675+ "hive" ,
9676+ "mysql" ,
9677+ "postgres" ,
9678+ "presto" ,
9679+ "redshift" ,
9680+ "snowflake" ,
9681+ "spark" ,
9682+ "trino" ,
9683+ "tsql" ,
9684+ ):
9685+ sql = f"""
9686+ MODEL (
9687+ name test_schema.test_model,
9688+ kind SCD_TYPE_2_BY_COLUMN (
9689+ unique_key ARRAY(col),
9690+ columns ARRAY(col),
9691+ invalidate_hard_deletes TRUE,
9692+ on_destructive_change error
9693+ ),
9694+ dialect { dialect }
9695+ );
9696+
9697+ SELECT
9698+ 1 AS col
9699+ """
9700+
9701+ model = load_sql_based_model (d .parse (sql ))
9702+ deserialized_model = SqlModel .parse_raw (model .json ())
9703+
9704+ assert model .data_hash == deserialized_model .data_hash
You can’t perform that action at this time.
0 commit comments