Open Aviss opened 3 months ago
Thanks for opening this @Aviss!
Ah, I can see how the syntax for granting to database roles differs and how that would necessitate new options within the dbt interface.
This looks similar to the following issue in dbt-redshift: https://github.com/dbt-labs/dbt-redshift/issues/415. It has the associated PR https://github.com/dbt-labs/dbt-redshift/pull/626 which proposes the following interface:
If this pattern were adopted within dbt-core, then the interface for dbt-snowflake might look like:
models:
- name: MODEL_NAME_1
config:
grants:
# New syntax option
select:
role: [ROLE_NAME_1, ROLE_NAME_2, ...]
database_role: [DATABASE_ROLE_NAME_1, DATABASE_ROLE_NAME_2, ...]
insert:
role: [ROLE_NAME_1, ROLE_NAME_2, ...]
database_role: [DATABASE_ROLE_NAME_1, DATABASE_ROLE_NAME_2, ...]
- name: MODEL_NAME_2
config:
grants:
# Also preserve existing syntax for full backwards compatibility
select: [ROLE_NAME_1, ROLE_NAME_2, ...]
This isn't something we're likely to prioritize anytime soon, but leaving this issue open for folks to upvote.
In that sense I would suggest adding this limitation to the DBT grants documentation page since it already contains a database specific section
Good idea @Aviss ! 💡
Opened this PR to update the documentation: https://github.com/dbt-labs/docs.getdbt.com/pull/6120
Is this your first time submitting a feature request?
Describe the feature
Snowflake supports the concept of a database role, a role that can only be assigned permissions on a database, but no account level permissions like managing users.
However, this comes with a slightly altered SQL-Query where GRANTS and REVOKES are concerned.
From the logs I gather that DBT does not specify the object type in the Query and thus implicitly refers to roles. In fact, when a databse role grant has been (manually) added to a table this leads to an error:
granted_to
column in theshow grants
response:However I can not think of a concise way to configure this distinction in the models.
One option would be to duplicate the
grants
keyword:Alternatively a special notation could be used:
As none of these options are particularly elegant, I would understand a reluctance to implement this feature. I'm opening this issue mostly for documentation purposes since I was unable to find anything on this topic online.
In that sense I would suggest adding this limitation to the DBT grants documentation page since it already contains a database specific section
Describe alternatives you've considered
No response
Who will this benefit?
No response
Are you interested in contributing this feature?
No response
Anything else?
No response