ALTER MATERIALIZED VIEW REBUILD
You must rebuild the materialized view to keep it up-to-date when changes to the data occur.
ALTER MATERIALIZED VIEW [db_name.]materialized_view_name REBUILD;
- The database name followed by the name of the materialized view in dot notation.
View maintenance occurs incrementally, if possible. The refresh reflects any data inserted into ACID tables (full ACID or insert-only). If your materialized view groups results, you must use a full ACID table to rebuild incrementally. Hive does a full rebuild if an incremental one is impossible.
A rewrite of a query based on a stale materialized view does not occur 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 the freshness of such a table is unknown. 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,
ALTER MATERIALIZED VIEW mydb.mv1 REBUILD;