EmmyMiao87 commented on code in PR #10227:
URL: https://github.com/apache/doris/pull/10227#discussion_r901653625


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalAggregation.java:
##########
@@ -0,0 +1,86 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.nereids.operators.plans.logical;
+
+import org.apache.doris.nereids.exceptions.UnboundException;
+import org.apache.doris.nereids.operators.OperatorType;
+import org.apache.doris.nereids.trees.expressions.NamedExpression;
+import org.apache.doris.nereids.trees.expressions.Slot;
+import org.apache.doris.nereids.trees.plans.Plan;
+
+import com.google.common.collect.ImmutableList;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * Logical Aggregation plan operator.
+ */
+public class LogicalAggregation extends LogicalUnaryOperator {

Review Comment:
   In the comments, please explain the meaning of each attribute directly, and 
give an example in combination with the real sql statement.



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalSort.java:
##########
@@ -0,0 +1,101 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.nereids.operators.plans.logical;
+
+import org.apache.doris.nereids.operators.OperatorType;
+import org.apache.doris.nereids.trees.expressions.NamedExpression;
+import org.apache.doris.nereids.trees.expressions.Slot;
+import org.apache.doris.nereids.trees.plans.Plan;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.List;
+import java.util.Objects;
+
+/**
+    Logical Sort plan operator.
+ */

Review Comment:
   Please update commit as above ~



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java:
##########
@@ -278,6 +318,64 @@ last, plan(join.relationPrimary())
         return last;
     }
 
+    private LogicalPlan withAggClause(List<NamedExpression> aggExpressions,
+            GroupByItemContext ctx, LogicalPlan aggClause) {
+        List<Expression> tmpExpressions = new ArrayList<>();
+        for (ExpressionContext expressionCtx : ctx.expression()) {
+            tmpExpressions.add(typedVisit(expressionCtx));
+        }
+        List<NamedExpression> groupByExpressions = 
tmpExpressions.stream().map(expression -> {
+            if (expression instanceof NamedExpression) {
+                return (NamedExpression) expression;
+            } else {
+                return new UnboundAlias(expression);
+            }
+        }).collect(Collectors.toList());
+        return new LogicalUnaryPlan(new LogicalAggregation(groupByExpressions, 
aggExpressions), aggClause);
+    }
+
+    /**
+     * Generate sortItems.
+     *
+     * @param ctx SortItemContext
+     * @return SortItems
+     */
+    public SortItems genSortItems(SortItemContext ctx) {
+        OrderDirection orderDirection;
+        if (ctx.DESC() != null) {
+            orderDirection = OrderDirection.DESC;
+        } else {
+            orderDirection = OrderDirection.ASC;
+        }
+        Expression expression = typedVisit(ctx.expression());
+        NamedExpression namedExpression;
+        if (expression instanceof NamedExpression) {

Review Comment:
   Why convert all expr to namedexpr? Is there any special purpose?
   I give an example
   ```
   select a.k1+a.k2 from a order by 1
   ```
   then the original sort item should be intliteral(1)
   



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to