dbt tries to create schema which already exists, as user with no create permissions

Thanks for confirming that it’s still happening in new versions of dbt Core @rmenendezm! I asked around internally, and here’s what I learned:

  • dbt only considers creating schemas for models that are actually selected to run (relevant lines of code)
  • dbt first determines what schemas exist, and will run create schema ... if not exists only if it doesn’t think the schema exists.

With this in mind, our hypothesis is:

  • the schema does exist (already confirmed)
  • The database user that is using dbt doesn’t have permission to see the schema at all, even that it exists
  • One or more of the selected models in your run are intended to land in the SDNA_US_SDNA_UI_DEV schema
  • dbt can’t see that the schema already exists (it’s not allowed to!) so it tries to create it, and hits an error.

I would suggest that you check what permissions the database user has, to ensure it can at least see the schemas.

From there, if you have a different situation then it would be worth opening a GitHub issue with the details

1 Like