Apache Pinot Docs

Searchâ€¦

latest

For Users

For Developers

For Operators

Configuration Reference

Aggregation Functions

Function

Description

Example

Default Value When No Record Selected

Calculate the histogram of a numeric column as

`Double[]`

`HISTOGRAM(numberOfGames,0,200,10)`

`0, 0, ..., 0`

Returns the minimum value of a numeric column as

`Double`

`MIN(playerScore)`

`Double.POSITIVE_INFINITY`

Returns the maximum value of a numeric column as

`Double`

`MAX(playerScore)`

`Double.NEGATIVE_INFINITY`

Returns the sum of the values for a numeric column with optional precision and scale as

`BigDecimal`

`SUMPRECISION(salary), SUMPRECISION(salary, precision, scale)`

`0.0`

Returns the average of the values for a numeric column as

`Double`

`AVG(playerScore)`

`Double.NEGATIVE_INFINITY`

Returns the most frequent value of a numeric column as

`Double`

. When multiple modes are present it gives the minimum of all the modes. This behavior can be overridden to get the maximum or the average mode.`MODE(playerScore)`

`MODE(playerScore, 'MIN')`

`MODE(playerScore, 'MAX')`

`MODE(playerScore, 'AVG')`

`Double.NEGATIVE_INFINITY`

Returns the

`max - min`

value for a numeric column as `Double`

`MINMAXRANGE(playerScore)`

`Double.NEGATIVE_INFINITY`

Returns the Nth percentile of the values for a numeric column as

`Double`

. N is a decimal number between 0 and 100 inclusive.`PERCENTILE(playerScore, 50) PERCENTILE(playerScore, 99.9)`

`Double.NEGATIVE_INFINITY`

`PERCENTILEEST(playerScore, 50)`

`PERCENTILEEST(playerScore, 99.9)`

`Long.MIN_VALUE`

`PERCENTILETDIGEST(playerScore, 50)`

`PERCENTILETDIGEST(playerScore, 99.9)`

`Double.NaN`

PERCENTILESMARTTDIGEST

Returns the Nth percentile of the values for a numeric column as *TDigest*. The switch *TDigest* can be configured via the optional second argument.

`Double`

. When there are too many values, automatically switch to approximate percentile using `threshold`

(100_000 by default) and `compression`

(100 by default) for the `PERCENTILESMARTTDIGEST(playerScore, 50)`

`PERCENTILESMARTTDIGEST(playerScore, 99.9, 'threshold=100;compression=50)`

`Double.NEGATIVE_INFINITY`

Returns the count of distinct values of a column as

`Integer`

`DISTINCTCOUNT(playerName)`

`0`

Returns the count of distinct values of a column as *INT* column, but approximate for other cases where hash codes are used in distinct counting and there may be hash collisions.

`Integer`

. This function is accurate for `DISTINCTCOUNTBITMAP(playerName)`

`0`

Returns an approximate distinct count using *HyperLogLog as* *HyperLogLog*.

`Long`

. It also takes an optional second argument to configure the `log2m`

for the `DISTINCTCOUNTHLL(playerName, 12)`

`0`

Returns *HyperLogLog* response serialized as

`String`

. The serialized HLL can be converted back into an HLL and then aggregated with other HLLs. A common use case may be to merge HLL responses from different Pinot tables, or to allow aggregation after client-side batching.`DISTINCTCOUNTRAWHLL(playerName)`

`0`

DISTINCTCOUNTSMARTHLL

Returns the count of distinct values of a column as *HyperLogLog*. The switch *HyperLogLog* can be configured via the optional second argument.

`Integer`

. When there are too many distinct values, automatically switch to approximate distinct count using `threshold`

(100_000 by default) and `log2m`

(12 by default) for the `DISTINCTCOUNTSMARTHLL(playerName),`

`DISTINCTCOUNTSMARTHLL(playerName, 'threshold=100;log2m=8')`

`0`

Returns the count of distinct values of a column as

`Long`

when the column is pre-partitioned for each segment, where there is no common value within different segments. This function calculates the exact count of distinct values within the segment, then simply sums up the results from different segments to get the final result.`SEGMENTPARTITIONEDDISTINCTCOUNT(playerName)`

`0`

Get the last value of **dataColumn** where the **timeColumn** is used to define the time of dataColumn and the **dataType** specifies the type of dataColumn, which can be

`BOOLEAN`

, `INT`

, `LONG`

, `FLOAT`

, `DOUBLE`

, `STRING`

`LASTWITHTIME(playerScore, timestampColumn, 'BOOLEAN')`

`LASTWITHTIME(playerScore, timestampColumn, 'INT')`

`LASTWITHTIME(playerScore, timestampColumn, 'LONG')`

`LASTWITHTIME(playerScore, timestampColumn, 'FLOAT')`

`LASTWITHTIME(playerScore, timestampColumn, 'DOUBLE')`

`LASTWITHTIME(playerScore, timestampColumn, 'STRING')`

`INT: Int.MIN_VALUE LONG: Long.MIN_VALUE FLOAT: Float.NaN DOUBLE: Double.NaN STRING: ""`

Get the first value of **dataColumn** where the **timeColumn** is used to define the time of dataColumn and the **dataType** specifies the type of dataColumn, which can be

`BOOLEAN`

, `INT`

, `LONG`

, `FLOAT`

, `DOUBLE`

, `STRING`

`FIRSTWITHTIME(playerScore, timestampColumn, 'BOOLEAN')`

`FIRSTWITHTIME(playerScore, timestampColumn, 'INT')`

`FIRSTWITHTIME(playerScore, timestampColumn, 'LONG')`

`FIRSTWITHTIME(playerScore, timestampColumn, 'FLOAT')`

`FIRSTWITHTIME(playerScore, timestampColumn, 'DOUBLE')`

`FIRSTWITHTIME(playerScore, timestampColumn, 'STRING')`

`INT: Int.MIN_VALUE LONG: Long.MIN_VALUE FLOAT: Float.NaN DOUBLE: Double.NaN STRING: ""`

Deprecated functions:

Function

Description

Example

FASTHLL stores serialized HyperLogLog in String format, which performs worse than DISTINCTCOUNTHLL, which supports serialized HyperLogLog in BYTES (byte array) format

`FASTHLL(playerName)`

Multi-value column functions

The following aggregation functions can be used for multi-value columns

Function

â€‹**PERCENTILEMV(column, N)**
Returns the Nth percentile of the values for a numeric multi-value column as

`Double`

â€‹**DISTINCTCOUNTBITMAPMV**
Returns the count of distinct values for a multi-value column as

`Integer`

. This function is accurate for INT or dictionary encoded column, but approximate for other cases where hash codes are used in distinct counting and there may be hash collision.â€‹**DISTINCTCOUNTRAWHLLMV**
Returns *HyperLogLog* response serialized as string. The serialized HLL can be converted back into an HLL and then aggregated with other HLLs. A common use case may be to merge HLL responses from different Pinot tables, or to allow aggregation after client-side batching.

Deprecated functions:

Function

Description

Example

stores serialized HyperLogLog in String format, which performs worse than DISTINCTCOUNTHLL, which supports serialized HyperLogLog in BYTES (byte array) format

`FASTHLLMV(playerNames)`

Last modified 3mo ago

Copy link

Edit on GitHub