Skip to content

Commit

Permalink
add where filter condition to output
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinL committed May 16, 2024
1 parent 4910795 commit 4afc9e2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion splink/blocking.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,9 @@ def materialise_exploded_id_tables(
return exploding_blocking_rules


def _sql_gen_where_condition(link_type, unique_id_cols):
def _sql_gen_where_condition(
link_type: backend_link_type_options, unique_id_cols: List[InputColumn]
) -> str:
id_expr_l = _composite_unique_id_from_nodes_sql(unique_id_cols, "l")
id_expr_r = _composite_unique_id_from_nodes_sql(unique_id_cols, "r")

Expand Down
17 changes: 17 additions & 0 deletions splink/internals/blocking_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,12 +494,28 @@ def add_l_r(sql, table_name):
if filter_conditions == "TRUE":
filter_conditions = ""

source_dataset_input_column, unique_id_input_column = _process_unique_id_columns(
unique_id_column_name,
source_dataset_column_name,
splink_df_dict,
link_type,
db_api.sql_dialect.name,
)

if source_dataset_input_column:
uid_for_where = [source_dataset_input_column, unique_id_input_column]
else:
uid_for_where = [unique_id_input_column]

join_condition_sql = _sql_gen_where_condition(link_type, uid_for_where)

if not compute_post_filter_count:
return {
"number_of_comparisons_generated_pre_filter_conditions": pre_filter_total,
"number_of_comparisons_to_be_scored_post_filter_conditions": "not computed",
"filter_conditions_identified": filter_conditions,
"equi_join_conditions_identified": equi_join_conditions_joined,
"inner_join_condition_identified": join_condition_sql,
}

if pre_filter_total < max_rows_limit:
Expand Down Expand Up @@ -536,6 +552,7 @@ def add_l_r(sql, table_name):
"number_of_comparisons_to_be_scored_post_filter_conditions": post_filter_total,
"filter_conditions_identified": filter_conditions,
"equi_join_conditions_identified": equi_join_conditions_joined,
"inner_join_condition_identified": join_condition_sql,
}


Expand Down

0 comments on commit 4afc9e2

Please sign in to comment.