Skip to content

Commit f91749f

Browse files
clean up logic for non existing models per env; revise doc
1 parent fad605a commit f91749f

3 files changed

Lines changed: 3 additions & 31 deletions

File tree

docs/guides/tablediff.md

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

136136
When diffing multiple models, SQLMesh will:
137137

138-
1. Show which models exist only in the source environment
139-
2. Show which models exist only in the target environment
140-
3. Show which models exist in both environments but have no differences
141-
4. Compare the models that have differences and display them
138+
1. Show the models returnes by the selector that exist in both environments, but have no differences
139+
2. Compare the models that have differences and display the table diff of each model
142140

143141
The `--select-model` option supports a powerful selection syntax that lets you choose models using patterns, tags, dependencies and git status. For complete details, see the [model selection guide](./model_selection.md).
144142

sqlmesh/core/console.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,6 @@ def stop_table_diff_progress(self, success: bool) -> None:
250250
@abc.abstractmethod
251251
def show_table_diff_details(
252252
self,
253-
models_in_source: t.List[str],
254-
models_in_target: t.List[str],
255253
models_no_diff: t.List[str],
256254
models_to_diff: t.List[str],
257255
) -> None:
@@ -719,8 +717,6 @@ def stop_table_diff_progress(self, success: bool) -> None:
719717

720718
def show_table_diff_details(
721719
self,
722-
models_in_source: t.List[str],
723-
models_in_target: t.List[str],
724720
models_no_diff: t.List[str],
725721
models_to_diff: t.List[str],
726722
) -> None:
@@ -1987,25 +1983,11 @@ def loading_stop(self, id: uuid.UUID) -> None:
19871983

19881984
def show_table_diff_details(
19891985
self,
1990-
models_in_source: t.List[str],
1991-
models_in_target: t.List[str],
19921986
models_no_diff: t.List[str],
19931987
models_to_diff: t.List[str],
19941988
) -> None:
19951989
"""Display information about which tables are identical and which are diffed"""
19961990

1997-
if models_in_source:
1998-
m_tree = Tree("\n[b]Models only in source environment:")
1999-
for m in models_in_source:
2000-
m_tree.add(f"[{self.TABLE_DIFF_SOURCE_BLUE}]{m}[/{self.TABLE_DIFF_SOURCE_BLUE}]")
2001-
self._print(m_tree)
2002-
2003-
if models_in_target:
2004-
m_tree = Tree("\n[b]Models only in target environment:")
2005-
for m in models_in_target:
2006-
m_tree.add(f"[{self.TABLE_DIFF_TARGET_GREEN}]{m}[/{self.TABLE_DIFF_TARGET_GREEN}]")
2007-
self._print(m_tree)
2008-
20091991
if models_no_diff:
20101992
m_tree = Tree("\n[b]Models without changes:")
20111993
for m in models_no_diff:

sqlmesh/core/context.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,8 +1625,6 @@ 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_in_source: t.List[str] = []
1629-
models_in_target: t.List[str] = []
16301628
models_no_diff: t.List[str] = []
16311629
models_without_grain: t.List[Model] = []
16321630
source_snapshots_to_name = {
@@ -1642,11 +1640,7 @@ def table_diff(
16421640
source_snapshot = source_snapshots_to_name.get(model.fqn)
16431641
target_snapshot = target_snapshots_to_name.get(model.fqn)
16441642

1645-
if source_snapshot is None and target_snapshot:
1646-
models_in_source.append(model_fqn)
1647-
elif target_snapshot is None and source_snapshot:
1648-
models_in_target.append(model_fqn)
1649-
elif target_snapshot and source_snapshot:
1643+
if target_snapshot and source_snapshot:
16501644
if (
16511645
source_snapshot.fingerprint.data_hash
16521646
!= target_snapshot.fingerprint.data_hash
@@ -1667,8 +1661,6 @@ def table_diff(
16671661
models_no_diff.append(model_fqn)
16681662

16691663
self.console.show_table_diff_details(
1670-
models_in_source,
1671-
models_in_target,
16721664
models_no_diff,
16731665
[model[0].name for model in models_to_diff],
16741666
)

0 commit comments

Comments
 (0)