Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CT-1519] Adding friendlier error message when dist is improperly set as a list or mapping #226

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changes/unreleased/Fixes-20221122-172014.yaml
Original file line number Diff line number Diff line change
@@ -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"
4 changes: 4 additions & 0 deletions dbt/include/redshift/macros/adapters.sql
Original file line number Diff line number Diff line change
@@ -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") %}
Copy link
Contributor

@mikealfare mikealfare Jun 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs a do in front of it, e.g.:

{% do exceptions.raise_compiler_error("Expected a single valued property for dist and got: " ~ dist ~ " instead") %}

Alternatively, I think {{ instead of {% also works:

{{ exceptions.raise_compiler_error("Expected a single valued property for dist and got: " ~ dist ~ " instead") }}

Otherwise jinja is looking for a keyword like set, if, macro, etc.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's my mistake on the compiler error- it needs a do statement. Let me update this later today. There's an issue with the conditional check. Strings are technically iterable so this isn't doing what I want it to do in any case

{%- endif -%}

{%- set dist = dist.strip().lower() -%}

{%- if dist in ['all', 'even'] -%}
Expand Down