Skip to content

Commit

Permalink
Merge pull request #2527 from moj-analytical-services/explicit-tf-col…
Browse files Browse the repository at this point in the history
…umns-select

Explicit tf columns select
  • Loading branch information
ADBond authored Nov 27, 2024
2 parents 2aa78da + d4a7daa commit 1fa511b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion scripts/postgres_docker/teardown.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# run from root

# remove -v (removing volume) if you want to keep data
docker-compose -f scripts/postgres/docker-compose.yaml down -v
docker-compose -f scripts/postgres_docker/docker-compose.yaml down -v
10 changes: 8 additions & 2 deletions splink/internals/term_frequencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ def _join_tf_to_df_concat_sql(linker: Linker) -> str:
tbl = colname_to_tf_tablename(col)
select_cols.append(f"{tbl}.{col.tf_name}")

select_cols.insert(0, "__splink__df_concat.*")
column_names_in_df_concat = linker._concat_table_column_names

aliased_concat_column_names = [
f"__splink__df_concat.{col} AS {col}" for col in column_names_in_df_concat
]

select_cols = aliased_concat_column_names + select_cols
select_cols_str = ", ".join(select_cols)

templ = "left join {tbl} on __splink__df_concat.{col} = {tbl}.{col}"
Expand All @@ -72,7 +78,7 @@ def _join_tf_to_df_concat_sql(linker: Linker) -> str:
left_joins_str = " ".join(left_joins)

sql = f"""
select {select_cols_str }
select {select_cols_str}
from __splink__df_concat
{left_joins_str}
"""
Expand Down

0 comments on commit 1fa511b

Please sign in to comment.