EmmyMiao87 commented on code in PR #10335: URL: https://github.com/apache/doris/pull/10335#discussion_r907119613
########## fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java: ########## @@ -180,7 +179,7 @@ public LogicalPlan visitQuery(QueryContext ctx) { } private LogicalPlan withQueryOrganization(QueryOrganizationContext ctx, LogicalPlan children) { - List<SortItems> sortItems = visitQueryOrganization(ctx); + List<OrderKey> sortItems = visitQueryOrganization(ctx); Review Comment: ```suggestion List<OrderKey> orderKeys = visitQueryOrganization(ctx); ``` ########## fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java: ########## @@ -368,8 +353,8 @@ public SortItems genSortItems(SortItemContext ctx) { * @param ctx QueryOrganizationContext * @return List of SortItems */ - public List<SortItems> visitQueryOrganization(QueryOrganizationContext ctx) { - List<SortItems> sortItems = new ArrayList<>(); + public List<OrderKey> visitQueryOrganization(QueryOrganizationContext ctx) { + List<OrderKey> sortItems = new ArrayList<>(); Review Comment: ```suggestion List<OrderKey> orderKeys = new ArrayList<>(); ``` ########## fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java: ########## @@ -351,15 +339,12 @@ private LogicalPlan withAggClause(List<NamedExpression> aggExpressions, * @param ctx SortItemContext * @return SortItems */ - public SortItems genSortItems(SortItemContext ctx) { - OrderDirection orderDirection; - if (ctx.DESC() != null) { - orderDirection = OrderDirection.DESC; - } else { - orderDirection = OrderDirection.ASC; - } + public OrderKey genSortItems(SortItemContext ctx) { Review Comment: ```suggestion public OrderKey genOrderKeys(SortItemContext ctx) { ``` ########## fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/LogicalHeapSortToPhysicalHeapSort.java: ########## @@ -0,0 +1,36 @@ +// 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.rules.implementation; + +import org.apache.doris.nereids.operators.plans.physical.PhysicalHeapSort; +import org.apache.doris.nereids.rules.Rule; +import org.apache.doris.nereids.rules.RuleType; +import org.apache.doris.nereids.trees.plans.Plan; + +/** + * Implementation rule that convert logical sort to physical sort. + */ +public class LogicalHeapSortToPhysicalHeapSort extends OneImplementationRuleFactory { Review Comment: ```suggestion public class LogicalSortToPhysicalHeapSort extends OneImplementationRuleFactory { ``` ########## fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalAggregation.java: ########## @@ -31,68 +32,70 @@ /** * Logical Aggregation plan operator. - * - *eg:select a, sum(b), c from table group by a, c; + * <p> + * eg:select a, sum(b), c from table group by a, c; * groupByExpressions: Column field after group by. eg: a, c; * outputExpressions: Column field after select. eg: a, sum(b), c; Review Comment: Please add the comments about `partitionExprList ` ########## fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/PhysicalPlanTranslator.java: ########## @@ -147,20 +148,20 @@ public PlanFragment visitPhysicalOlapScan( } @Override - public PlanFragment visitPhysicalSort(PhysicalUnaryPlan<PhysicalSort, Plan> sort, + public PlanFragment visitPhysicalSort(PhysicalUnaryPlan<PhysicalHeapSort, Plan> sort, PlanTranslatorContext context) { PlanFragment childFragment = visit(sort.child(0), context); - PhysicalSort physicalSort = sort.getOperator(); + PhysicalHeapSort physicalHeapSort = sort.getOperator(); if (!childFragment.isPartitioned()) { Review Comment: Why doesn't the sort node translate if the childfragment is a single instance? ########## fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalAggregation.java: ########## @@ -88,10 +89,7 @@ public <R, C> R accept(PlanOperatorVisitor<R, C> visitor, Plan plan, C context) @Override public List<Expression> getExpressions() { - return new ImmutableList.Builder<Expression>() - .addAll(groupByExprList) - .addAll(aggExprList) - .addAll(partitionExprList) - .build(); + return new ImmutableList.Builder<Expression>().addAll(groupByExprList).addAll(outputExpressionList) + .addAll(partitionExprList).build(); Review Comment: partitionExprList maybe null ########## fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalAggregation.java: ########## @@ -31,68 +32,70 @@ /** * Logical Aggregation plan operator. - * - *eg:select a, sum(b), c from table group by a, c; + * <p> + * eg:select a, sum(b), c from table group by a, c; * groupByExpressions: Column field after group by. eg: a, c; * outputExpressions: Column field after select. eg: a, sum(b), c; - * + * <p> * Each agg node only contains the select statement field of the same layer, * and other agg nodes in the subquery contain. */ public class LogicalAggregation extends LogicalUnaryOperator { - private final List<Expression> groupByExpressions; - private final List<? extends NamedExpression> outputExpressions; + private final List<Expression> groupByExprList; + private final List<NamedExpression> outputExpressionList; + private List<Expression> partitionExprList; + + private AggPhase aggPhase; /** * Desc: Constructor for LogicalAggregation. */ - public LogicalAggregation(List<Expression> groupByExpressions, - List<? extends NamedExpression> outputExpressions) { + public LogicalAggregation(List<Expression> groupByExprList, List<NamedExpression> outputExpressionList) { super(OperatorType.LOGICAL_AGGREGATION); - this.groupByExpressions = groupByExpressions; - this.outputExpressions = outputExpressions; + this.groupByExprList = groupByExprList; + this.outputExpressionList = outputExpressionList; } - /** - * Get GroupByAggregation list. - * - * @return all group by of this node. - */ - public List<Expression> getGroupByExpressions() { - return groupByExpressions; + public List<Expression> getPartitionExprList() { + return partitionExprList; Review Comment: ```suggestion return partitionExprList == null ? groupByExprList : partitionExprList; ``` -- 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