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

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • None
    • 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

              Unassigned Unassigned
              nishantbangarwa Nishant Bangarwa
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: