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

Add error checking to all of the macros that use get_columns_in_relation #527

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions macros/sql/star.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

{%- set include_cols = [] %}
{%- set cols = adapter.get_columns_in_relation(from) -%}
{%- if not cols %}
{{ exceptions.raise_compiler_error("Error: no columns found in relation " ~ relation ~ " - check for case-sensitive naming") }}
{% endif -%}
{%- set except = except | map("lower") | list %}
{%- for col in cols -%}

Expand Down
3 changes: 3 additions & 0 deletions macros/sql/union.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
{%- do dbt_utils._is_relation(relation, 'union_relations') -%}
{%- do dbt_utils._is_ephemeral(relation, 'union_relations') -%}
{%- set cols = adapter.get_columns_in_relation(relation) -%}
{%- if not cols %}
{{ exceptions.raise_compiler_error("Error: no columns found in relation " ~ relation ~ " - check for case-sensitive naming") }}
{% endif -%}
{%- for col in cols -%}

{#- If an exclude list was provided and the column is in the list, do nothing -#}
Expand Down