Closed thebbennett closed 1 year ago
Thanks for reaching out @thebbennett !
I don't know all the ins-and-outs here, but these two links look like they have some relevant information:
It looks like dbt Cloud creates special schemas (like dbt_cloud_pr_82935_116
) when you have CI configured in dbt Cloud. But I don't know why it is not created when you use dbt run
but it is created when you do dbt build
:shrug:
Could you reach out to dbt Cloud Support using the speech bubble (💬) in the dbt Cloud interface or at email address support@getdbt.com?
I hate redirecting you, but I don't know how to effectively troubleshoot this one since it appears to be related to dbt Cloud rather than dbt Core. In the meantime, I'm going to close this in favor of you reaching out to dbt Cloud Support. If there ends up being a change we can make in dbt Core, then we can either re-open this issue or create a new one.
This has been resolved on a call with @thebbennett !
dbt build
runs snapshot, which their previous run
and test
logic was leaving out.
the snapshot sql also had specific schema logic written in the model, which did not enforce their preferred ci schema. The in-model schema logic takes priority over their generate_schema_name
macro, so it was attempting to create the dbt_cloud_pr
schema and failing due to the permissions.
This has been resolved on a call with @thebbennett !
dbt build
runs snapshot, which their previousrun
andtest
logic was leaving out. the snapshot sql also had specific schema logic written in the model, which did not enforce their preferred ci schema. The in-model schema logic takes priority over theirgenerate_schema_name
macro, so it was attempting to create thedbt_cloud_pr
schema and failing due to the permissions.
How it was solved? Is it possible to override the schema creation and use the one in dev or prod profile?
How it was solved?
Hi @nsoria1, I would say this was more about aligning expectations.
Is it possible to override the schema creation and use the one in dev or prod profile?
You might consider something like this:
{% snapshot your_snapshot %}
{{
config(
target_database='analytics',
target_schema=target.schema
...
)
}}
...
Whatever you do, just make sure that you are not overwriting your production schema in development runs.
Is this a new bug in dbt-core?
Current Behavior
My team runs dbt Core.
We changed our CI job from
to
We also have 2 macros,
generate_schema_name
andgenerate_alias_name
, that override the create_schema function to instead create all of the views/tables produced by the CI run into 1 schema.These macros work when we use
dbt run
. These macros fail when we usedbt build
. The error message we get ispermission denied for database dev
and the logs tell me that dbt is trying to create a new schema for our CI run. This tells me that our macro is not working as intended.Expected Behavior
There should be no difference in running
dbt run
versusdbt build
when we run our CI job. Ourgenerate_schema_name
macro should work as expected and tell the CI job to place all views/tables in our set schema.Steps To Reproduce
generate_relation_names
and copy the following Jinja into it. Set YOUR_SCHEMA_HERE to a schema you have permission to create in.Relevant log output
Environment
Which database adapter are you using with dbt?
redshift
Additional Context
See this Slack message