Skip to content

Commit 283606f

Browse files
Revert "remove no differences from the cli output"
This reverts commit 447c4e4.
1 parent 4f536b2 commit 283606f

3 files changed

Lines changed: 21 additions & 8 deletions

File tree

docs/guides/tablediff.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ sqlmesh table_diff prod:dev --select-model "sqlmesh_example.*"
135135

136136
When diffing multiple models, SQLMesh will:
137137

138-
1. Show the models returned by the selector that exist in both environments and have differences
139-
2. Compare the models and display the data diff of each model
138+
1. Show the models returned by the selector that exist in both environments, but have no differences
139+
2. Compare the models that have differences and display the data diff of each model
140140

141141
> Note: Models will only be data diffed if there's a breaking change that impacts them.
142142

sqlmesh/core/console.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,10 @@ def stop_table_diff_progress(self, success: bool) -> None:
250250
@abc.abstractmethod
251251
def show_table_diff_details(
252252
self,
253+
models_no_diff: t.List[str],
253254
models_to_diff: t.List[str],
254255
) -> None:
255-
"""Display information about which tables are going to be diffed"""
256+
"""Display information about which tables are identical and which are diffed"""
256257

257258
@abc.abstractmethod
258259
def show_table_diff_summary(self, table_diff: TableDiff) -> None:
@@ -716,6 +717,7 @@ def stop_table_diff_progress(self, success: bool) -> None:
716717

717718
def show_table_diff_details(
718719
self,
720+
models_no_diff: t.List[str],
719721
models_to_diff: t.List[str],
720722
) -> None:
721723
pass
@@ -1981,9 +1983,16 @@ def loading_stop(self, id: uuid.UUID) -> None:
19811983

19821984
def show_table_diff_details(
19831985
self,
1986+
models_no_diff: t.List[str],
19841987
models_to_diff: t.List[str],
19851988
) -> None:
1986-
"""Display information about which tables are going to be diffed"""
1989+
"""Display information about which tables are identical and which are diffed"""
1990+
1991+
if models_no_diff:
1992+
m_tree = Tree("\n[b]Models without changes:")
1993+
for m in models_no_diff:
1994+
m_tree.add(f"[{self.TABLE_DIFF_SOURCE_BLUE}]{m}[/{self.TABLE_DIFF_SOURCE_BLUE}]")
1995+
self._print(m_tree)
19871996

19881997
if models_to_diff:
19891998
m_tree = Tree("\n[b]Models to compare:")

sqlmesh/core/context.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,6 +1625,7 @@ def table_diff(
16251625
models_to_diff: t.List[
16261626
t.Tuple[Model, EngineAdapter, str, str, t.Optional[t.List[str] | exp.Condition]]
16271627
] = []
1628+
models_no_diff: t.List[str] = []
16281629
models_without_grain: t.List[Model] = []
16291630
source_snapshots_to_name = {
16301631
snapshot.name: snapshot for snapshot in source_env.snapshots
@@ -1656,12 +1657,15 @@ def table_diff(
16561657
models_to_diff.append((model, adapter, source, target, model_on))
16571658
if not model_on:
16581659
models_without_grain.append(model)
1660+
else:
1661+
models_no_diff.append(model_fqn)
16591662

1660-
if models_to_diff:
1661-
self.console.show_table_diff_details(
1662-
[model[0].name for model in models_to_diff],
1663-
)
1663+
self.console.show_table_diff_details(
1664+
models_no_diff,
1665+
[model[0].name for model in models_to_diff],
1666+
)
16641667

1668+
if models_to_diff:
16651669
if models_without_grain:
16661670
model_names = "\n".join(
16671671
f"─ {model.name} \n at '{model._path}'" for model in models_without_grain

0 commit comments

Comments
 (0)