@@ -217,25 +217,15 @@ def show_model_difference_summary(
217217 ) -> None :
218218 """Displays a summary of differences for the given models."""
219219
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-
230220 @abc .abstractmethod
231221 def show_table_diff (
232222 self ,
233- table_diff : TableDiff ,
223+ table_diffs : t . List [ TableDiff ] ,
234224 show_sample : bool = True ,
235225 skip_grain_check : bool = False ,
236226 temp_schema : t .Optional [str ] = None ,
237227 ) -> None :
238- """Display the table diff between two tables."""
228+ """Display the table diff between two or multiple tables."""
239229
240230 @abc .abstractmethod
241231 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:
668658 def loading_stop (self , id : uuid .UUID ) -> None :
669659 pass
670660
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-
680661 def show_table_diff (
681662 self ,
682- table_diff : TableDiff ,
663+ table_diffs : t . List [ TableDiff ] ,
683664 show_sample : bool = True ,
684665 skip_grain_check : bool = False ,
685666 temp_schema : t .Optional [str ] = None ,
686667 ) -> 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+ )
694676
695677 def show_table_diff_summary (self , table_diff : TableDiff ) -> None :
696678 pass
@@ -2159,30 +2141,6 @@ def show_row_diff(
21592141
21602142
21612143 def show_table_diff (
2162- self ,
2163- table_diff : TableDiff ,
2164- show_sample : bool = True ,
2165- skip_grain_check : bool = False ,
2166- temp_schema : t .Optional [str ] = None ,
2167- ) -> None :
2168- """Display the table diff between two tables.
2169-
2170- Args:
2171- table_diff: The TableDiff object containing schema and summary differences
2172- show_sample: Show the sample dataframe in the console. Requires show=True.
2173- skip_grain_check: Skip check for rows that contain null or duplicate grains.
2174- temp_schema: The schema to use for temporary tables.
2175- """
2176-
2177- self .show_table_diff_summary (table_diff )
2178- self .show_schema_diff (table_diff .schema_diff ())
2179- self .show_row_diff (
2180- table_diff .row_diff (temp_schema = temp_schema , skip_grain_check = skip_grain_check ),
2181- show_sample = show_sample ,
2182- skip_grain_check = skip_grain_check ,
2183- )
2184-
2185- def show_impacted_tables_diff (
21862144 self ,
21872145 table_diffs : t .List [TableDiff ],
21882146 show_sample : bool = True ,
@@ -2220,12 +2178,13 @@ def show_impacted_tables_diff(
22202178 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 } ]"
22212179 )
22222180 self ._print (m_tree )
2223- for diff in mismatched_tables :
2224- self .show_table_diff (
2225- table_diff = diff ,
2181+ for table_diff in mismatched_tables :
2182+ self .show_table_diff_summary (table_diff )
2183+ self .show_schema_diff (table_diff .schema_diff ())
2184+ self .show_row_diff (
2185+ table_diff .row_diff (temp_schema = temp_schema , skip_grain_check = skip_grain_check ),
22262186 show_sample = show_sample ,
22272187 skip_grain_check = skip_grain_check ,
2228- temp_schema = temp_schema ,
22292188 )
22302189
22312190 def print_environments (self , environments_summary : t .List [EnvironmentSummary ]) -> None :
@@ -2817,6 +2776,53 @@ def show_model_difference_summary(
28172776 context_diff , modified_snapshots , environment_naming_info , default_catalog , no_diff
28182777 )
28192778
2779+ def show_table_diff (
2780+ self ,
2781+ table_diffs : t .List [TableDiff ],
2782+ show_sample : bool = True ,
2783+ skip_grain_check : bool = False ,
2784+ temp_schema : t .Optional [str ] = None ,
2785+ ) -> None :
2786+ """
2787+ Display the table diff between all mismatched tables.
2788+ """
2789+ mismatched_tables = []
2790+ fully_matched = []
2791+ for table_diff in table_diffs :
2792+ if (
2793+ table_diff .row_diff (
2794+ temp_schema = temp_schema , skip_grain_check = skip_grain_check
2795+ ).full_match_pct
2796+ == 100
2797+ ):
2798+ fully_matched .append (table_diff )
2799+ else :
2800+ mismatched_tables .append (table_diff )
2801+
2802+ if fully_matched :
2803+ m_tree = Tree ("\n [b]Identical Tables" )
2804+ for m in fully_matched :
2805+ m_tree .add (
2806+ 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 } ]"
2807+ )
2808+ self ._print (m_tree )
2809+
2810+ if mismatched_tables :
2811+ m_tree = Tree ("\n [b]Mismatched Tables" )
2812+ for m in mismatched_tables :
2813+ m_tree .add (
2814+ 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 } ]"
2815+ )
2816+ self ._print (m_tree )
2817+ for table_diff in mismatched_tables :
2818+ self .show_table_diff_summary (table_diff )
2819+ self .show_schema_diff (table_diff .schema_diff ())
2820+ self .show_row_diff (
2821+ table_diff .row_diff (temp_schema = temp_schema , skip_grain_check = skip_grain_check ),
2822+ show_sample = show_sample ,
2823+ skip_grain_check = skip_grain_check ,
2824+ )
2825+
28202826 def _print_models_with_threshold (
28212827 self ,
28222828 environment_naming_info : EnvironmentNamingInfo ,
0 commit comments