Plutooooooo commented on a change in pull request #4517:
URL: https://github.com/apache/iotdb/pull/4517#discussion_r766308844



##########
File path: server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
##########
@@ -2456,14 +2465,18 @@ public void 
parseSelectClause(IoTDBSqlParser.SelectClauseContext ctx) {
     boolean isFirstElement = true;
     for (IoTDBSqlParser.ResultColumnContext resultColumnContext : 
ctx.resultColumn()) {
       selectComponent.addResultColumn(parseResultColumn(resultColumnContext));
-      // judge query type according to the first select element
-      if (!hasDecidedQueryType()) {
-        if (selectComponent.hasAggregationFunction()) {
-          queryOp = new AggregationQueryOperator(queryOp);
-        } else if (selectComponent.hasTimeSeriesGeneratingFunction()) {
-          queryOp = new UDFQueryOperator(queryOp);
-        }
+    }
+
+    if (!hasDecidedQueryType()) {
+      if (selectComponent.hasUserDefinedAggregationFunction()) {
+        queryOp = new UDAFQueryOperator(new AggregationQueryOperator(queryOp));
+      } else if (selectComponent.hasAggregationFunction()) {
+        queryOp = new AggregationQueryOperator(queryOp);
+      } else if (selectComponent.hasTimeSeriesGeneratingFunction()) {
+        queryOp = new UDFQueryOperator(queryOp);
       }
+    } else if (selectComponent.hasUserDefinedAggregationFunction()) {
+      queryOp = new UDAFQueryOperator((AggregationQueryOperator) (queryOp));

Review comment:
       > ```
   > if (selectComponent.hasUserDefinedAggregationFunction()) {
   >     queryOp = new UDAFQueryOperator(new AggregationQueryOperator(queryOp));
   > }
   > ```
   > 
   > The statements in if branch and else branch are the same, we can extract 
them out. BTW, why should it be in the else branch?
   
   I've had the same doubt at first glance. It's probably the difference 
between 'select count(a), count(a)+1 from root.sg' and 'select count(a)+1, 
count(a) from root.sg'




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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to