Skip to content

Commit 1ed4b0e

Browse files
committed
First fix
1 parent 119b623 commit 1ed4b0e

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

sqlmesh/core/model/definition.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,13 @@ def validate_definition(self) -> None:
10351035
# Will raise if the custom materialization points to an invalid class
10361036
get_custom_materialization_type_or_raise(self.kind.materialization)
10371037

1038+
# Embedded model kind shouldn't have audits
1039+
if self.kind.name == ModelKindName.EMBEDDED and self.audits:
1040+
raise_config_error(
1041+
"Audits are not supported for embedded models",
1042+
self._path,
1043+
)
1044+
10381045
def is_breaking_change(self, previous: Model) -> t.Optional[bool]:
10391046
"""Determines whether this model is a breaking change in relation to the `previous` model.
10401047

tests/core/test_model.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12158,3 +12158,19 @@ def test_grants_empty_values():
1215812158
def test_grants_table_type(kind: t.Union[str, _ModelKind], expected: DataObjectType):
1215912159
model = create_sql_model("test_table", parse_one("SELECT 1 as id"), kind=kind)
1216012160
assert model.grants_table_type == expected
12161+
12162+
12163+
def test_audits_in_embedded_model():
12164+
expression = d.parse(
12165+
"""
12166+
MODEL (
12167+
name test.embedded_with_audits,
12168+
kind EMBEDDED,
12169+
audits (not_null (columns := (id)))
12170+
);
12171+
12172+
SELECT 1 AS id, 'A' as value
12173+
"""
12174+
)
12175+
with pytest.raises(ConfigError, match="Audits are not supported for embedded models"):
12176+
load_sql_based_model(expression).validate_definition()

0 commit comments

Comments
 (0)