Fix: Create empty physical tables for fully annotated self-referential models#5391
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a regression where self-referential models with fully annotated queries failed to create empty physical tables during initialization. The issue was introduced by a refactor that coupled model table creation with evaluation.
- Adds logic to handle self-referential models with annotated queries
- Includes a comprehensive integration test for the fixed scenario
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| sqlmesh/core/snapshot/evaluator.py | Extends condition to create empty tables for self-referential annotated models |
| tests/core/test_integration.py | Adds integration test verifying self-referential model behavior |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| assert context.engine_adapter.table_exists(snapshot.table_name(is_deployable=False)) | ||
|
|
||
|
|
||
| @time_machine.travel("2023-01-08 00:00:00 UTC") |
There was a problem hiding this comment.
This looks like a good example of a test that doesn't actually need the sushi project at all.
Wouldnt this work much faster with an empty duckdb context?
There was a problem hiding this comment.
Yes. It looks like this pattern has been used in other tests too. We might consider refactoring this separately.
This fixes a regression introduced by the refactor that coupled model table creation with evaluation.
Self-referential models required
columnsto be specified in the definition despite having fully annotated queries.