MATERIALIZED_VIEWS view

TheINFORMATION_SCHEMA.MATERIALIZED_VIEWS view contains status about materialized views.

Required permissions

To get the permissions that you need to query theINFORMATION_SCHEMA.MATERIALIZED_VIEWS view, ask your administrator to grant you theBigQuery Metadata Viewer (roles/bigquery.metadataViewer) IAM role on your project or dataset. For more information about granting roles, seeManage access to projects, folders, and organizations.

This predefined role contains the permissions required to query theINFORMATION_SCHEMA.MATERIALIZED_VIEWS view. To see the exact permissions that are required, expand theRequired permissions section:

Required permissions

The following permissions are required to query theINFORMATION_SCHEMA.MATERIALIZED_VIEWS view:

  • bigquery.tables.get
  • bigquery.tables.list

You might also be able to get these permissions withcustom roles or otherpredefined roles.

For more information about BigQuery permissions, seeAccess control with IAM.

Schema

When you query theINFORMATION_SCHEMA.MATERIALIZED_VIEWS view, the query results containone row for each materialized view in a dataset.

TheINFORMATION_SCHEMA.MATERIALIZED_VIEWS view has the following schema:

Column nameData typeValue
table_catalogSTRINGThe name of the project that contains the dataset. Also referred to as theprojectId.
table_schemaSTRINGThe name of the dataset that contains the materialized view. Also referred to as thedatasetId.
table_nameSTRINGThe name of the materialized view. Also referred to as thetableId.
last_refresh_timeTIMESTAMPThe time when this materialized view was last refreshed.
refresh_watermarkTIMESTAMPThe refresh watermark of the materialized view. The data contained in materialized view base tables up to this time are included in the materialized view cache.
last_refresh_statusRECORDError result of the last automatic refresh job as anErrorProto object. If present, indicates that the last automatic refresh was unsuccessful.

For stability, we recommend that you explicitly list columns in your information schema queries instead ofusing a wildcard (SELECT *). Explicitly listing columns prevents queries frombreaking if the underlying schema changes.

Scope and syntax

Queries against this view must include a dataset or a region qualifier. Forqueries with a dataset qualifier, you must have permissions for the dataset.For queries with a region qualifier, you must have permissions for the project.For moreinformation, seeSyntax.The following table explains the region and resource scopes for this view:

View nameResource scopeRegion scope
[PROJECT_ID.]`region-REGION`.INFORMATION_SCHEMA.MATERIALIZED_VIEWSProject levelREGION
[PROJECT_ID.]DATASET_ID.INFORMATION_SCHEMA.MATERIALIZED_VIEWSDataset levelDataset location
Replace the following:
  • Optional:PROJECT_ID: the ID of your Google Cloud project. If not specified, the default project is used.
  • REGION: anydataset region name. For example,`region-us`.
  • DATASET_ID: the ID of your dataset. For more information, seeDataset qualifier.

    Note: You must usea region qualifier to queryINFORMATION_SCHEMA views. The location of the query execution must match the region of theINFORMATION_SCHEMA view.

For example:

-- Returns metadata for views in a single dataset.SELECT*FROMmyDataset.INFORMATION_SCHEMA.MATERIALIZED_VIEWS;-- Returns metadata for all views in a region.SELECT*FROMregion-us.INFORMATION_SCHEMA.MATERIALIZED_VIEWS;

Examples

Example 1:

The following example retrieves all the unhealthy materialized views from theINFORMATION_SCHEMA.MATERIALIZED_VIEWS view. It returns the materialized viewswith nonNULLlast_refresh_status values inmydataset in your defaultproject —myproject.

To run the query against a project other than your default project, add theproject ID to the dataset in the following format:`project_id`.dataset.INFORMATION_SCHEMA.MATERIALIZED_VIEWS;for example,`myproject`.mydataset.INFORMATION_SCHEMA.MATERIALIZED_VIEWS.

SELECTtable_name,last_refresh_statusFROMmydataset.INFORMATION_SCHEMA.MATERIALIZED_VIEWSWHERElast_refresh_statusISNOTNULL;
Note:INFORMATION_SCHEMA view names are case-sensitive.

The result is similar to the following:

  +---------------+---------------------------------------------------------------------+  |  table_name   |                        last_refresh_status                          |  +---------------------------------------------------------------------+---------------+  |  myview       |   {"reason":"invalidQuery","location":"query","message":"..."}      |  +---------------------------------------------------------------------+---------------+

Example 2:

The following example retrieves thelast_refresh_time andrefresh_watermarkof materialized viewmyview inmydataset in your default project —myproject. The result shows when the materialized was last refreshed and up towhen data of base tables are collected into the materialized view cache.

To run the query against a project other than your default project, add theproject ID to the dataset in the following format:`project_id`.dataset.INFORMATION_SCHEMA.MATERIALIZED_VIEWS;for example,`myproject`.mydataset.INFORMATION_SCHEMA.MATERIALIZED_VIEWS.

SELECTtable_name,last_refresh_time,refresh_watermarkFROMmydataset.INFORMATION_SCHEMA.MATERIALIZED_VIEWSWHEREtable_name='myview';
Note:INFORMATION_SCHEMA view names are case-sensitive.

The result is similar to the following:

  +---------------+------------------------------------------------+  |  table_name   |  last_refresh_time     | refresh_watermark     |  +---------------+------------------------------------------------+  |  myview       | 2023-02-22 19:37:17    | 2023-03-08 16:52:57   |  +---------------+------------------------------------------------+

Note: If there have been no recent changes to the base tables,BigQuery periodically increases therefresh_watermark toindicate that the materialized view is up-to-date without actually refreshingit. As a result, thelast_refresh_time can be earlier than therefresh_watermark.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.