Queries the status of a materialized view to determine whether it is valid and view changes to the source table.
Materialized view states
A materialized view is either valid or invalid:
| State | Query behavior |
|---|---|
| Valid | MaxCompute reads data directly from the materialized view. Query acceleration takes effect. |
| Invalid | MaxCompute falls back to reading from the source table. Query acceleration does not take effect. |
Check validity
Syntax
Boolean materialized_view_is_valid(<mv_name>, <partition>);Return value
true: the materialized view data is consistent with the source table.false: the materialized view data is out of sync. Query acceleration is not active.
Parameters
| Parameter | Required | Description |
|---|---|---|
<mv_name> | Yes | Name of the materialized view, enclosed in double quotes. |
<partition> | No | Partition value. For level-2 partitions, pass values for each partition level as separate arguments. |
Examples
Check a non-partitioned materialized view:
SELECT materialized_view_is_valid("mf_mv_refresh4");Check a specific partition:
-- Level-1 partition
SELECT materialized_view_is_valid("mf_mv_refresh_pts", "20220810");
-- Level-2 partition
SELECT materialized_view_is_valid("mf_mv_refresh_pts_part", "20220810", "beijing");What's next
CREATE MATERIALIZED VIEW: create a materialized view that supports clustering or partitioning.
ALTER MATERIALIZED VIEW: update a materialized view, manage its lifecycle, or drop partitions.
DESC TABLE/VIEW: view materialized view details in a MaxCompute project.
DROP MATERIALIZED VIEW: drop an existing materialized view.