From 9913bebe4bf2bb5e124d4dd6818b28a090f7538b Mon Sep 17 00:00:00 2001 From: Wim Date: Fri, 22 Dec 2023 13:03:00 +0000 Subject: [PATCH 1/2] split quoting behaviour for Snowflake between column identifiers and other identifiers --- macros/utils.sql | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/macros/utils.sql b/macros/utils.sql index 9629273..43dde18 100644 --- a/macros/utils.sql +++ b/macros/utils.sql @@ -25,7 +25,7 @@ {% endmacro %} {% macro quote_and_join_columns(columns) %} - {% set columns = dbt_unit_testing.map(columns, dbt_unit_testing.quote_identifier) | join(",") %} + {% set columns = dbt_unit_testing.map(columns, dbt_unit_testing.quote_column_identifier) | join(",") %} {{ return (columns) }} {% endmacro %} @@ -133,6 +133,22 @@ {{ return (dbt_unit_testing.merge_jsons([unit_tests_config] + configs)) }} {% endmacro %} +{% macro quote_column_identifier(identifier) %} + {{ return(adapter.dispatch('quote_identifier','dbt_unit_testing')(identifier)) }} +{% endmacro %} + +{% macro default__quote_column_identifier(identifier) -%} + {{ return(quote_identifier(identifier)) }} +{%- endmacro %} + +{% macro snowflake__quote_column_identifier(identifier) %} + {% if identifier.startswith('"') %} + {{ return(identifier) }} + {% else %} + {{ return('"' ~ identifier ~ '"') }} + {% endif %} +{% endmacro %} + {% macro quote_identifier(identifier) %} {{ return(adapter.dispatch('quote_identifier','dbt_unit_testing')(identifier)) }} {% endmacro %} From 5dd1157e4f2cd6e10a18b1da1bce8f52a5620745 Mon Sep 17 00:00:00 2001 From: Wim Date: Fri, 22 Dec 2023 13:43:26 +0000 Subject: [PATCH 2/2] adding missing change to quote_column_identifier macro --- macros/utils.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macros/utils.sql b/macros/utils.sql index 43dde18..bd19635 100644 --- a/macros/utils.sql +++ b/macros/utils.sql @@ -134,7 +134,7 @@ {% endmacro %} {% macro quote_column_identifier(identifier) %} - {{ return(adapter.dispatch('quote_identifier','dbt_unit_testing')(identifier)) }} + {{ return(adapter.dispatch('quote_column_identifier','dbt_unit_testing')(identifier)) }} {% endmacro %} {% macro default__quote_column_identifier(identifier) -%}