Jackie-Jiang commented on a change in pull request #4535: Implement DISTINCT clause URL: https://github.com/apache/incubator-pinot/pull/4535#discussion_r319703822
########## File path: pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/FunctionCallAstNode.java ########## @@ -75,22 +83,52 @@ public String getExpression() { return _expression; } - public AggregationInfo buildAggregationInfo() { + AggregationInfo buildAggregationInfo() { String expression; // COUNT aggregation function always works on '*' - if (_name.equalsIgnoreCase("count")) { + if (_name.equalsIgnoreCase(COUNT_FUNCTION_NAME)) { expression = "*"; } else { List<? extends AstNode> children = getChildren(); - if (children == null || children.size() != 1) { - throw new Pql2CompilationException("Aggregation function expects exact 1 argument"); + if (children == null || children.size() < 1) { + throw new Pql2CompilationException("Aggregation function expects non-null argument"); + } + if (!_name.equalsIgnoreCase(DISTINCT_FUNCTION_NAME)) { + if (children.size() != 1) { + throw new Pql2CompilationException("Aggregation function expects exactly 1 argument as column name"); + } else { + expression = TransformExpressionTree.getStandardExpression(children.get(0)); + } + } else { + // DISTINCT + if (!Pql2Compiler.ENABLE_DISTINCT) { + throw new Pql2CompilationException("Support for DISTINCT is currently disabled"); + } + if (children.size() == 1) { Review comment: Same comments as in `PinotQuery2BrokerRequestConverter` ---------------------------------------------------------------- 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