npawar commented on a change in pull request #5635:
URL: https://github.com/apache/incubator-pinot/pull/5635#discussion_r446716774



##########
File path: 
pinot-common/src/main/java/org/apache/pinot/pql/parsers/PinotQuery2BrokerRequestConverter.java
##########
@@ -83,15 +83,30 @@ private void convertOrderBy(PinotQuery pinotQuery, 
BrokerRequest brokerRequest)
       return;
     }
     List<SelectionSort> sortSequenceList = new ArrayList<>();
+    List<AggregationInfo> aggregationInfoList = 
brokerRequest.getAggregationsInfo();
     final List<Expression> orderByList = pinotQuery.getOrderByList();
     for (Expression orderByExpr : orderByList) {
       SelectionSort selectionSort = new SelectionSort();
       //order by is always a function (ASC or DESC)
       Function functionCall = orderByExpr.getFunctionCall();
       
selectionSort.setIsAsc(functionCall.getOperator().equalsIgnoreCase(OrderByAstNode.ASCENDING_ORDER));
-      
selectionSort.setColumn(ParserUtils.standardizeExpression(functionCall.getOperands().get(0),
 true));
+      Expression expression = functionCall.getOperands().get(0);
+      selectionSort.setColumn(ParserUtils.standardizeExpression(expression, 
true));
       sortSequenceList.add(selectionSort);
+
+      if (expression.getType().equals(ExpressionType.FUNCTION) && 
FunctionDefinitionRegistry
+          .isAggFunc(expression.getFunctionCall().getOperator())) {
+        AggregationInfo aggInfo = 
buildAggregationInfo(expression.getFunctionCall());
+        if (aggregationInfoList == null) {
+          aggregationInfoList = new ArrayList<>();
+          aggregationInfoList.add(aggInfo);
+          brokerRequest.setAggregationsInfo(aggregationInfoList);
+        } else if (!aggregationInfoList.contains(aggInfo)) {

Review comment:
       @kishoreg  yes it works.
   @mayankshriv I've modified `QueryContextUtils.isAggregationQuery` also in 
same PR, and so it does return true. Yes it gets treated as a aggregation-group 
by query, and finally only the columns from the selection are returned




----------------------------------------------------------------
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:
[email protected]



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

Reply via email to