Skip to content

Fix: Create empty physical tables for fully annotated self-referential models#5391

Merged
izeigerman merged 2 commits intomainfrom
fix-create-table-for-annotated-self-ref-model
Sep 17, 2025
Merged

Fix: Create empty physical tables for fully annotated self-referential models#5391
izeigerman merged 2 commits intomainfrom
fix-create-table-for-annotated-self-ref-model

Conversation

@izeigerman
Copy link
Collaborator

This fixes a regression introduced by the refactor that coupled model table creation with evaluation.

Self-referential models required columns to be specified in the definition despite having fully annotated queries.

@izeigerman izeigerman requested review from a team and Copilot September 17, 2025 00:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It looks like this pattern has been used in other tests too. We might consider refactoring this separately.

@izeigerman izeigerman enabled auto-merge (squash) September 17, 2025 03:18
@izeigerman izeigerman merged commit e46caec into main Sep 17, 2025
36 checks passed
@izeigerman izeigerman deleted the fix-create-table-for-annotated-self-ref-model branch September 17, 2025 03:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants