You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/06/20 13:07:00 UTC

[GitHub] [doris] EmmyMiao87 commented on a diff in pull request #10227: [feature](nereids) Add ssb related expressions and PlanNode

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


##########
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 {
+
+    private final List<? extends NamedExpression> groupByExpressions;
+    private final List<? extends NamedExpression> aggExpressions;
+
+    /**
+     * Desc: Constructor for LogicalAggregation.
+     */
+    public LogicalAggregation(List<? extends NamedExpression> groupByExpressions,
+            List<? extends NamedExpression> aggExpressions) {
+        super(OperatorType.LOGICAL_AGGREGATION);
+        this.groupByExpressions = Objects.requireNonNull(groupByExpressions, "groupByExpressions can not be null");

Review Comment:
   Both group by and agg can be null respectively.
   for example
   ```
   select sum(a) from test
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/operators/OperatorType.java:
##########
@@ -35,6 +35,8 @@ public enum OperatorType {
     LOGICAL_FILTER,
     LOGICAL_JOIN,
     PLACE_HOLDER,

Review Comment:
   Put PLACE_HOLDER in the end



##########
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 {
+
+    private final List<? extends NamedExpression> groupByExpressions;

Review Comment:
   Both group by columns and agg columns may be functioncalls. So I think the list generic here should be expression more appropriate.
   ```
   select k1+k1 from test_join group by k1+k1;
   ```



##########
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 {
+
+    private final List<? extends NamedExpression> groupByExpressions;
+    private final List<? extends NamedExpression> aggExpressions;
+
+    /**
+     * Desc: Constructor for LogicalAggregation.
+     */
+    public LogicalAggregation(List<? extends NamedExpression> groupByExpressions,
+            List<? extends NamedExpression> aggExpressions) {
+        super(OperatorType.LOGICAL_AGGREGATION);
+        this.groupByExpressions = Objects.requireNonNull(groupByExpressions, "groupByExpressions can not be null");
+        this.aggExpressions = aggExpressions;
+    }
+
+    /**
+     * Get GroupByAggregation list.
+     *
+     * @return all group by of this node.
+     */
+    public List<? extends NamedExpression> getGroupByExpressions() {
+        return groupByExpressions;
+    }
+
+    /**
+     * Get AggExpressions list.
+     *
+     * @return all agg expressions.
+     */
+    public List<? extends NamedExpression> getAggExpressions() {
+        return aggExpressions;
+    }
+
+    @Override
+    public String toString() {
+        return "Aggregation (" + StringUtils.join(groupByExpressions, ", ")
+                + StringUtils.join(aggExpressions, ", ") + ")";
+    }
+
+    @Override
+    public List<Slot> computeOutput(Plan input) {
+        return aggExpressions.stream()

Review Comment:
   Output should be the agg expr + group by expr



-- 
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-unsubscribe@doris.apache.org

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


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