-
Notifications
You must be signed in to change notification settings - Fork 313
Description
Description
Models defined with kind EMBEDDED are purely virtual and are designed to be in-lined as CTEs into downstream models. They should never be materialized into a physical table.
When an EMBEDDED model includes an audits block (as is currently permitted), the sqlmesh plan command fails because it attempts to execute the audit query against a non-existent physical table, resulting in a 404 Not found error in the database engine (this behavior has been confirmed on BigQuery).
Audits should either be explicitly forbidden on EMBEDDED models during project validation, or they should be silently ignored/omitted during plan generation for this specific model kind.
Minimum Viable Example
-
Create the model definition:
models/broken_embedded_model.sqlMODEL ( name my_project.virtual_source, kind EMBEDDED, columns ( id INT, value STRING ), audits ( not_null(columns := (id)), unique_combination_of_columns(columns := (id)) ) ); -- Minimal dummy SQL that should be inlined SELECT CAST(1 AS INT) AS id, 'A' AS value UNION ALL SELECT CAST(2 AS INT) AS id, 'B' AS value;
-
Run the plan command:
sqlmesh plan
Expected Behavior
- Preferred: The CLI should fail project validation immediately upon load with a clear error: "Audits are not permitted on models with kind EMBEDDED."
- Alternative: The planner should recognize the
EMBEDDEDkind and omit/skip the audit step for this model during the plan generation.
Actual Behavior
The sqlmesh plan fails with a NotFound error because it attempts to query a materialized table proxy for the virtual model to execute the audit:
"my_project"."virtual_source"
NotFound:
404 Not found: Table <project-id>:<schema-physical>.my_project__virtual_source__<hash> was not found in location US; reason: notFound, message: Not found: Table <project-id>:<schema-physical>.my_project__virtual_source__<hash> was not found in location US