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

get_column_values compiler error never gets raised - failing silently #531

Closed
1 of 5 tasks
jpmmcneill opened this issue Mar 30, 2022 · 4 comments
Closed
1 of 5 tasks
Labels
bug Something isn't working good first issue

Comments

@jpmmcneill
Copy link
Contributor

jpmmcneill commented Mar 30, 2022

Describe the bug

The get_column_values compiler error is not working.

{{ exceptions.raise_compiler_error("In get_column_values(): relation " ~ target_relation ~ " does not exist and no default value was provided.") }}

is blocked by

{% set default = [] %}

Steps to reproduce

Run the get_column_values against a table where the relation doesn't exist, without a default passed. Instead of raising a compiler error, [] is returned as a value.

Expected results

A compiler error should be raised in the above case.

Actual results

The macro fails silently.

Which database are you using dbt with?

  • postgres
  • redshift
  • bigquery
  • snowflake
  • other (specify: ____________)

The output of dbt --version:

1.0.1

y other context about the problem here. For example, if you think you know which line of code is causing the issue.
--->

Are you interested in contributing the fix?

I'll open a PR to fix.

@jpmmcneill jpmmcneill added bug Something isn't working triage labels Mar 30, 2022
@jpmmcneill
Copy link
Contributor Author

This is quite a serious bug in my opinion. It was causing production code to break in some edge cases, and the macro should catch this case

@joellabes
Copy link
Contributor

joellabes commented Mar 31, 2022

Hi @jpmmcneill, thanks for calling this out! The change was made in #386 to resolve a different error.

A potential PR to resolve this, while retaining the same behaviour, would be to remove this block

{% if default is none %}
{% set default = [] %}
{% endif %}

and replace the return block in

{%- if not execute -%}
{{ return(default) }}
{% endif %}

with {{ return(default or []) }} which I think would have the same result.

We're looking to cut the next patch of dbt utils next week - if you can get a PR turned around in the next couple of days I'd be happy to include this!

Please use next/patch as your base branch to avoid merge conflicts when it comes time to open your PR.

@jpmmcneill
Copy link
Contributor Author

jpmmcneill commented Mar 31, 2022

Thanks @joellabes, PR open over here: #533

Do you think we should swap out load_relation to get_or_create_relation?

I ran into this where load_relation was silently failing, but in our system we replaced it with a subquery and everything worked out fine, so it was more of a state issue [we're using ECS so this probably isn't typical behaviour]

@joellabes
Copy link
Contributor

Fixed in #533

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue
Projects
None yet
Development

No branches or pull requests

2 participants