dbt is creating schemas when they already exists because of case-sensitive comparisons #1651
Labels
enhancement
New feature or request
good_first_issue
Straightforward + self-contained changes, good for new contributors!
snowflake
Milestone
Issue
In Snowflake, DBT is trying to create a schema that already exists. Because my snowflake role does not have create schema privs, I get an
Insufficient privileges to operate on database 'foo'
error when dbt tries to create the schema.Issue description
Stacktrace:
Results
https://github.com/fishtown-analytics/dbt/blob/399b33822a85493a8790df787eed59e951aecf6c/core/dbt/task/runnable.py#L306-L324
I believe there is a bug in
create_schemas()
and case sensitivity. In Snowflake,list_schemas()
will return schema names in upper-case. However, if you define your schemas in your dbt project or profiles in lowercase, the set subtraction ofrequired_schemas - existing_schemas
will not identify that the schema already exists and will re-create it.When I change my dbt_project.yml and profiles.yml to use only upper-case schema names, it works as expected.
System information
The output of
dbt --version
:The python version you're using (probably the output of
python --version
)Proposed Solutions
dbt does not support case-sensitive schemas
This looks like the easiest route. If you look at lookup schemas in a case-insensitive way #1411, we already consider databases to be case insensitive.
dbt supports case-sensitive schemas
If we go this route, I think the default should be case insensitive. However, if you double quote your schema name, it will evaluate as case-sensitive. This seems like a better solution, but I'm unsure of all the downstream call points that would need to be updated to support this.
Happy to help submit a patch if you give me some direction on what the correct fix should be :)
The text was updated successfully, but these errors were encountered: