Skip to content

Commit 1107e93

Browse files
committed
feedback
1 parent 4fa8614 commit 1107e93

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

sqlmesh/dbt/context.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,7 @@ def context_for_dependencies(self, dependencies: Dependencies) -> DbtContext:
265265
else:
266266
models[ref] = t.cast(ModelConfig, model)
267267
else:
268-
exception = MissingModelError(f"Model '{ref}' was not found.")
269-
exception.model_name = ref
268+
exception = MissingModelError(ref)
270269
raise exception
271270

272271
for source in dependencies.sources:

sqlmesh/utils/errors.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ def __init__(self, message: str | Exception, location: t.Optional[Path] = None)
3636
class MissingModelError(ConfigError):
3737
"""Raised when a model that is referenced is missing."""
3838

39-
model_name: str
39+
def __init__(self, model_name: str) -> None:
40+
self.model_name = model_name
41+
super().__init__(f"Model '{model_name}' was not found.")
4042

4143

4244
class MissingDependencyError(SQLMeshError):

tests/dbt/test_model.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def test_model_test_circular_references() -> None:
5050
downstream_model.check_for_circular_test_refs(context)
5151

5252

53-
def test_load_invalid_ref_audit_constraints(tmp_path: Path) -> None:
53+
def test_load_invalid_ref_audit_constraints(tmp_path: Path, caplog) -> None:
5454
yaml = YAML()
5555
dbt_project_dir = tmp_path / "dbt"
5656
dbt_project_dir.mkdir()
@@ -126,6 +126,10 @@ def test_load_invalid_ref_audit_constraints(tmp_path: Path) -> None:
126126
yaml.dump(dbt_profile_config, f)
127127

128128
context = Context(paths=dbt_project_dir)
129+
assert (
130+
"Skipping audit 'relationships_full_model_cola__cola__ref_not_real_model_' because model 'not_real_model' is not a valid ref"
131+
in caplog.text
132+
)
129133
fqn = '"local"."main"."full_model"'
130134
assert fqn in context.snapshots
131135
# The audit isn't loaded due to the invalid ref

0 commit comments

Comments
 (0)