From cc8080181405e32972de6f4c6ca0ef824ff3ec98 Mon Sep 17 00:00:00 2001 From: dluftspring Date: Tue, 22 Nov 2022 17:08:48 -0800 Subject: [PATCH 1/4] Adding friendlier error message when dist is improperly set as a list or mapping --- dbt/include/redshift/macros/adapters.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dbt/include/redshift/macros/adapters.sql b/dbt/include/redshift/macros/adapters.sql index ca888d566..2f9b7318f 100644 --- a/dbt/include/redshift/macros/adapters.sql +++ b/dbt/include/redshift/macros/adapters.sql @@ -1,6 +1,10 @@ {% macro dist(dist) %} {%- if dist is not none -%} + {%- if dist is iterable or dist is mapping -%} + {% exceptions.raise_compiler_error("Expected a single valued property for dist and got: " ~ dist ~ " instead") %} + {%-endif -%} + {%- set dist = dist.strip().lower() -%} {%- if dist in ['all', 'even'] -%} From 4a65af696ed86a7b674252a58e9acd23d35aa402 Mon Sep 17 00:00:00 2001 From: dluftspring Date: Tue, 22 Nov 2022 17:20:27 -0800 Subject: [PATCH 2/4] Commit changie file --- .changes/unreleased/Fixes-20221122-172014.yaml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changes/unreleased/Fixes-20221122-172014.yaml diff --git a/.changes/unreleased/Fixes-20221122-172014.yaml b/.changes/unreleased/Fixes-20221122-172014.yaml new file mode 100644 index 000000000..a30be59b6 --- /dev/null +++ b/.changes/unreleased/Fixes-20221122-172014.yaml @@ -0,0 +1,7 @@ +kind: Fixes +body: Friendlier error message for misspecified distkey type +time: 2022-11-22T17:20:14.432522-08:00 +custom: + Author: dluftspring + Issue: "224" + PR: "226" From f739b54004f69b210c7278f97773853b7e208c01 Mon Sep 17 00:00:00 2001 From: Mila Page <67295367+VersusFacit@users.noreply.github.com> Date: Thu, 20 Apr 2023 22:15:46 -0700 Subject: [PATCH 3/4] fix syntax error --- dbt/include/redshift/macros/adapters.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbt/include/redshift/macros/adapters.sql b/dbt/include/redshift/macros/adapters.sql index 1e5a5e6ca..dd8c8dc7a 100644 --- a/dbt/include/redshift/macros/adapters.sql +++ b/dbt/include/redshift/macros/adapters.sql @@ -3,7 +3,7 @@ {%- if dist is not none -%} {%- if dist is iterable or dist is mapping -%} {% exceptions.raise_compiler_error("Expected a single valued property for dist and got: " ~ dist ~ " instead") %} - {%-endif -%} + {%- endif -%} {%- set dist = dist.strip().lower() -%} From af3598e3044e26561c3625f627f0e34c76de78c2 Mon Sep 17 00:00:00 2001 From: dluftspring Date: Thu, 3 Aug 2023 09:26:57 -0700 Subject: [PATCH 4/4] Add missing do and fix type check to exclude strings --- dbt/include/redshift/macros/adapters.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dbt/include/redshift/macros/adapters.sql b/dbt/include/redshift/macros/adapters.sql index 072d9bb1b..491241d7a 100644 --- a/dbt/include/redshift/macros/adapters.sql +++ b/dbt/include/redshift/macros/adapters.sql @@ -1,8 +1,8 @@ {% macro dist(dist) %} {%- if dist is not none -%} - {%- if dist is iterable or dist is mapping -%} - {% exceptions.raise_compiler_error("Expected a single valued property for dist and got: " ~ dist ~ " instead") %} + {%- if dist is iterable or dist is mapping and (dist is not string) -%} + {% do exceptions.raise_compiler_error("Expected a single valued property for dist and got: " ~ dist ~ " instead") %} {%- endif -%} {%- set dist = dist.strip().lower() -%}