Updated on 2024-10-09 GMT+08:00

Validity Period and Data Update of HetuEngine Materialized Views

Validity Period of Materialized Views

The mv_validity field for creating a materialized view indicates the validity period of the materialized view. HetuEngine allows you to rewrite the SQL statements using only the materialized views within the validity period.

Refreshing Materialized View Data

If data needs to be updated periodically, you can use either of the following methods to periodically refresh the materialized views:

  • Manually refreshing a materialized view

    Run the refresh materialized view <mv name> command on the HetuEngine client, or run the refresh materialized view <mv name> command using JDBC in the service program to manually update the database.

  • Automatically refreshing a materialized view
    1. To enable the automatic refresh capability of the materialized views, you must set a compute instance as the maintenance instance. For details, see Configuring a HetuEngine Maintenance Instance.
    2. Use create materialized view to create a materialized view that can be automatically refreshed.
      • If there are too many materialized views, some materialized views may expire due to too long waiting time.
      • The automatic refresh function does not automatically refresh materialized views in the disable status.

Automatically Refreshing Materialized Views When Querying External Hive Data Sources

By default, the maintenance instance uses the HetuEngine built-in user hetuserver/hadoop.<System domain name> for refreshing materialized views. When materialized view creation statements query external Hive data sources where authentication has been enabled, you need to change the user for automatically refreshing materialized views as follows:

  1. Check whether the HetuEngine service has been installed in the peer cluster.

    • If yes, go to 3.
    • If no, go to 2.

  2. Prepare the user used by the system for automated refresh.

    1. Create a human-machine user with the same name in both the local and peer clusters.

      Take mvuser as an example. In the peer cluster, add it to the supergroup user group. In the local cluster, add it to the supergroup and hive user groups and add the tenant role of the maintenance instance.

    2. (Optional) If Ranger authentication is enabled in the local cluster, grant the permission to refresh materialized views and set sessions permission to the mvuser user. For details, see Table 1 and Table 2.

  3. Log in to FusionInsight Manager as the HetuEngine administrator.
  4. Choose Cluster > Services > HetuEngine and click the Configurations tab and then All Configurations.
  5. Search for jobsystem.customized.properties, add a custom configuration named hetuserver.engine.jobsystem.inner.principal, and set its value according to the following content. Then, click Save and operate as prompted.

    • If the HetuEngine service has been installed in the peer cluster, set the value to hetuserver.
    • If the HetuEngine service is not installed in the peer cluster, set the value the user name created in 2.a.

  6. Click the Instance tab, select all HSBroker instances, click More, and select Restart Instance to restart the HSBroker instances as prompted.
  7. In the displayed Dashboard tab, find the Basic Information area, and click the link next to HSConsole WebUI. In the Compute Instance tab, locate the maintenance instance and click Restart in the Operation column and operate as prompted.

    Instances with the icon displayed next to their names are maintenance instances. You can also confirm the maintenance instance by referring to Configuring a HetuEngine Maintenance Instance.