diff --git a/examples/sushi_dbt/models/schema.yml b/examples/sushi_dbt/models/schema.yml index d42d64bcce..8fd62c4efe 100644 --- a/examples/sushi_dbt/models/schema.yml +++ b/examples/sushi_dbt/models/schema.yml @@ -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 diff --git a/sqlmesh/core/model/definition.py b/sqlmesh/core/model/definition.py index 0a20ab23b2..b6ea6d23e1 100644 --- a/sqlmesh/core/model/definition.py +++ b/sqlmesh/core/model/definition.py @@ -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. diff --git a/tests/core/test_model.py b/tests/core/test_model.py index a45e1e1e67..3e0f6d40b9 100644 --- a/tests/core/test_model.py +++ b/tests/core/test_model.py @@ -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()