Skip to content

Commit 33fa5ea

Browse files
committed
Fix: Support of the null meta config in dbt model / source definitions (#5598)
1 parent ac65e8a commit 33fa5ea

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
@@ -40,7 +40,9 @@ def load_yaml(source: str | Path) -> t.Dict:
4040
raise ConfigError(f"{source}: {ex}" if isinstance(source, Path) else f"{ex}")
4141

4242

43-
def parse_meta(v: t.Dict[str, t.Any]) -> t.Dict[str, t.Any]:
43+
def parse_meta(v: t.Optional[t.Dict[str, t.Any]]) -> t.Dict[str, t.Any]:
44+
if v is None:
45+
return {}
4446
for key, value in v.items():
4547
if isinstance(value, str):
4648
v[key] = try_str_to_bool(value)
@@ -109,7 +111,7 @@ def _validate_list(cls, v: t.Union[str, t.List[str]]) -> t.List[str]:
109111

110112
@field_validator("meta", mode="before")
111113
@classmethod
112-
def _validate_meta(cls, v: t.Dict[str, t.Union[str, t.Any]]) -> t.Dict[str, t.Any]:
114+
def _validate_meta(cls, v: t.Optional[t.Dict[str, t.Union[str, t.Any]]]) -> t.Dict[str, t.Any]:
113115
return parse_meta(v)
114116

115117
_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
@@ -34,8 +34,14 @@ sources:
3434
schema: raw
3535
tables:
3636
- name: items
37+
config:
38+
meta:
3739
- name: orders
40+
config:
41+
meta:
3842
- name: order_items
43+
config:
44+
meta:
3945
freshness:
4046
warn_after: {count: 10, period: hour}
4147
error_after: {count: 11, period: hour}

0 commit comments

Comments
 (0)