Aggregate Functions in Analytical Views

Arcadia Engine supports all Impala aggregate functions in Analytical Views, including APPX_MEDIAN(), AVG(), COUNT(), GROUP_CONCAT(), MAX(), MIN(), NDV(), SAMPLE(), STDDEV(), STDDEV_SAMP(), STDDEV_POP(), SUM(), VARIANCE(), VARIANCE_SAMP(), VARIANCE_POP(), VAR_SAMP(), and VAR_POP().

Analytical Views also support Arcadia's proprietary BOOLEAN_AND(), BOOLEAN_OR(), and GCDO(), as well as user-defined functions.

Enabling Aggregate Functions

To enable aggregate functions in the analytical view, simply add them to the 'select list' of the analytical view. Queries that contain these aggregate functions are automatically routed to the analytical view, provided they meet the necessary conditions.

Using Aggregate Functions in Analytical Views

The following steps demonstrate how to implement an aggregate that uses the ndv() function.

  1. Create an analytical view:
    create analytical view aview1 stored as parquet 
      as select name, ndv(event_id) from events group by name;
  2. Refresh the analytical view:
    refresh analytical view aview1;
  3. Check the query routing:
    explain select ndv(event_id) from events;
    'REWR :''SELECT ndv_bigint_finalize('_c1') 'ndv(event_id)' FROM default.aview1 aview1'