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

[Barbara Gittings]: Regression: dbt tries to create schemas that already exist #2186

Closed
drewbanin opened this issue Mar 6, 2020 · 1 comment · Fixed by #2187
Closed

[Barbara Gittings]: Regression: dbt tries to create schemas that already exist #2186

drewbanin opened this issue Mar 6, 2020 · 1 comment · Fixed by #2187
Assignees
Labels
bug Something isn't working

Comments

@drewbanin
Copy link
Contributor

Describe the bug

If a schema already exists in the database, dbt should not try to create the schema. While dbt does use create schema if not exists..., this query will fail if the user does not have permissions to create schemas on the database. dbt's schema creation code accounts for this, but it looks like a bug slipped into the pre-release of 0.16.0 (thanks for the heads up @eogilvy12!)

This regression manifests as:

ERROR:  permission denied for database analytics

at the start of the run.

Steps To Reproduce

  1. Create a user without create permissions on the database.
create user drew_noaccess; # must not be a superuser!
revoke create on database analytics from drew_noaccess;
  1. Run dbt using this user, targeting a schema that already exists:
$ dbt run
...
ERROR:  permission denied for database analytics

Cause

I think this only happens when database (and maybe schema?) quoting is enabled in a project.
It looks like dbt correctly runs the queries to find schemas in the given database, but we've got an extra pair of quotes in the database name that (while appropriate for an information schema query[1]) break during the in-memory check for existing schemas[2]
Via:

[1]
https://github.com/fishtown-analytics/dbt/blob/a259f154dae60009b2115189f21ca1ed61061456/core/dbt/task/runnable.py#L405-L409

[2]
https://github.com/fishtown-analytics/dbt/blob/a259f154dae60009b2115189f21ca1ed61061456/core/dbt/task/runnable.py#L445-L450

Screen Shot 2020-03-06 at 2 48 00 PM

@drewbanin drewbanin added the bug Something isn't working label Mar 6, 2020
@beckjake beckjake linked a pull request Mar 6, 2020 that will close this issue
4 tasks
beckjake added a commit that referenced this issue Mar 11, 2020
…ed-schemas

Do not create already-existing schemas (#2186)
@beckjake
Copy link
Contributor

Fixed in #2187

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants