Check the status of a materialized view to detect changes in its source table and ensure that the view is valid.
Background
A materialized view can be in one of the following two states:
Valid
When you run a query, MaxCompute reads data directly from the materialized view instead of the source table.
Invalid
When you run a query, MaxCompute cannot read data directly from the materialized view. It reads data from the source table instead, which prevents query acceleration.
Query materialized view status
Use the following function to check whether the data in a materialized view is valid.
Syntax
Boolean materialized_view_is_valid(<mv_name>,<partition>);Examples
This function returns
trueif the data inmf_mv_refresh4is consistent with the latest data in the source table; otherwise, it returnsfalse.SELECT materialized_view_is_valid("mf_mv_refresh4");--Specify partition values. SELECT materialized_view_is_valid("mf_mv_refresh_pts","20220810","beijing"); --Specify level-2 partition values. SELECT materialized_view_is_valid("mf_mv_refresh_pts_part","20220810","beijing");
Related commands
CREATE MATERIALIZED VIEW: Creates a materialized view and supports partitioning and clustering.
ALTER MATERIALIZED VIEW: Updates a materialized view, manages its lifecycle, or drops its partitions.
DESC TABLE/VIEW: Displays information about a MaxCompute materialized view.
DROP MATERIALIZED VIEW: Drops a materialized view.