For the complete documentation index, see llms.txt. This page is also available as Markdown.

DISTINCTCOUNTHLLPLUS

This section contains reference documentation for the DISTINCTCOUNTHLLPLUS function.

Returns an approximate distinct count using HyperLogLogPlusPlus. It also takes an optional second and third arguments to configure the p, sp for the HyperLogLogPlus. The optional parameter p defines the normal set precision and the parameter sp defines the sparse set precision. When set, sp must be at most 25; a larger value is rejected because the sparse encoding would corrupt the registers once the sketch converts to the normal format. For accurate distinct counting, see DISTINCTCOUNT.

Signature

DISTINCTCOUNTHLLPlus(colName) DISTINCTCOUNTHLLPlus(colName, p) DISTINCTCOUNTHLLPlus(colName, p, sp)

Usage Examples

These examples are based on the Batch Quick Start.

select DISTINCTCOUNTHLLPLUS(teamID) AS value
from baseballStats 
value

158

select DISTINCTCOUNTHLLPLUS(teamID, 12) AS value
from baseballStats 
value

149

DISTINCTCOUNTSMARTHLLPLUS

DISTINCTCOUNTSMARTHLLPLUS starts with exact distinct counting in a set and switches to HyperLogLog++ when the number of distinct values exceeds a threshold. This is useful when some groups stay small enough for exact counting while larger groups still need bounded memory usage.

Signature

DISTINCTCOUNTSMARTHLLPLUS(colName) DISTINCTCOUNTSMARTHLLPLUS(colName, 'threshold=;p=

;sp=')

Parameters

  • colName (required): Column to aggregate.

  • threshold (optional): Number of distinct values Pinot keeps exactly before converting to HLL++. Default: 100000. A non-positive value disables the conversion.

  • p (optional): HyperLogLog++ normal precision after conversion. Default: 14.

  • sp (optional): HyperLogLog++ sparse precision after conversion. Default: 0. When set, must be at most 25.

Usage Examples

Last updated

Was this helpful?