star macro: conditional check to see if cols contains columns, if not replace with * #561
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #605
This is a:
next/patch
next/minor
next/major
Description & motivation
I have been using sqlfluff to lint my dbt sql code. Sqlfluff relies on the dbt compiled code to lint. When dbt_util.star is called with a reference that does not yet exist (parsing mode) without running
dbt run
it does not know how to handleget_filtered_columns_in_relation
being empty. This PR should add the case where ifget_filtered_columns_in_relation
is empty it will replace the entire dbt_utils query with a star. This allows the compiled version to be properly linted without a parsing error.Previously:
Now:
I'm not sure if the submitted "fix" for this in Release 0.8.3 works as intended, but should be reviewed by someone more familiar with the codebase.
The method I used for testing was running
dbt compile --select path/to/file
on a file like the following:A prerequisite for the above is the referenced table cannot exist in the database.
Checklist
star()
source)limit_zero()
macro in place of the literal string:limit 0
dbt_utils.type_*
macros instead of explicit datatypes (e.g.dbt_utils.type_timestamp()
instead ofTIMESTAMP