Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-1670

Count distinct on druid is translated to Cardinality aggregator which is approximate

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      Right now count distinct on Druid is translated as a 'cardinality' aggregator which uses hyperloglog and return approximate results. See cardinality aggregator here - http://druid.io/docs/latest/querying/aggregations.html for details.

      https://github.com/apache/calcite/blob/master/druid/src/main/java/org/apache/calcite/adapter/druid/DruidQuery.java#L721

       
      case COUNT:
            if (aggCall.isDistinct()) {
              return new JsonCardinalityAggregation("cardinality", name, list);
            }
            return new JsonAggregation("count", name, only);
      

      The current recommended way in druid to get exact counts is to do a nested groupby query.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                nishantbangarwa Nishant Bangarwa
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated: