Skip to content

Commit 4424859

Browse files
committed
Use is_first_insert instead
1 parent 24a026c commit 4424859

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

sqlmesh/core/snapshot/evaluator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2284,11 +2284,11 @@ def insert(
22842284
) -> None:
22852285
# We should always recreate materialized views across supported engines (Snowflake, BigQuery etc) because
22862286
# if upstream tables were recreated (e.g FULL models), the MVs would be silently invalidated.
2287-
# The only exception to that rule is RisingWave, which doesn't support CREATE OR REPLACE, so upstream
2287+
# The only exception to that rule is RisingWave, which doesn't support CREATE OR REPLACE, so upstream
22882288
# models don't recreate their physical tables for the MVs to be invalidated.
2289-
# However, even for RW we still want to recreate MVs to avoid stale references
2289+
# However, even for RW we still want to recreate MVs to avoid stale references
22902290
is_materialized_view = self._is_materialized_view(model)
2291-
must_recreate_view = not self.adapter.HAS_VIEW_BINDING or is_materialized_view
2291+
must_recreate_view = not self.adapter.HAS_VIEW_BINDING or is_first_insert
22922292

22932293
if self.adapter.table_exists(table_name) and not must_recreate_view:
22942294
logger.info("Skipping creation of the view '%s'", table_name)

tests/core/engine_adapter/integration/test_integration.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3772,7 +3772,7 @@ def test_materialized_view_evaluation(ctx: TestContext, mocker: MockerFixture):
37723772
)
37733773
)
37743774
)
3775-
3775+
37763776
def _assert_mview_value(value: int):
37773777
df = adapter.fetchdf(f"SELECT * FROM {mview_name.sql(dialect=dialect)}")
37783778
assert df["col"][0] == value
@@ -3794,5 +3794,4 @@ def _assert_mview_value(value: int):
37943794

37953795
assert any("Replacing view" in call[0][0] for call in mock_logger.call_args_list)
37963796

3797-
3798-
_assert_mview_value(value=2)
3797+
_assert_mview_value(value=2)

0 commit comments

Comments
 (0)