Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions examples/sushi_dbt/models/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ models:
columns:
- name: waiter_id
description: Waiter id
tests:
- not_null
- name: ds
description: Date
- name: waiter_as_customer_by_day
Expand Down
7 changes: 7 additions & 0 deletions sqlmesh/core/model/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,13 @@ def validate_definition(self) -> None:
# Will raise if the custom materialization points to an invalid class
get_custom_materialization_type_or_raise(self.kind.materialization)

# Embedded model kind shouldn't have audits
if self.kind.name == ModelKindName.EMBEDDED and self.audits:
raise_config_error(
"Audits are not supported for embedded models",
self._path,
)

def is_breaking_change(self, previous: Model) -> t.Optional[bool]:
"""Determines whether this model is a breaking change in relation to the `previous` model.

Expand Down
16 changes: 16 additions & 0 deletions tests/core/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -12176,3 +12176,19 @@ def execution_date(evaluator):
)
model = load_sql_based_model(expressions)
assert_exp_eq(model.render_query(), '''SELECT '1970-01-01' AS "col"''')


def test_audits_in_embedded_model():
expression = d.parse(
"""
MODEL (
name test.embedded_with_audits,
kind EMBEDDED,
audits (not_null (columns := (id)))
);

SELECT 1 AS id, 'A' as value
"""
)
with pytest.raises(ConfigError, match="Audits are not supported for embedded models"):
load_sql_based_model(expression).validate_definition()