siddharthteotia commented on a change in pull request #4535: Implement DISTINCT clause URL: https://github.com/apache/incubator-pinot/pull/4535#discussion_r327248106
########## File path: pinot-common/src/main/java/org/apache/pinot/pql/parsers/PinotQuery2BrokerRequestConverter.java ########## @@ -223,38 +226,66 @@ private String standardizeFunction(Function functionCall) { private AggregationInfo buildAggregationInfo(Function function) { List<Expression> operands = function.getOperands(); - if (operands == null || operands.size() != 1) { - throw new Pql2CompilationException( - "Aggregation function" + function.getOperator() + " expects 1 argument. found: " + operands); + if (operands == null || operands.size() < 1) { + throw new Pql2CompilationException("Aggregation function expects non null argument"); } - String functionName = function.getOperator(); + String columnName; - if (functionName.equalsIgnoreCase("count")) { - columnName = "*"; + String functionName = function.getOperator(); + + if (functionName.equalsIgnoreCase(AggregationFunctionType.DISTINCT.getName())) { + // DISTINCT can support multiple arguments + if (operands.size() == 1) { + // single column DISTINCT + columnName = getColumnExpression(operands.get(0)); + } else { + // multi column DISTINCT + StringBuilder sb = new StringBuilder(); + int numOperands = operands.size(); + for (int i = 0; i < numOperands; ++i) { Review comment: Done ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org