morrySnow commented on code in PR #11374:
URL: https://github.com/apache/doris/pull/11374#discussion_r934121610
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindSlotReference.java:
##########
@@ -282,6 +282,10 @@ public BoundStar(List<Slot> children) {
);
}
+ public String toSql() {
+ return
children.stream().map(Expression::toSql).collect(Collectors.joining(","));
Review Comment:
nit:
```suggestion
return
children.stream().map(Expression::toSql).collect(Collectors.joining(", "));
```
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindFunction.java:
##########
@@ -90,6 +93,24 @@ public Expression visitUnboundFunction(UnboundFunction
unboundFunction, Void con
return unboundFunction;
}
return new Sum(unboundFunction.getArguments().get(0));
+ } else if (name.equalsIgnoreCase("count")) {
+ List<Expression> arguments = unboundFunction.getArguments();
+ if (arguments.size() != 1) {
+ return unboundFunction;
+ }
+ return new Count(unboundFunction.getArguments().get(0));
Review Comment:
could we handle count(*) and count(1) now?
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/Avg.java:
##########
@@ -0,0 +1,56 @@
+// 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.trees.expressions.functions;
+
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.UnaryExpression;
+import org.apache.doris.nereids.types.DataType;
+import org.apache.doris.nereids.types.DoubleType;
+
+import com.google.common.base.Preconditions;
+
+import java.util.List;
+
+/** avg agg function. */
+public class Avg extends AggregateFunction implements UnaryExpression {
+
+ public Avg(Expression child) {
+ super("avg", child);
+ }
+
+ @Override
+ public DataType getDataType() {
+ return DoubleType.INSTANCE;
+ }
+
+ @Override
+ public boolean nullable() {
+ return child().nullable();
+ }
+
+ @Override
+ public Expression withChildren(List<Expression> children) {
+ Preconditions.checkArgument(children.size() == 1);
+ return new Avg(children.get(0));
+ }
+
+ @Override
+ public DataType getIntermediateType() {
+ return getDataType();
Review Comment:
avg's IntermediateType is not consistent with Function data type
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]