Materialized view commands
Also available as:
PDF

ALTER MATERIALIZED VIEW REBUILD

You must rebuild the materialized view to keep it up-to-date when changes to the data occur.

Syntax

ALTER MATERIALIZED VIEW [db_name.]materialized_view_name REBUILD;
db_name.materialized_view_name
The database name followed by the name for the materialized view in dot notation.

Description

Hive performs view maintenance incrementally if possible, refreshing the view to reflect any data inserted into ACID tables. The rebuild operation preserves the low-latency analytical processing (LLAP) cache for existing data in the materialized view. Hive does a full rebuild if an incremental one is impossible.

Hive does not rewrite a query based on a stale materialized view automatically. If you want a rewrite of a stale or possibly stale materialized view, you can force a rewrite. For example, you might want to use the contents of a materialized view of a non-transactional table because Hive cannot determine the freshness of such a table. To enable rewriting of a query based on a stale materialized view, you can run the rebuild operation periodically and set the following property: hive.materializedview.rewriting.time.window. For example, SET hive.materializedview.rewriting.time.window=10min;

Example

ALTER MATERIALIZED VIEW mydb.mv1 REBUILD;