Skip to content

Commit eb61d61

Browse files
committed
Fix: Include the preview disclaimer in the backfill section of the plan explanation when appropriate
1 parent e07c5fe commit eb61d61

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

sqlmesh/core/plan/explainer.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ def visit_backfill_stage(self, stage: stages.BackfillStage) -> Tree:
161161
for snapshot, intervals in stage.snapshot_to_intervals.items():
162162
display_name = self._display_name(snapshot)
163163
if snapshot.is_model:
164-
table_name = snapshot.table_name(stage.deployability_index.is_deployable(snapshot))
164+
is_deployable = stage.deployability_index.is_deployable(snapshot)
165+
table_name = snapshot.table_name(is_deployable)
165166
model_tree = Tree(f"{display_name} -> {table_name}")
166167

167168
for signal_name, _ in snapshot.model.signals:
@@ -170,26 +171,30 @@ def visit_backfill_stage(self, stage: stages.BackfillStage) -> Tree:
170171
if snapshot.model.pre_statements:
171172
model_tree.add("Run pre-statements")
172173

174+
backfill_tree = Tree("Fully refresh table")
173175
if snapshot.is_incremental:
174176
current_intervals = (
175177
snapshot.intervals
176178
if stage.deployability_index.is_deployable(snapshot)
177179
else snapshot.dev_intervals
178180
)
181+
# If there are no intervals, the table will be fully refreshed
179182
if current_intervals:
180183
formatted_range = SnapshotIntervals(
181184
snapshot_id=snapshot.snapshot_id, intervals=intervals
182185
).format_intervals(snapshot.node.interval_unit)
183-
model_tree.add(
186+
backfill_tree = Tree(
184187
f"Incrementally insert records within the range [{formatted_range}]"
185188
)
186-
else:
187-
# If there are no intervals, the table will be fully refreshed
188-
model_tree.add("Fully refresh table")
189189
elif snapshot.is_view:
190-
model_tree.add("Recreate view")
191-
else:
192-
model_tree.add("Fully refresh table")
190+
backfill_tree = Tree("Recreate view")
191+
192+
if not is_deployable:
193+
backfill_tree.add(
194+
"[orange1]preview[/orange1]: data will NOT be reused in production"
195+
)
196+
197+
model_tree.add(backfill_tree)
193198

194199
if snapshot.model.post_statements:
195200
model_tree.add("Run post-statements")

0 commit comments

Comments
 (0)