File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed
Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change 3838logger = logging .getLogger (__name__ )
3939
4040
41+ logger = logging .getLogger (__name__ )
42+
43+
4144INCREMENTAL_BY_TIME_STRATEGIES = set (["delete+insert" , "insert_overwrite" , "microbatch" ])
4245INCREMENTAL_BY_UNIQUE_KEY_STRATEGIES = set (["merge" ])
4346
@@ -521,14 +524,24 @@ def to_sqlmesh(
521524 raise ConfigError (
522525 f"Failed to parse model '{ self .canonical_name (context )} ' partition_by field '{ p } ' in '{ self .path } ': { e } "
523526 ) from e
524- else :
525- partitioned_by .append (self ._big_query_partition_by_expr (context ))
526- optional_kwargs ["partitioned_by" ] = partitioned_by
527+ elif isinstance (self .partition_by , dict ):
528+ if context .target .dialect == "bigquery" :
529+ partitioned_by .append (self ._big_query_partition_by_expr (context ))
530+ else :
531+ logger .warning (
532+ "Ignoring partition_by config for model '%s' targeting %s. The format of the config field is only supported for BigQuery." ,
533+ self .name ,
534+ context .target .dialect ,
535+ )
536+
537+ if partitioned_by :
538+ optional_kwargs ["partitioned_by" ] = partitioned_by
527539
528540 if self .cluster_by :
529541 if isinstance (kind , ViewKind ):
530542 logger .warning (
531- f"Ignoring cluster_by config for model '{ self .name } '; cluster_by is not supported for views."
543+ "Ignoring cluster_by config for model '%s'; cluster_by is not supported for views." ,
544+ self .name ,
532545 )
533546 else :
534547 clustered_by = []
Original file line number Diff line number Diff line change @@ -1469,6 +1469,9 @@ def test_partition_by(sushi_test_project: Project):
14691469 model_config .partition_by = {"field" : "ds" , "data_type" : "date" , "granularity" : "day" }
14701470 assert model_config .to_sqlmesh (context ).partitioned_by == [exp .to_column ("ds" , quoted = True )]
14711471
1472+ context .target = DuckDbConfig (name = "target" , schema = "foo" )
1473+ assert model_config .to_sqlmesh (context ).partitioned_by == []
1474+
14721475
14731476@pytest .mark .xdist_group ("dbt_manifest" )
14741477def test_partition_by_none (sushi_test_project : Project ):
You can’t perform that action at this time.
0 commit comments