diff --git a/target_bigquery/core.py b/target_bigquery/core.py index 45bc6bf..081d533 100644 --- a/target_bigquery/core.py +++ b/target_bigquery/core.py @@ -515,7 +515,7 @@ def clean_up(self) -> None: tmp = f"{self.merge_target.name}__tmp" dedupe_query = ( f"SELECT * FROM {self.table.get_escaped_name()} " - f"QUALIFY ROW_NUMBER() OVER (PARTITION BY {', '.join(self.key_properties)} " + f"QUALIFY ROW_NUMBER() OVER (PARTITION BY {', '.join(f'`{p}`' for p in self.key_properties)} " f"ORDER BY COALESCE({', '.join(date_columns)}) DESC) = 1" ) ctas_tmp = f"CREATE OR REPLACE TEMP TABLE `{tmp}` AS {dedupe_query}"