Skip to content

Commit 1cb5220

Browse files
fix: Use less common name as match suffix (#13)
1 parent fb576c8 commit 1cb5220

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

sqlcompyre/analysis/table_comparison.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,13 @@ def row_matches(self) -> RowMatches:
252252
@cached_property
253253
def column_matches(self) -> ColumnMatches:
254254
"""A comparison between the column values of the two tables."""
255+
MATCH_SUFFIX = "_zzz_match"
255256
inner_join = self._inner_join()
256257

257258
# Query for testing equality of column values in matching rows
258259
cases = [
259260
sa.case((self._is_equal(left_column, right_column), 1.0), else_=0.0).label(
260-
f"{left_column}_match"
261+
f"{left_column}_{MATCH_SUFFIX}"
261262
)
262263
for left_column, right_column in self.column_name_mapping.items()
263264
if left_column not in self.join_columns
@@ -268,10 +269,10 @@ def column_matches(self) -> ColumnMatches:
268269
case_stmt = select(*cases).select_from(inner_join).subquery()
269270

270271
# Compute fraction of matching values
271-
cols_to_avg = [col for col in case_stmt.c if "_match" in col.name]
272+
cols_to_avg = [col for col in case_stmt.c if f"_{MATCH_SUFFIX}" in col.name]
272273
avgs = select(
273274
*[
274-
sa.func.avg(col).label(f"{col.name.replace('_match', '')}")
275+
sa.func.avg(col).label(f"{col.name.replace(f'_{MATCH_SUFFIX}', '')}")
275276
for col in cols_to_avg
276277
]
277278
)

0 commit comments

Comments
 (0)