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

fix: Fix grants statements on materialized views #1267

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20240625-140329.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Fix grants statements on materialized views
time: 2024-06-25T14:03:29.437827546Z
custom:
Author: AcidFlow
Issue: "1268"
14 changes: 12 additions & 2 deletions dbt/include/bigquery/macros/adapters/apply_grants.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,19 @@


{%- macro bigquery__get_grant_sql(relation, privilege, grantee) -%}
grant `{{ privilege }}` on {{ relation.type }} {{ relation }} to {{ '\"' + grantee|join('\", \"') + '\"' }}
{% set relation_type_overrides = {
"materialized_view": "materialized view"
}
%}
{% set relation_type = relation_type_overrides.get(relation.type, relation.type) %}
grant `{{ privilege }}` on {{ relation_type }} {{ relation }} to {{ '\"' + grantee|join('\", \"') + '\"' }}
{%- endmacro -%}

{%- macro bigquery__get_revoke_sql(relation, privilege, grantee) -%}
revoke `{{ privilege }}` on {{ relation.type }} {{ relation }} from {{ '\"' + grantee|join('\", \"') + '\"' }}
{% set relation_type_overrides = {
"materialized_view": "materialized view"
}
%}
{% set relation_type = relation_type_overrides.get(relation.type, relation.type) %}
revoke `{{ privilege }}` on {{ relation_type }} {{ relation }} from {{ '\"' + grantee|join('\", \"') + '\"' }}
{%- endmacro -%}