Skip to content

Fix: CLI output for restatement plans #4444

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 1 commit into from
May 20, 2025
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
16 changes: 10 additions & 6 deletions sqlmesh/core/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ def start_promotion_progress(
default_catalog: t.Optional[str],
) -> None:
"""Indicates that a new snapshot promotion progress has begun."""
if self.promotion_progress is None:
if snapshots and self.promotion_progress is None:
self.promotion_progress = make_progress_bar(
"Updating virtual layer ", self.console, justify="left"
)
Expand Down Expand Up @@ -1782,10 +1782,13 @@ def _prompt_categorize(
"""Get the user's change category for the directly modified models."""
plan = plan_builder.build()

self.show_environment_difference_summary(
plan.context_diff,
no_diff=no_diff,
)
if plan.restatements:
self._print("\n[bold]Restating models\n")
else:
self.show_environment_difference_summary(
plan.context_diff,
no_diff=no_diff,
)

if plan.context_diff.has_changes:
self.show_model_difference_summary(
Expand Down Expand Up @@ -3458,7 +3461,8 @@ def start_promotion_progress(
environment_naming_info: EnvironmentNamingInfo,
default_catalog: t.Optional[str],
) -> None:
self._write(f"Starting promotion for {len(snapshots)} snapshots")
if snapshots:
self._write(f"Starting promotion for {len(snapshots)} snapshots")

def update_promotion_progress(self, snapshot: SnapshotInfoLike, promoted: bool) -> None:
self._write(f"Promoting {snapshot.name}")
Expand Down
4 changes: 3 additions & 1 deletion sqlmesh/core/plan/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ def evaluate(
push_completion_status = self._push(plan, snapshots, deployability_index_for_creation)
if push_completion_status.is_nothing_to_do:
self.console.log_status_update(
"\n[green]SKIP: No physical layer updates to perform[/green]\n"
""
if plan.restatements
else "\n[green]SKIP: No physical layer updates to perform[/green]\n"
)
update_intervals_for_new_snapshots(plan.new_snapshots, self.state_sync)
self._restate(plan, snapshots_by_name)
Expand Down
11 changes: 7 additions & 4 deletions sqlmesh/integrations/github/cicd/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,13 @@ def get_plan_summary(self, plan: Plan) -> str:
try:
# Clear out any output that might exist from prior steps
self._console.clear_captured_outputs()
self._console.show_environment_difference_summary(
context_diff=plan.context_diff,
no_diff=False,
)
if plan.restatements:
self._console._print("\n**Restating models**\n")
else:
self._console.show_environment_difference_summary(
context_diff=plan.context_diff,
no_diff=False,
)
if plan.context_diff.has_changes:
self._console.show_model_difference_summary(
context_diff=plan.context_diff,
Expand Down
4 changes: 2 additions & 2 deletions tests/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,10 @@ def test_plan_restate_model(runner, tmp_path):
)
assert result.exit_code == 0
assert_duckdb_test(result)
assert "No changes to plan: project files match the `prod` environment" in result.output
assert "Restating models" in result.output
assert "sqlmesh_example.full_model [full refresh" in result.output
assert_model_batches_executed(result)
assert_virtual_layer_updated(result)
assert "Virtual layer updated" not in result.output


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