Add error checking to all of the macros that use get_columns_in_relation #527
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.
…so as to provide a more useful error message if no columns are returned by that function.
This is a:
main
dev/
branchdev/
branchDescription & motivation
I ran into a situation where different adapters have different behaviors with respect to the case-sensitivity of the relation that is passed in to
get_columns_in_relation
: Snowflake/Spark largely ignore the case of the relation (so passing in "events" will give the same colimn as "EVENTS") whereas other adapters (e.g., Postgres) do case-sensitive matching of the relation/schema names via theinformation_schema.columns
table and will return 0 columns if the cases do not match. I thought I could make the error message for this situation a bit easier to grok than what happens now (which is that you get a compiled model with a bunch of invalid SQL)I am happy to add tests for these checks if it's appropriate to do so, but I'll need a little bit of guidance in so far as running
make test target=postgres models=sql.test_star seeds=sql.data_star
locally threw this error: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