Queries the status of a materialized view. This operation allows you to view changes to the source table and determines whether the materialized view is valid.

Background information

A materialized view can be in one of the following states:
  • Valid

    When you execute a query statement, MaxCompute queries data from the materialized view instead of querying data from the source table.

  • Invalid

    When you execute a query statement, MaxCompute cannot directly query data from the materialized view. In this case, MaxCompute queries data from the source table. As a result, the query speed is not accelerated.

Query the status of a materialized view

You can use a function to check whether data in a materialized view is valid.
  • Syntax
    Boolean materialized_view_is_valid(<mv_name>,<partition>);
  • Examples
    Check whether data in the materialized view mf_mv_refresh4 is consistent with data in the source table. If the data is consistent, true is returned. Otherwise, false is returned.
    • select materialized_view_is_valid("mf_mv_refresh4");
    • select materialized_view_is_valid("mf_mv_refresh_pts","ds ='20220810'");

Related statements

  • CREATE MATERIALIZED VIEW: Creates a materialized view that supports clustering or partitioning based on the data for materialized view scenarios.
  • ALTER MATERIALIZED VIEW: Updates a materialized view, modifies the lifecycle of a materialized view, enables or disables the lifecycle of a materialized view, or deletes partitions of a materialized view.
  • DESC TABLE/VIEW: Views the information of a MaxCompute materialized view.
  • DROP MATERIALIZED VIEW: Drops an existing materialized view.