Skip to content

Fix: Include the preview disclaimer in the backfill section of the plan explanation when appropriate #4845

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
21 changes: 13 additions & 8 deletions sqlmesh/core/plan/explainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ def visit_backfill_stage(self, stage: stages.BackfillStage) -> Tree:
for snapshot, intervals in stage.snapshot_to_intervals.items():
display_name = self._display_name(snapshot)
if snapshot.is_model:
table_name = snapshot.table_name(stage.deployability_index.is_deployable(snapshot))
is_deployable = stage.deployability_index.is_deployable(snapshot)
table_name = snapshot.table_name(is_deployable)
model_tree = Tree(f"{display_name} -> {table_name}")

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

backfill_tree = Tree("Fully refresh table")
if snapshot.is_incremental:
current_intervals = (
snapshot.intervals
if stage.deployability_index.is_deployable(snapshot)
else snapshot.dev_intervals
)
# If there are no intervals, the table will be fully refreshed
if current_intervals:
formatted_range = SnapshotIntervals(
snapshot_id=snapshot.snapshot_id, intervals=intervals
).format_intervals(snapshot.node.interval_unit)
model_tree.add(
backfill_tree = Tree(
f"Incrementally insert records within the range [{formatted_range}]"
)
else:
# If there are no intervals, the table will be fully refreshed
model_tree.add("Fully refresh table")
elif snapshot.is_view:
model_tree.add("Recreate view")
else:
model_tree.add("Fully refresh table")
backfill_tree = Tree("Recreate view")

if not is_deployable:
backfill_tree.add(
"[orange1]preview[/orange1]: data will NOT be reused in production"
)

model_tree.add(backfill_tree)

if snapshot.model.post_statements:
model_tree.add("Run post-statements")
Expand Down