Skip to content

Commit b2276bf

Browse files
committed
fix: pydantic v1 issues with dbt 1.6 semantic models
1 parent 5011741 commit b2276bf

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

sqlmesh/dbt/manifest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@
8080
IGNORED_PACKAGES = {"elementary"}
8181
BUILTIN_CALLS = {*BUILTIN_GLOBALS, *BUILTIN_FILTERS}
8282

83+
# Patch Semantic Manifest to skip validation and avoid Pydantic v1 errors on DBT 1.6
84+
# We patch for 1.7+ since we don't care about semantic models
85+
if DBT_VERSION >= (1, 6, 0):
86+
from dbt.contracts.graph.semantic_manifest import SemanticManifest # type: ignore
87+
88+
SemanticManifest.validate = lambda _: True # type: ignore
89+
8390

8491
class ManifestHelper:
8592
def __init__(
@@ -456,6 +463,8 @@ def _load_manifest(self) -> Manifest:
456463
register_adapter(runtime_config) # type: ignore
457464

458465
manifest = ManifestLoader.get_full_manifest(runtime_config)
466+
# This adapter doesn't care about semantic models so we clear them out to avoid issues
467+
manifest.semantic_models = {}
459468
reset_adapters()
460469
return manifest
461470

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,23 @@ sources:
5252
tables:
5353
- name: items
5454
- name: orders
55+
56+
semantic_models:
57+
- name: top_waiters
58+
description: Some description
59+
model: ref('top_waiters')
60+
measures:
61+
- name: total_waiters
62+
agg: sum
63+
expr: waiter
64+
dimensions:
65+
- name: waiter
66+
type: categorical
67+
68+
metrics:
69+
- name: some_waiter_thing
70+
description: Something
71+
type: simple
72+
label: testing
73+
type_params:
74+
measure: total_waiters

0 commit comments

Comments
 (0)