Skip to main content
Accumulates values into a HyperLogLog sketch and returns the serialized sketch as a VARBINARY. This function is part of the DataSketches HLL family of functions for approximate distinct counting. ds_hll_accumulate creates a serialized HyperLogLog sketch that can be combined with other sketches using ds_hll_combine and estimated using ds_hll_estimate. It is based on Apache DataSketches and provides high precision for approximate distinct counting. For more information, see HyperLogLog Sketches.

Syntax

Parameters

  • expr: The expression to accumulate into the sketch. Can be any data type.
  • log_k: Integer. Range [4, 21]. Default: 17. Controls the precision and memory usage of the sketch.
  • tgt_type: Valid values are HLL_4, HLL_6 (default) and HLL_8. Controls the target type of the HyperLogLog sketch.

Return Type

Returns a VARBINARY containing the serialized HyperLogLog sketch.

Examples

  • ds_hll_combine: Combines multiple serialized sketches into a single sketch
  • ds_hll_estimate: Estimates the distinct count from a serialized sketch
  • ds_hll_count_distinct: Direct approximate distinct counting function

Keywords

ds_HLL_ACCUMULATE, HLL, HYPERLOGLOG, APPROXIMATE, DISTINCT, COUNT