Each individual element of the “fields” list can be a String or DimensionSpec. A String dimension in the fields list is equivalent to a DefaultDimensionSpec (no transformations).

    The HyperLogLog algorithm generates decimal estimates with some error. “round” can be set to true to round off estimated values to whole numbers. Note that even with rounding, the cardinality is still an estimate. The “round” field only affects query-time behavior, and is ignored at ingestion-time.

    When setting to false (the default) it computes the cardinality of the set composed of the union of all dimension values for all the given dimensions.

    • For a single dimension, this is equivalent to
    1. SELECT COUNT(DISTINCT(dimension)) FROM <datasource>
    • For multiple dimensions, this is equivalent to something akin to

    Cardinality by row

      Example

      Determine the number of distinct countries people are living in or have come from.

      Determine the number of distinct people (i.e. combinations of first and last name).

      1. "type": "cardinality",
      2. "name": "distinct_people",
      3. "fields": [ "first_name", "last_name" ],
      4. "byRow" : true
      5. }

      HyperUnique aggregator

      Uses to compute the estimated cardinality of a dimension that has been aggregated as a “hyperUnique” metric at indexing time.

      1. "type" : "hyperUnique",
      2. "name" : <output_name>,
      3. "fieldName" : <metric_name>,
      4. "isInputHyperUnique" : false,
      5. "round" : false

      “isInputHyperUnique” can be set to true to index precomputed HLL (Base64 encoded output from druid-hll is expected). The “isInputHyperUnique” field only affects ingestion-time behavior, and is ignored at query-time.

      The HyperLogLog algorithm generates decimal estimates with some error. “round” can be set to true to round off estimated values to whole numbers. Note that even with rounding, the cardinality is still an estimate. The “round” field only affects query-time behavior, and is ignored at ingestion-time.