From 1ed4b0e464c14fd499664b1826bbe250a2aed95a Mon Sep 17 00:00:00 2001 From: dylan Date: Tue, 4 Nov 2025 21:16:49 +0800 Subject: [PATCH 1/2] First fix --- sqlmesh/core/model/definition.py | 7 +++++++ tests/core/test_model.py | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) 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 1ada9bd4a5..dbf11b946e 100644 --- a/tests/core/test_model.py +++ b/tests/core/test_model.py @@ -12158,3 +12158,19 @@ def test_grants_empty_values(): def test_grants_table_type(kind: t.Union[str, _ModelKind], expected: DataObjectType): model = create_sql_model("test_table", parse_one("SELECT 1 as id"), kind=kind) assert model.grants_table_type == expected + + +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() From 9700b2363ea4dffb2018934ce267cee9e0634bfb Mon Sep 17 00:00:00 2001 From: dylan Date: Tue, 4 Nov 2025 21:43:54 +0800 Subject: [PATCH 2/2] Fix: Reject audits on EMBEDDED models (#5546) --- examples/sushi_dbt/models/schema.yml | 2 -- 1 file changed, 2 deletions(-) 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