You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the existing issues, and I could not find an existing issue for this bug
Current Behavior
As a user, when I use pre-hook in dbt, I expect this to run before dbt starts creating things in my database. That is - you guessed it - not the case.
Before the pre-hooks are executed, dbt already calls the create_schema(...) macro to create the schema set in the profiles.yml file. You also don't have any model information in the create_schema(...) macro that you could use to override this behaviour. The macro accepts a relation as an argument, but it's only given relations where only the schema is set.
Expected Behavior
dbt should not call create_schema(...) in the beginning of the run. It should call create_schema(...) right before the model materialization happens and then pass the relation it's going to materialize as an argument to this macro. Schemas can be different for every model so creating the initial one listed in profiles.yml might not even be necessary.
Why this matters:
In Trino / Starburst permissions work in a particular way. Users are assigned roles and permissions are assigned to those roles. In most database engines, you would then have the sum of all of your permissions available to you, but not in Starburst. You have to explicitly assume a role you're given before you can use the linked permissions. So in Starburst if I work with schemas which belong to a different role than my default role, I have to first run a pre-hook with SET ROLE rolename.
Steps To Reproduce
Add a pre-hook to a model
dbt run -s that_model
Check dbt logs
Notice that dbt first creates the schema and only then runs the pre-hook
dbt tasks have a [before_run](https://github.com/dbt-labs/dbt-core/blob/f7c4c3c9cc2db8327c3fbb9e4889f7f0f1e9e167/core/dbt/task/runnable.py#L528) function which - as the name implies - runs before anything else. The dbt run has [create_schemas](https://github.com/dbt-labs/dbt-core/blob/f7c4c3c9cc2db8327c3fbb9e4889f7f0f1e9e167/core/dbt/task/run.py#L1006) as part of the implementation of this function.
Can we just remove this call there?
Relevant log output
Environment
dbt-core 1.9
Which database adapter are you using with dbt?
other (mention it in "Additional Context")
Additional Context
dbt-trino, but IMHO irrelevant and should be fixed in dbt-core
The text was updated successfully, but these errors were encountered:
Is this a new bug in dbt-core?
Current Behavior
As a user, when I use
pre-hook
in dbt, I expect this to run before dbt starts creating things in my database. That is - you guessed it - not the case.Before the
pre-hook
s are executed, dbt already calls thecreate_schema(...)
macro to create the schema set in theprofiles.yml
file. You also don't have any model information in thecreate_schema(...)
macro that you could use to override this behaviour. The macro accepts a relation as an argument, but it's only given relations where only the schema is set.Expected Behavior
dbt should not call
create_schema(...)
in the beginning of the run. It should callcreate_schema(...)
right before the model materialization happens and then pass the relation it's going to materialize as an argument to this macro. Schemas can be different for every model so creating the initial one listed inprofiles.yml
might not even be necessary.Why this matters:
In Trino / Starburst permissions work in a particular way. Users are assigned roles and permissions are assigned to those roles. In most database engines, you would then have the sum of all of your permissions available to you, but not in Starburst. You have to explicitly assume a role you're given before you can use the linked permissions. So in Starburst if I work with schemas which belong to a different role than my default role, I have to first run a pre-hook with
SET ROLE rolename
.Steps To Reproduce
pre-hook
to a modeldbt run -s that_model
pre-hook
dbt tasks have a
[before_run](https://github.com/dbt-labs/dbt-core/blob/f7c4c3c9cc2db8327c3fbb9e4889f7f0f1e9e167/core/dbt/task/runnable.py#L528)
function which - as the name implies - runs before anything else. Thedbt run
has[create_schemas](https://github.com/dbt-labs/dbt-core/blob/f7c4c3c9cc2db8327c3fbb9e4889f7f0f1e9e167/core/dbt/task/run.py#L1006)
as part of the implementation of this function.Can we just remove this call there?
Relevant log output
Environment
Which database adapter are you using with dbt?
other (mention it in "Additional Context")
Additional Context
dbt-trino, but IMHO irrelevant and should be fixed in dbt-core
The text was updated successfully, but these errors were encountered: