siddharthteotia commented on a change in pull request #4535: Implement DISTINCT 
clause
URL: https://github.com/apache/incubator-pinot/pull/4535#discussion_r320624968
 
 

 ##########
 File path: 
pinot-common/src/main/java/org/apache/pinot/pql/parsers/PinotQuery2BrokerRequestConverter.java
 ##########
 @@ -223,38 +226,65 @@ 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(FunctionCallAstNode.DISTINCT_FUNCTION_NAME)) {
+      // DISTINCT can support multiple arguments
+      if (operands.size() == 1) {
+        // single column DISTINCT
+        columnName = getColumnExpression(operands.get(0));
+      } else {
+        // multi column DISTINCT
+        final StringBuilder sb = new StringBuilder();
+        for (int i = 0; i < operands.size() ; ++i) {
+          Expression expression = operands.get(i);
+          sb.append(getColumnExpression(expression));
+          if (i <= operands.size() - 2) {
 
 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

Reply via email to