Skip to content

Commit d6c3e5d

Browse files
committed
fix: bigquery actually requires "MATERIALIZED VIEW" in DCL for
actual materialized views
1 parent fbc12da commit d6c3e5d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

sqlmesh/core/engine_adapter/bigquery.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1370,8 +1370,13 @@ def _get_grant_expression(self, table: exp.Table) -> exp.Expression:
13701370

13711371
@staticmethod
13721372
def _grant_object_kind(table_type: DataObjectType) -> str:
1373-
if table_type == DataObjectType.VIEW or table_type == DataObjectType.MATERIALIZED_VIEW:
1373+
if table_type == DataObjectType.VIEW:
13741374
return "VIEW"
1375+
if table_type == DataObjectType.MATERIALIZED_VIEW:
1376+
# We actually need to use "MATERIALIZED VIEW" here even though it's not listed
1377+
# as a supported resource_type in the BigQuery DCL doc:
1378+
# https://cloud.google.com/bigquery/docs/reference/standard-sql/data-control-language
1379+
return "MATERIALIZED VIEW"
13751380
return "TABLE"
13761381

13771382
def _dcl_grants_config_expr(

tests/core/engine_adapter/test_bigquery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,7 @@ def test_sync_grants_config_with_overlaps(
13361336
[
13371337
(DataObjectType.TABLE, "TABLE"),
13381338
(DataObjectType.VIEW, "VIEW"),
1339-
(DataObjectType.MATERIALIZED_VIEW, "TABLE"),
1339+
(DataObjectType.MATERIALIZED_VIEW, "MATERIALIZED VIEW"),
13401340
],
13411341
)
13421342
def test_sync_grants_config_object_kind(

0 commit comments

Comments
 (0)