@@ -2150,42 +2150,44 @@ def show_table_diff(
21502150 """
21512151 Display the table diff between all mismatched tables.
21522152 """
2153- mismatched_tables = []
2154- fully_matched = []
2155- for table_diff in table_diffs :
2156- if (
2157- table_diff .row_diff (
2158- temp_schema = temp_schema , skip_grain_check = skip_grain_check
2159- ).full_match_pct
2160- == 100
2161- ):
2162- fully_matched .append (table_diff )
2163- else :
2164- mismatched_tables .append (table_diff )
2153+ if len (table_diffs ) > 1 :
2154+ mismatched_tables = []
2155+ fully_matched = []
2156+ for table_diff in table_diffs :
2157+ if (
2158+ table_diff .row_diff (
2159+ temp_schema = temp_schema , skip_grain_check = skip_grain_check
2160+ ).full_match_pct
2161+ == 100
2162+ ):
2163+ fully_matched .append (table_diff )
2164+ else :
2165+ mismatched_tables .append (table_diff )
2166+ table_diffs = mismatched_tables if mismatched_tables else []
2167+ if fully_matched :
2168+ m_tree = Tree ("\n [b]Identical Tables" )
2169+ for m in fully_matched :
2170+ m_tree .add (
2171+ 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 } ]"
2172+ )
2173+ self ._print (m_tree )
21652174
2166- if fully_matched :
2167- m_tree = Tree ("\n [b]Identical Tables" )
2168- for m in fully_matched :
2169- m_tree .add (
2170- 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 } ]"
2171- )
2172- self ._print (m_tree )
2175+ if mismatched_tables :
2176+ m_tree = Tree ("\n [b]Mismatched Tables" )
2177+ for m in mismatched_tables :
2178+ m_tree .add (
2179+ 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 } ]"
2180+ )
2181+ self ._print (m_tree )
21732182
2174- if mismatched_tables :
2175- m_tree = Tree ("\n [b]Mismatched Tables" )
2176- for m in mismatched_tables :
2177- m_tree .add (
2178- 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 } ]"
2179- )
2180- self ._print (m_tree )
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 ),
2186- show_sample = show_sample ,
2187- skip_grain_check = skip_grain_check ,
2188- )
2183+ for table_diff in table_diffs :
2184+ self .show_table_diff_summary (table_diff )
2185+ self .show_schema_diff (table_diff .schema_diff ())
2186+ self .show_row_diff (
2187+ table_diff .row_diff (temp_schema = temp_schema , skip_grain_check = skip_grain_check ),
2188+ show_sample = show_sample ,
2189+ skip_grain_check = skip_grain_check ,
2190+ )
21892191
21902192 def print_environments (self , environments_summary : t .List [EnvironmentSummary ]) -> None :
21912193 """Prints all environment names along with expiry datetime."""
@@ -2776,53 +2778,6 @@ def show_model_difference_summary(
27762778 context_diff , modified_snapshots , environment_naming_info , default_catalog , no_diff
27772779 )
27782780
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-
28262781 def _print_models_with_threshold (
28272782 self ,
28282783 environment_naming_info : EnvironmentNamingInfo ,
0 commit comments