@@ -217,25 +217,15 @@ def show_model_difference_summary(
217
217
) -> None :
218
218
"""Displays a summary of differences for the given models."""
219
219
220
- @abc .abstractmethod
221
- def show_impacted_tables_diff (
222
- self ,
223
- table_diffs : t .List [TableDiff ],
224
- show_sample : bool = True ,
225
- skip_grain_check : bool = False ,
226
- temp_schema : t .Optional [str ] = None ,
227
- ) -> None :
228
- """Display the table diff between all mismatched tables."""
229
-
230
220
@abc .abstractmethod
231
221
def show_table_diff (
232
222
self ,
233
- table_diff : TableDiff ,
223
+ table_diffs : t . List [ TableDiff ] ,
234
224
show_sample : bool = True ,
235
225
skip_grain_check : bool = False ,
236
226
temp_schema : t .Optional [str ] = None ,
237
227
) -> None :
238
- """Display the table diff between two tables."""
228
+ """Display the table diff between two or multiple tables."""
239
229
240
230
@abc .abstractmethod
241
231
def show_table_diff_summary (self , table_diff : TableDiff ) -> None :
@@ -668,29 +658,21 @@ def loading_start(self, message: t.Optional[str] = None) -> uuid.UUID:
668
658
def loading_stop (self , id : uuid .UUID ) -> None :
669
659
pass
670
660
671
- def show_impacted_tables_diff (
672
- self ,
673
- table_diffs : t .List [TableDiff ],
674
- show_sample : bool = True ,
675
- skip_grain_check : bool = False ,
676
- temp_schema : t .Optional [str ] = None ,
677
- ) -> None :
678
- pass
679
-
680
661
def show_table_diff (
681
662
self ,
682
- table_diff : TableDiff ,
663
+ table_diffs : t . List [ TableDiff ] ,
683
664
show_sample : bool = True ,
684
665
skip_grain_check : bool = False ,
685
666
temp_schema : t .Optional [str ] = None ,
686
667
) -> None :
687
- self .show_table_diff_summary (table_diff )
688
- self .show_schema_diff (table_diff .schema_diff ())
689
- self .show_row_diff (
690
- table_diff .row_diff (temp_schema = temp_schema , skip_grain_check = skip_grain_check ),
691
- show_sample = show_sample ,
692
- skip_grain_check = skip_grain_check ,
693
- )
668
+ for table_diff in table_diffs :
669
+ self .show_table_diff_summary (table_diff )
670
+ self .show_schema_diff (table_diff .schema_diff ())
671
+ self .show_row_diff (
672
+ table_diff .row_diff (temp_schema = temp_schema , skip_grain_check = skip_grain_check ),
673
+ show_sample = show_sample ,
674
+ skip_grain_check = skip_grain_check ,
675
+ )
694
676
695
677
def show_table_diff_summary (self , table_diff : TableDiff ) -> None :
696
678
pass
@@ -2158,30 +2140,6 @@ def show_row_diff(
2158
2140
self .console .print (row_diff .t_sample .to_string (index = False ), end = "\n \n " )
2159
2141
2160
2142
def show_table_diff (
2161
- self ,
2162
- table_diff : TableDiff ,
2163
- show_sample : bool = True ,
2164
- skip_grain_check : bool = False ,
2165
- temp_schema : t .Optional [str ] = None ,
2166
- ) -> None :
2167
- """Display the table diff between two tables.
2168
-
2169
- Args:
2170
- table_diff: The TableDiff object containing schema and summary differences
2171
- show_sample: Show the sample dataframe in the console. Requires show=True.
2172
- skip_grain_check: Skip check for rows that contain null or duplicate grains.
2173
- temp_schema: The schema to use for temporary tables.
2174
- """
2175
-
2176
- self .show_table_diff_summary (table_diff )
2177
- self .show_schema_diff (table_diff .schema_diff ())
2178
- self .show_row_diff (
2179
- table_diff .row_diff (temp_schema = temp_schema , skip_grain_check = skip_grain_check ),
2180
- show_sample = show_sample ,
2181
- skip_grain_check = skip_grain_check ,
2182
- )
2183
-
2184
- def show_impacted_tables_diff (
2185
2143
self ,
2186
2144
table_diffs : t .List [TableDiff ],
2187
2145
show_sample : bool = True ,
@@ -2219,12 +2177,13 @@ def show_impacted_tables_diff(
2219
2177
f"[{ self .TABLE_DIFF_SOURCE_BLUE } ]{ m .source } [/{ self .TABLE_DIFF_SOURCE_BLUE } ] - [{ self .TABLE_DIFF_TARGET_GREEN } ]{ m .target } [/{ self .TABLE_DIFF_TARGET_GREEN } ]"
2220
2178
)
2221
2179
self ._print (m_tree )
2222
- for diff in mismatched_tables :
2223
- self .show_table_diff (
2224
- table_diff = diff ,
2180
+ for table_diff in mismatched_tables :
2181
+ self .show_table_diff_summary (table_diff )
2182
+ self .show_schema_diff (table_diff .schema_diff ())
2183
+ self .show_row_diff (
2184
+ table_diff .row_diff (temp_schema = temp_schema , skip_grain_check = skip_grain_check ),
2225
2185
show_sample = show_sample ,
2226
2186
skip_grain_check = skip_grain_check ,
2227
- temp_schema = temp_schema ,
2228
2187
)
2229
2188
2230
2189
def print_environments (self , environments_summary : t .Dict [str , int ]) -> None :
@@ -2814,6 +2773,53 @@ def show_model_difference_summary(
2814
2773
context_diff , modified_snapshots , environment_naming_info , default_catalog , no_diff
2815
2774
)
2816
2775
2776
+ def show_table_diff (
2777
+ self ,
2778
+ table_diffs : t .List [TableDiff ],
2779
+ show_sample : bool = True ,
2780
+ skip_grain_check : bool = False ,
2781
+ temp_schema : t .Optional [str ] = None ,
2782
+ ) -> None :
2783
+ """
2784
+ Display the table diff between all mismatched tables.
2785
+ """
2786
+ mismatched_tables = []
2787
+ fully_matched = []
2788
+ for table_diff in table_diffs :
2789
+ if (
2790
+ table_diff .row_diff (
2791
+ temp_schema = temp_schema , skip_grain_check = skip_grain_check
2792
+ ).full_match_pct
2793
+ == 100
2794
+ ):
2795
+ fully_matched .append (table_diff )
2796
+ else :
2797
+ mismatched_tables .append (table_diff )
2798
+
2799
+ if fully_matched :
2800
+ m_tree = Tree ("\n [b]Identical Tables" )
2801
+ for m in fully_matched :
2802
+ m_tree .add (
2803
+ f"[{ self .TABLE_DIFF_SOURCE_BLUE } ]{ m .source } [/{ self .TABLE_DIFF_SOURCE_BLUE } ] - [{ self .TABLE_DIFF_TARGET_GREEN } ]{ m .target } [/{ self .TABLE_DIFF_TARGET_GREEN } ]"
2804
+ )
2805
+ self ._print (m_tree )
2806
+
2807
+ if mismatched_tables :
2808
+ m_tree = Tree ("\n [b]Mismatched Tables" )
2809
+ for m in mismatched_tables :
2810
+ m_tree .add (
2811
+ f"[{ self .TABLE_DIFF_SOURCE_BLUE } ]{ m .source } [/{ self .TABLE_DIFF_SOURCE_BLUE } ] - [{ self .TABLE_DIFF_TARGET_GREEN } ]{ m .target } [/{ self .TABLE_DIFF_TARGET_GREEN } ]"
2812
+ )
2813
+ self ._print (m_tree )
2814
+ for table_diff in mismatched_tables :
2815
+ self .show_table_diff_summary (table_diff )
2816
+ self .show_schema_diff (table_diff .schema_diff ())
2817
+ self .show_row_diff (
2818
+ table_diff .row_diff (temp_schema = temp_schema , skip_grain_check = skip_grain_check ),
2819
+ show_sample = show_sample ,
2820
+ skip_grain_check = skip_grain_check ,
2821
+ )
2822
+
2817
2823
def _print_models_with_threshold (
2818
2824
self ,
2819
2825
environment_naming_info : EnvironmentNamingInfo ,
0 commit comments