Skip to content

Commit b9d0f91

Browse files
authored
Fix: Support of the null meta config in dbt model / source definitions (#5598)
1 parent 7cfb218 commit b9d0f91

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

sqlmesh/dbt/common.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ def load_yaml(source: str | Path) -> t.Dict:
4646
raise ConfigError(f"{source}: {ex}" if isinstance(source, Path) else f"{ex}")
4747

4848

49-
def parse_meta(v: t.Dict[str, t.Any]) -> t.Dict[str, t.Any]:
49+
def parse_meta(v: t.Optional[t.Dict[str, t.Any]]) -> t.Dict[str, t.Any]:
50+
if v is None:
51+
return {}
5052
for key, value in v.items():
5153
if isinstance(value, str):
5254
v[key] = try_str_to_bool(value)
@@ -115,7 +117,7 @@ def _validate_list(cls, v: t.Union[str, t.List[str]]) -> t.List[str]:
115117

116118
@field_validator("meta", mode="before")
117119
@classmethod
118-
def _validate_meta(cls, v: t.Dict[str, t.Union[str, t.Any]]) -> t.Dict[str, t.Any]:
120+
def _validate_meta(cls, v: t.Optional[t.Dict[str, t.Union[str, t.Any]]]) -> t.Dict[str, t.Any]:
119121
return parse_meta(v)
120122

121123
_FIELD_UPDATE_STRATEGY: t.ClassVar[t.Dict[str, UpdateStrategy]] = {

tests/fixtures/dbt/sushi_test/models/schema.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,14 @@ sources:
9191
schema: raw
9292
tables:
9393
- name: items
94+
config:
95+
meta:
9496
- name: orders
97+
config:
98+
meta:
9599
- name: order_items
100+
config:
101+
meta:
96102
freshness:
97103
warn_after: {count: 10, period: hour}
98104
error_after: {count: 11, period: hour}

0 commit comments

Comments
 (0)