File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change 22
33import datetime
44import typing as t
5+ import logging
56
67from sqlglot import exp
78from sqlglot .errors import SqlglotError
3536 from sqlmesh .dbt .context import DbtContext
3637
3738
39+ logger = logging .getLogger (__name__ )
40+
41+
3842INCREMENTAL_BY_TIME_STRATEGIES = set (["delete+insert" , "insert_overwrite" , "microbatch" ])
3943INCREMENTAL_BY_UNIQUE_KEY_STRATEGIES = set (["merge" ])
4044
@@ -517,8 +521,13 @@ def to_sqlmesh(
517521 raise ConfigError (
518522 f"Failed to parse model '{ self .canonical_name (context )} ' partition_by field '{ p } ' in '{ self .path } ': { e } "
519523 ) from e
520- elif isinstance (self .partition_by , dict ) and context .target .dialect == "bigquery" :
521- partitioned_by .append (self ._big_query_partition_by_expr (context ))
524+ elif isinstance (self .partition_by , dict ):
525+ if context .target .dialect == "bigquery" :
526+ partitioned_by .append (self ._big_query_partition_by_expr (context ))
527+ else :
528+ logger .warning (
529+ f"Ignoring partition_by config for model '{ self .name } ' targeting { context .target .dialect } ; it is only supported for bigquery."
530+ )
522531
523532 if partitioned_by :
524533 optional_kwargs ["partitioned_by" ] = partitioned_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