Skip to content

Commit e8b93d3

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

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

sqlmesh/core/engine_adapter/bigquery.py

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

13781378
@staticmethod
13791379
def _grant_object_kind(table_type: DataObjectType) -> str:
1380-
if table_type == DataObjectType.VIEW or table_type == DataObjectType.MATERIALIZED_VIEW:
1380+
if table_type == DataObjectType.VIEW:
13811381
return "VIEW"
1382+
if table_type == DataObjectType.MATERIALIZED_VIEW:
1383+
# We actually need to use "MATERIALIZED VIEW" here even though it's not listed
1384+
# as a supported resource_type in the BigQuery DCL doc:
1385+
# https://cloud.google.com/bigquery/docs/reference/standard-sql/data-control-language
1386+
return "MATERIALIZED VIEW"
13821387
return "TABLE"
13831388

13841389
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)