diff --git a/target_snowflake/connector.py b/target_snowflake/connector.py index 78a971a..1bdd4d9 100644 --- a/target_snowflake/connector.py +++ b/target_snowflake/connector.py @@ -12,7 +12,7 @@ from snowflake.sqlalchemy import URL from snowflake.sqlalchemy.base import SnowflakeIdentifierPreparer from snowflake.sqlalchemy.snowdialect import SnowflakeDialect -from sqlalchemy.sql import text +from sqlalchemy.sql import quoted_name, text from target_snowflake.snowflake_types import NUMBER, TIMESTAMP_NTZ, VARIANT @@ -388,7 +388,7 @@ def _get_merge_from_stage_statement( # noqa: ANN202 dedup = f"QUALIFY ROW_NUMBER() OVER (PARTITION BY {dedup_cols} ORDER BY SEQ8() DESC) = 1" return ( text( - f"merge into {full_table_name} d using " # noqa: ISC003 + f"merge into {quoted_name(full_table_name, quote=True)} d using " # noqa: ISC003 + f"(select {json_casting_selects} from '@~/target-snowflake/{sync_id}'" # noqa: S608 + f"(file_format => {file_format}) {dedup}) s " + f"on {join_expr} "