From 43a9570e14fd55ab933b9f2e591ee4d103bd52c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez-Mondrag=C3=B3n?= Date: Thu, 25 Jul 2024 10:17:22 -0400 Subject: [PATCH] fix: Ensure table name is quoted in merge statement --- target_snowflake/connector.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target_snowflake/connector.py b/target_snowflake/connector.py index 78a971a..561c24a 100644 --- a/target_snowflake/connector.py +++ b/target_snowflake/connector.py @@ -5,6 +5,7 @@ import snowflake.sqlalchemy.custom_types as sct import sqlalchemy +from sqlalchemy.sql import quoted_name from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import serialization from singer_sdk import typing as th @@ -388,7 +389,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} "