Skip to content

Commit 94d9e45

Browse files
committed
cosmetic
1 parent 997f05d commit 94d9e45

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

sqlmesh/core/snapshot/evaluator.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -746,11 +746,15 @@ def _evaluate_snapshot(
746746
adapter.execute(model.render_pre_statements(**render_statements_kwargs))
747747

748748
if not target_table_exists or (model.is_seed and not snapshot.intervals):
749-
columns_to_types_provided = (
749+
# Only create the empty table if the columns were provided explicitly by the user
750+
should_create_empty_table = (
750751
model.kind.is_materialized
751752
and model.columns_to_types_
752753
and columns_to_types_all_known(model.columns_to_types_)
753-
) or (model.depends_on_self and model.annotated)
754+
)
755+
if not should_create_empty_table:
756+
# Or if the model is self-referential and its query is fully annotated with types
757+
should_create_empty_table = model.depends_on_self and model.annotated
754758
if self._can_clone(snapshot, deployability_index):
755759
self._clone_snapshot_in_dev(
756760
snapshot=snapshot,
@@ -763,7 +767,7 @@ def _evaluate_snapshot(
763767
)
764768
runtime_stage = RuntimeStage.EVALUATING
765769
target_table_exists = True
766-
elif columns_to_types_provided or model.is_seed or model.kind.is_scd_type_2:
770+
elif should_create_empty_table or model.is_seed or model.kind.is_scd_type_2:
767771
self._execute_create(
768772
snapshot=snapshot,
769773
table_name=target_table_name,

0 commit comments

Comments
 (0)