-
Notifications
You must be signed in to change notification settings - Fork 535
Open
Labels
Description
Describe the bug
When the macro dbt_utils.star
uses a non-existing model, the output of the compilation is:
*
/* No columns were returned. Maybe the relation doesn't exist yet
or all columns were excluded. This star is only output during
dbt compile, and exists to keep SQLFluff happy. */
Notice the trailing whitespaces yet
, during
, which fail sqlfluff's linting with L001 Unnecessary trailing whitespace
.
While there, use {%- ... -%}
instead of {% ... %}
in the macro statements to remove trailing whitespaces.
Steps to reproduce
Compile a non existing table:
SELECT
{{ dbt_utils.star(from=ref('non_existing_table')) }}
FROM {{ ref('non_existing_table') }}
which returns:
SELECT
*
/* No columns were returned. Maybe the relation doesn't exist yet
or all columns were excluded. This star is only output during
dbt compile, and exists to keep SQLFluff happy. */
FROM non_existing_table
Expected results
SELECT
*
/* No columns were returned. Maybe the relation doesn't exist yet
or all columns were excluded. This star is only output during
dbt compile, and exists to keep SQLFluff happy. */
FROM non_existing_table
Actual results
SELECT
<- 1 whitespace
*
/* No columns were returned. Maybe the relation doesn't exist yet <- 1 whitespace
or all columns were excluded. This star is only output during <- 2 whitespaces
dbt compile, and exists to keep SQLFluff happy. */
<- 12 whitespaces
FROM non_existing_table
Which database are you using dbt with?
- snowflake
The output of dbt --version
:
Core:
- installed: 1.8.3
Additional context
We lint our compiled dbt models. When a model doesn't exist in one of our database, it compiles with the message that contains whitespaces and fails with sqlfluff's L001 Unnecessary trailing whitespace.
Are you interested in contributing the fix?
Tested in local. I will open a Pull Request