Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions sqlmesh/core/snapshot/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
CustomKind,
)
from sqlmesh.core.model.kind import _Incremental
from sqlmesh.utils import CompletionStatus
from sqlmesh.utils import CompletionStatus, columns_to_types_all_known
from sqlmesh.core.schema_diff import (
has_drop_alteration,
TableAlterOperation,
Expand Down Expand Up @@ -747,6 +747,11 @@ def _evaluate_snapshot(
adapter.execute(model.render_pre_statements(**render_statements_kwargs))

if not target_table_exists or (model.is_seed and not snapshot.intervals):
columns_to_types_provided = (
model.kind.is_materialized
and model.columns_to_types_
and columns_to_types_all_known(model.columns_to_types_)
)
if self._can_clone(snapshot, deployability_index):
self._clone_snapshot_in_dev(
snapshot=snapshot,
Expand All @@ -759,7 +764,7 @@ def _evaluate_snapshot(
)
runtime_stage = RuntimeStage.EVALUATING
target_table_exists = True
elif model.annotated or model.is_seed or model.kind.is_scd_type_2:
elif columns_to_types_provided or model.is_seed or model.kind.is_scd_type_2:
self._execute_create(
snapshot=snapshot,
table_name=target_table_name,
Expand Down
2 changes: 1 addition & 1 deletion tests/core/test_snapshot_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ def test_evaluate_materialized_view(
)

# Ensure that the materialized view is recreated even if it exists
assert adapter_mock.create_view.assert_called
assert adapter_mock.create_view.call_count == 1


def test_evaluate_materialized_view_with_partitioned_by_cluster_by(
Expand Down