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

Using union_relations macro with include paramater doesn't select any columns and results in error #266

Closed
4 tasks
KellyBurdine opened this issue Aug 13, 2020 · 3 comments · Fixed by #473
Closed
4 tasks
Labels
bug Something isn't working triage

Comments

@KellyBurdine
Copy link

KellyBurdine commented Aug 13, 2020

Describe the bug

I was successfully using the macro union_relations with the optional exclude parameter. However when I switched to using include I received the error 'SQL compilation error:
syntax error line 19 at position 12 unexpected 'from'.'
When I opened the compiled file I noticed that the compiled SQL wasn't selecting any of the columns I listed in the include paramater. It was only selecting the source model followed by a comma and the from statement thus triggering the SQL error. It appears the macro is not working as intended.

Steps to reproduce

Create a model using the union_relations macro and use the optional "include" parameter. List columns in the include parameter. I also renamed my source column, but I'm not sure if that is related to the bug.

Expected results

I would expect all columns listed in the include parameter array to be in each select statement and not end in a comma before the from causing a syntax error.

Actual results

The macro is not calling any columns, but the source model column. I've confirmed these columns do exist in my underlying ref models and can query them from those tables in Snowflake.

Screenshots and log output

Here is a screenshot of my model script:
Screen Shot 2020-08-13 at 3 27 21 PM

Here is a screenshot of part of the compiled script
Screen Shot 2020-08-13 at 3 22 38 PM

Here is a screenshot of the error:
Screen Shot 2020-08-13 at 3 32 37 PM

System information

The contents of your packages.yml file:

Which database are you using dbt with?

  • postgres
  • redshift
  • bigquery
  • [ X] snowflake
  • other (specify: ____________)

The output of dbt --version:

installed version: 0.17.0
   latest version: 0.17.2

Your version of dbt is out of date! You can find instructions for upgrading here:
https://docs.getdbt.com/docs/installation

Plugins:
  - bigquery: 0.17.0
  - snowflake: 0.17.0
  - redshift: 0.17.0
  - postgres: 0.17.0

The operating system you're using:
MacOS Mojave Version 10.14.6

The output of python --version:
Python 3.7.7

**Contents of packages:: **

  • package: fishtown-analytics/dbt_utils
    version: 0.5.1

Additional context

Are you interested in contributing the fix?

No, going on extended leave in a few weeks

@KellyBurdine KellyBurdine added bug Something isn't working triage labels Aug 13, 2020
@grahamwetzler
Copy link
Contributor

I also ran into this issue but I realized the problem was that I was using lowercase column names. Snowflake objects are uppercase by default.

@grahamwetzler
Copy link
Contributor

A good solution to this could be to raise an error if no columns are selected.

@dbeatty10
Copy link
Contributor

Fixed by #473

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

Successfully merging a pull request may close this issue.

3 participants