amrishlal opened a new issue #7560:
URL: https://github.com/apache/pinot/issues/7560


   The query `SELECT count(DISTINCT name, score) FROM scores` produces wrong 
results. This happens happens because all arguments except the first one are 
ignored while constructing DISTINCTCOUNT Function in 
`AggregationFunctionFactory.java`.
   
   One way to fix this is to using CONCAT function to contact all arguments 
into a single argument before creating the DISTINCTCOUNT function. Does this 
sound good? If so I will go ahead and put this in a PR. Any other suggestions?
   
   ```
   diff --git 
a/pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/AggregationFunctionFactory.java
 
b/pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/AggregationFunctionFactory.java
   index 328560739d..b9e78fe098 100644
   --- 
a/pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/AggregationFunctionFactory.java
   +++ 
b/pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/AggregationFunctionFactory.java
   @@ -159,7 +159,13 @@ public class AggregationFunctionFactory {
              case MINMAXRANGE:
                return new MinMaxRangeAggregationFunction(firstArgument);
              case DISTINCTCOUNT:
   -            return new DistinctCountAggregationFunction(firstArgument);
   +            if (arguments.size() == 1) {
   +              return new DistinctCountAggregationFunction(firstArgument);
   +            }
   +
   +            arguments.add(ExpressionContext.forLiteral(""));
   +            return new DistinctCountAggregationFunction(ExpressionContext
   +                .forFunction(new 
FunctionContext(FunctionContext.Type.TRANSFORM, "CONCAT", arguments)));
              case DISTINCTCOUNTBITMAP:
                return new 
DistinctCountBitmapAggregationFunction(firstArgument);
              case SEGMENTPARTITIONEDDISTINCTCOUNT:
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to