Skip to content

Fix: Redundant creation of view models during the first evaluation#5337

Merged
izeigerman merged 1 commit intomainfrom
fix-redundant-view-creation
Sep 9, 2025
Merged

Fix: Redundant creation of view models during the first evaluation#5337
izeigerman merged 1 commit intomainfrom
fix-redundant-view-creation

Conversation

@izeigerman
Copy link
Collaborator

Closes #5331

The original intention was to create an empty table first if the user explicitly specified column types. However, model.annotated can return True for VIEW models as well if its types are known statically. This PR makes sure that the empty table creation only applies to materialized models.

@izeigerman izeigerman requested review from a team and Copilot September 9, 2025 21:52
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 an issue where view models were incorrectly triggering empty table creation during evaluation. The fix ensures that empty table creation only applies to materialized models when column types are explicitly provided, preventing redundant view model creation.

  • Replaced model.annotated check with a more specific condition for materialized models
  • Added logic to verify both materialization type and column type availability
  • Updated test assertion to check exact call count rather than just call occurrence

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
sqlmesh/core/snapshot/evaluator.py Added logic to restrict empty table creation to materialized models with known column types
tests/core/test_snapshot_evaluator.py Updated test assertion to verify exact call count for view creation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@izeigerman izeigerman merged commit cc2e1f1 into main Sep 9, 2025
36 of 37 checks passed
@izeigerman izeigerman deleted the fix-redundant-view-creation branch September 9, 2025 22:40
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.

RisingWave: SQLMesh plan unnecessarily always recreates MVs

3 participants