From 81a12af16be67226aa49c52e7e9a816203327a5f Mon Sep 17 00:00:00 2001 From: Joshua Kravitz Date: Mon, 11 Sep 2023 11:45:08 -0400 Subject: [PATCH 1/2] Fix concat macro when fields list is of length 1. --- dbt/include/sqlserver/macros/utils/concat.sql | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dbt/include/sqlserver/macros/utils/concat.sql b/dbt/include/sqlserver/macros/utils/concat.sql index 705e7f56..5eda9e64 100644 --- a/dbt/include/sqlserver/macros/utils/concat.sql +++ b/dbt/include/sqlserver/macros/utils/concat.sql @@ -1,3 +1,7 @@ {% macro sqlserver__concat(fields) -%} - concat({{ fields|join(', ') }}) + {%- if fields|length == 1 -%} + {{ fields[0] }} + {%- else -%} + concat({{ fields|join(', ') }}) + {%- endif -%} {%- endmacro %} From 01fa3a972f93c18ce7734b2775d339e4e57dcb7e Mon Sep 17 00:00:00 2001 From: Joshua Kravitz Date: Fri, 15 Sep 2023 08:39:51 -0400 Subject: [PATCH 2/2] Simplify by concating empty string. --- dbt/include/sqlserver/macros/utils/concat.sql | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/dbt/include/sqlserver/macros/utils/concat.sql b/dbt/include/sqlserver/macros/utils/concat.sql index 5eda9e64..2ebfa889 100644 --- a/dbt/include/sqlserver/macros/utils/concat.sql +++ b/dbt/include/sqlserver/macros/utils/concat.sql @@ -1,7 +1,3 @@ {% macro sqlserver__concat(fields) -%} - {%- if fields|length == 1 -%} - {{ fields[0] }} - {%- else -%} - concat({{ fields|join(', ') }}) - {%- endif -%} + concat('', {{ fields|join(', ') }}) {%- endmacro %}