Refreshing Analytical Views

To ensure valid results with analytical views, perform the following tasks.

Check Analytical View State

Check the state of an analytical view by running the following command:

show analytical views;

If the state of the views is either STALE or UNUSABLE, refresh the analytical views. There are several options, depending on your business requirements:

If the state of the analytical view is INVALID, recreate the analytical view after correcting its definition.

Here is an example of this command:

create analytical view analytical-view-name
  stored as parquet
  as (select   count(*), platform, sdk_version
      from     base-table-name
      group by platform, sdk_version);

Refresh Analytical Views in all Databases

The following command refreshes all analytical views, across all databases:

refresh all analytical views;

Refresh all Analytical Views in a Specific Database

To refresh all analytical views in a specific database, use the following commands:

use database-name;
refresh analytical views like '*';

Note that using the wildcard, *, matches everything. Don't forget the single quotes.

Refresh a Single Analytical View

The following command refreshes a specific analytical view in the current database:

refresh analytical view analytical-view-name;

Alternatively, this command refreshes an analytical in a specific database, while connected to any database:

refresh analytical view database-name.analytical-view-name;

Refresh Matching Analytical Views in a Specified Database

The following commands use a specific database to refresh analytical views that match the string_value parameter.

use database-name;
refresh analytical views like 'string_value';

The string_value parameter can match a number of file-naming protocols: 'event', 'my-custom-av-prefix', 'cyber-crime-diagnostics-and-prevention', and so on. Don't forget the single quotes.