Stay organized with collections Save and categorize content based on your preferences.
Create materialized view replicasThis document describes how to create materialized view replicas in BigQuery. A materialized view replica is a replication of external Amazon Simple Storage Service (Amazon S3), Apache Iceberg, or Salesforce Data Cloud data in a BigQuery dataset so that the data is available locally in BigQuery, which can help you avoid data egress costs and improve query performance.
Before you beginIn the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.Verify that billing is enabled for your Google Cloud project.
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.Verify that billing is enabled for your Google Cloud project.
To get the permissions that you need to perform the tasks in this document, ask your administrator to grant you the BigQuery Admin (roles/bigquery.admin
) IAM role. For more information about granting roles, see Manage access to projects, folders, and organizations.
This predefined role contains the permissions required to perform the tasks in this document. To see the exact permissions that are required, expand the Required permissions section:
Required permissionsThe following permissions are required to perform the tasks in this document:
bigquery.tables.create
bigquery.tables.get
bigquery.tables.getData
bigquery.tables.replicateData
bigquery.jobs.create
You might also be able to get these permissions with custom roles or other predefined roles.
For more information about BigQuery IAM, see Introduction to IAM in BigQuery.
Prepare a dataset for materialized view replicasBefore creating a materialized view replica, you must complete the following tasks:
Select one of the following options:
ConsoleIn the Google Cloud console, go to the BigQuery page.
In the Explorer pane, navigate to the project and dataset where you want to create the materialized view replica, and then click more_vert View actions > Create table.
In the Source section of the Create table dialog, do the following:
Optional: For Local materialized view max staleness, enter a max_staleness
value for your local materialized view.
In the Destination section of the Create table dialog, do the following:
Optional: Specify tags and advanced options for your materialized view replica. If you don't specify a dataset for Local Materialized View Dataset, then one is automatically created in the same project and region as the source data and named bq_auto_generated_local_mv_dataset
. If you don't specify a name for Local Materialized View Name, then one is automatically created in the same project and region as the source data and given the prefix bq_auto_generated_local_mv_
.
Click Create table.
A new local materialized view is created (if it wasn't specified) and authorized in the source dataset. Then the materialized view replica is created in the destination dataset.
SQLBQ.REFRESH_EXTERNAL_METADATA_CACHE
system procedure to refresh the metadata cache.BQ.REFRESH_MATERIALIZED_VIEW
system procedure to refresh the materialized view.Create materialized view replicas by using the CREATE MATERIALIZED VIEW AS REPLICA OF
statement:
CREATE MATERIALIZED VIEW PROJECT_ID.BQ_DATASET.REPLICA_NAME OPTIONS(replication_interval_seconds=REPLICATION_INTERVAL) AS REPLICA OF PROJECT_ID.S3_DATASET.MATERIALIZED_VIEW_NAME;
Replace the following:
PROJECT_ID
: the name of your project in which you want to create the materialized view replica—for example, myproject
.BQ_DATASET
: the name of the BigQuery dataset that you want to create the materialized view replica in—for example, bq_dataset
. The dataset must be in the BigQuery region that maps to the region of the source materialized view.REPLICA_NAME
: the name of the materialized view replica that you want to create—for example, my_mv_replica
.REPLICATION_INTERVAL
: specifies how often to replicate the data from the source materialized view to the replica, in seconds. Must be a value between 60 and 3,600, inclusive. Defaults to 300 (5 minutes).S3_DATASET
: the name of the dataset that contains the source materialized view—for example, s3_dataset
.MATERIALIZED_VIEW_NAME
: the name of the materialized view to replicate—for example, my_mv
.The following example creates a materialized view replica named mv_replica
in bq_dataset
:
CREATE MATERIALIZED VIEW `myproject.bq_dataset.mv_replica` OPTIONS( replication_interval_seconds=600 ) AS REPLICA OF `myproject.s3_dataset.my_s3_mv`
After you create the materialized view replica, the replication process polls the source materialized view for changes and replicates data to the materialized view replica, refreshing the data at the interval you specified in the replication_interval_seconds
or max_staleness
option. If you query the replica before the first backfill completes, you get a backfill in progress
error. You can query the data in the materialized view replica after the first replication completes.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["Materialized view replicas allow for the replication of data from external sources like Amazon S3, Apache Iceberg, or Salesforce Data Cloud into BigQuery datasets."],["Creating a materialized view replica requires specific IAM permissions, primarily the BigQuery Admin role, or custom roles with equivalent permissions like `bigquery.tables.replicateData`."],["Before creating a replica, users must create a supported dataset in a specific region and choose a source table like an Amazon S3 BigLake table, Apache Iceberg external table, or a Data Cloud table."],["Replicas can be created either through the BigQuery console by specifying the source and destination details or via SQL using the `CREATE MATERIALIZED VIEW AS REPLICA OF` statement."],["The replication process refreshes the materialized view replica at a user-defined interval, specified by `replication_interval_seconds` or `max_staleness`, ensuring the replica remains up-to-date with the source data."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4