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



##########
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:
       Isn't this really an aggregation group-by query (or at least needs to be 
executed like it)? If so, how does the aggregation actually work here? Will 
`QueryContextUtils.isAggregationQuery`  return true in this case?




----------------------------------------------------------------
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