Skip to main content
An aggregate function. Merges one or more Apache DataSketches HLL sketches that were built using the aggregate function APACHE_DATASKETCHES_HLL_BUILD into a new sketch. In order to get correct results each sketch must be built on the same <expression> datatype. Attempts to merge sketches for different datatypes will NOT result in an error, and it’s the user responsibility to merge skeches with the same datatype only. For example, you can merge a sketch built from INTEGER data with one built from TEXT data but the estimated cardinality will be incorrect. If sketches are with different hll precision and hll type the merged sketch will be built with lowest precision and type of all inputs. For example, you can merge a sketch built with precision 13 and a sketch built with precision 14 and the result precision will be 13.

Syntax

Parameters

Return Type

BYTEA

Error Handling

If the input expression is not a valid Apache DataSketches HLL sketches, the function will raise an error. Ensure that the input is correctly formatted and generated by the APACHE_DATASKETCHES_HLL_BUILD function. The sketch is validated before it is read. A sketch whose header fields disagree with its contents (coupon counts, the exception table, the minimum register value and its count) is rejected with Invalid Apache DataSketches HLL sketch: <reason>. This includes a sketch written by another implementation that stores those fields differently.

Example

Following the example in APACHE_DATASKETCHES_HLL_BUILD: