Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.

Commit 5712dcf

Browse files
committed
fix: Fix grants statements on materialized views
Granting privileges on materialized views was failing because the generated SQL statement used the relation type `materialized_view` as part of the query instead of `materialized view` (with a space). This commit defines an override for this specific materialization in the and grant/revoke macros.
1 parent 0627aa2 commit 5712dcf

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

dbt/include/bigquery/macros/adapters/apply_grants.sql

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,19 @@
1212

1313

1414
{%- macro bigquery__get_grant_sql(relation, privilege, grantee) -%}
15-
grant `{{ privilege }}` on {{ relation.type }} {{ relation }} to {{ '\"' + grantee|join('\", \"') + '\"' }}
15+
{% set relation_type_overrides = {
16+
"materialized_view": "materialized view"
17+
}
18+
%}
19+
{% set relation_type = relation_type_overrides.get(relation.type, relation.type) %}
20+
grant `{{ privilege }}` on {{ relation_type }} {{ relation }} to {{ '\"' + grantee|join('\", \"') + '\"' }}
1621
{%- endmacro -%}
1722

1823
{%- macro bigquery__get_revoke_sql(relation, privilege, grantee) -%}
19-
revoke `{{ privilege }}` on {{ relation.type }} {{ relation }} from {{ '\"' + grantee|join('\", \"') + '\"' }}
24+
{% set relation_type_overrides = {
25+
"materialized_view": "materialized view"
26+
}
27+
%}
28+
{% set relation_type = relation_type_overrides.get(relation.type, relation.type) %}
29+
revoke `{{ privilege }}` on {{ relation_type }} {{ relation }} from {{ '\"' + grantee|join('\", \"') + '\"' }}
2030
{%- endmacro -%}

0 commit comments

Comments
 (0)