Skip to content

Commit 05795b3

Browse files
committed
Fix CLI output for restatements plans
1 parent e24c9da commit 05795b3

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

sqlmesh/core/console.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ def start_promotion_progress(
11611161
default_catalog: t.Optional[str],
11621162
) -> None:
11631163
"""Indicates that a new snapshot promotion progress has begun."""
1164-
if self.promotion_progress is None:
1164+
if snapshots and self.promotion_progress is None:
11651165
self.promotion_progress = make_progress_bar(
11661166
"Updating virtual layer ", self.console, justify="left"
11671167
)
@@ -1782,10 +1782,13 @@ def _prompt_categorize(
17821782
"""Get the user's change category for the directly modified models."""
17831783
plan = plan_builder.build()
17841784

1785-
self.show_environment_difference_summary(
1786-
plan.context_diff,
1787-
no_diff=no_diff,
1788-
)
1785+
if plan.restatements:
1786+
self._print("\n[bold]Restating models\n")
1787+
else:
1788+
self.show_environment_difference_summary(
1789+
plan.context_diff,
1790+
no_diff=no_diff,
1791+
)
17891792

17901793
if plan.context_diff.has_changes:
17911794
self.show_model_difference_summary(
@@ -3458,7 +3461,8 @@ def start_promotion_progress(
34583461
environment_naming_info: EnvironmentNamingInfo,
34593462
default_catalog: t.Optional[str],
34603463
) -> None:
3461-
self._write(f"Starting promotion for {len(snapshots)} snapshots")
3464+
if snapshots:
3465+
self._write(f"Starting promotion for {len(snapshots)} snapshots")
34623466

34633467
def update_promotion_progress(self, snapshot: SnapshotInfoLike, promoted: bool) -> None:
34643468
self._write(f"Promoting {snapshot.name}")

sqlmesh/core/plan/evaluator.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@ def evaluate(
133133
push_completion_status = self._push(plan, snapshots, deployability_index_for_creation)
134134
if push_completion_status.is_nothing_to_do:
135135
self.console.log_status_update(
136-
"\n[green]SKIP: No physical layer updates to perform[/green]\n"
136+
""
137+
if plan.restatements
138+
else "\n[green]SKIP: No physical layer updates to perform[/green]\n"
137139
)
138140
update_intervals_for_new_snapshots(plan.new_snapshots, self.state_sync)
139141
self._restate(plan, snapshots_by_name)

sqlmesh/integrations/github/cicd/controller.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,10 +457,13 @@ def get_plan_summary(self, plan: Plan) -> str:
457457
try:
458458
# Clear out any output that might exist from prior steps
459459
self._console.clear_captured_outputs()
460-
self._console.show_environment_difference_summary(
461-
context_diff=plan.context_diff,
462-
no_diff=False,
463-
)
460+
if plan.restatements:
461+
self._console._print("\n**Restating models**\n")
462+
else:
463+
self._console.show_environment_difference_summary(
464+
context_diff=plan.context_diff,
465+
no_diff=False,
466+
)
464467
if plan.context_diff.has_changes:
465468
self._console.show_model_difference_summary(
466469
context_diff=plan.context_diff,

tests/cli/test_cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,10 @@ def test_plan_restate_model(runner, tmp_path):
248248
)
249249
assert result.exit_code == 0
250250
assert_duckdb_test(result)
251-
assert "No changes to plan: project files match the `prod` environment" in result.output
251+
assert "Restating models" in result.output
252252
assert "sqlmesh_example.full_model [full refresh" in result.output
253253
assert_model_batches_executed(result)
254-
assert_virtual_layer_updated(result)
254+
assert "Virtual layer updated" not in result.output
255255

256256

257257
@pytest.mark.parametrize("flag", ["--skip-backfill", "--dry-run"])

0 commit comments

Comments
 (0)