From a5499cc5afd1aca59edc195d5131e368521fa16e Mon Sep 17 00:00:00 2001 From: Marius Merkle Date: Wed, 6 Nov 2024 14:04:14 +0100 Subject: [PATCH 1/2] fix: Use less common name as match suffix --- sqlcompyre/analysis/table_comparison.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sqlcompyre/analysis/table_comparison.py b/sqlcompyre/analysis/table_comparison.py index 181b866..5abcf47 100644 --- a/sqlcompyre/analysis/table_comparison.py +++ b/sqlcompyre/analysis/table_comparison.py @@ -252,12 +252,13 @@ def row_matches(self) -> RowMatches: @cached_property def column_matches(self) -> ColumnMatches: """A comparison between the column values of the two tables.""" + MATCH_SUFFIX = "_match" inner_join = self._inner_join() # Query for testing equality of column values in matching rows cases = [ sa.case((self._is_equal(left_column, right_column), 1.0), else_=0.0).label( - f"{left_column}_match" + f"{left_column}_{MATCH_SUFFIX}" ) for left_column, right_column in self.column_name_mapping.items() if left_column not in self.join_columns @@ -268,10 +269,10 @@ def column_matches(self) -> ColumnMatches: case_stmt = select(*cases).select_from(inner_join).subquery() # Compute fraction of matching values - cols_to_avg = [col for col in case_stmt.c if "_match" in col.name] + cols_to_avg = [col for col in case_stmt.c if f"_{MATCH_SUFFIX}" in col.name] avgs = select( *[ - sa.func.avg(col).label(f"{col.name.replace('_match', '')}") + sa.func.avg(col).label(f"{col.name.replace(f'_{MATCH_SUFFIX}', '')}") for col in cols_to_avg ] ) From ae7e1def8773af5ec9c0c113688aea5621bff634 Mon Sep 17 00:00:00 2001 From: Marius Merkle Date: Wed, 6 Nov 2024 15:12:47 +0100 Subject: [PATCH 2/2] make the name even more odd --- sqlcompyre/analysis/table_comparison.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlcompyre/analysis/table_comparison.py b/sqlcompyre/analysis/table_comparison.py index 5abcf47..1555224 100644 --- a/sqlcompyre/analysis/table_comparison.py +++ b/sqlcompyre/analysis/table_comparison.py @@ -252,7 +252,7 @@ def row_matches(self) -> RowMatches: @cached_property def column_matches(self) -> ColumnMatches: """A comparison between the column values of the two tables.""" - MATCH_SUFFIX = "_match" + MATCH_SUFFIX = "_zzz_match" inner_join = self._inner_join() # Query for testing equality of column values in matching rows