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

Linting dbt_utils.star with Sqlfluff has an empty select #605

Closed
dbeatty10 opened this issue Jun 13, 2022 · 0 comments · Fixed by #561
Closed

Linting dbt_utils.star with Sqlfluff has an empty select #605

dbeatty10 opened this issue Jun 13, 2022 · 0 comments · Fixed by #561
Labels
bug Something isn't working triage

Comments

@dbeatty10
Copy link
Contributor

Describe the bug

Previously raised by @swanjson here and again by sam I here:

I have a dbt project that uses the dbt_utils.star macro that will not pass sqlfluff linting checks because the table that star is pointing at doesn’t exist yet. The current behavior of the macro is to return nothing in this situation, but it creates compiled code that looks like this:

select

from tablename

Code like this causes sqlfluff to raise a parsing error.

Steps to reproduce

  1. Create some_model.sql like:
    select
        {{ dbt_utils.star(from=ref('some_table'), except=['some_column']) }}
    from ref('some_table')
    
  2. Make sure it doesn't exist yet:
    drop table {{ ref('some_table') }}
    
  3. Run dbt compile
  4. Check the compiled SQL in target/compiled/{PROJECT_NAME}/models/some_model.sql

Expected results

select
    *
from tablename

Actual results

select

from tablename

Workaround

dbt run before linting (not ideal)

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
1 participant