924060929 commented on code in PR #14496: URL: https://github.com/apache/doris/pull/14496#discussion_r1031046945
########## fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/If.java: ########## @@ -90,27 +88,30 @@ public class If extends ScalarFunction .args(BooleanType.INSTANCE, StringType.INSTANCE, StringType.INSTANCE) ); - private final Supplier<DataType> widerType = Suppliers.memoize(() -> { - List<AbstractDataType> argumentsTypes = getSignature().argumentsTypes; - Type assignmentCompatibleType = ScalarType.getAssignmentCompatibleType( - argumentsTypes.get(1).toCatalogDataType(), - argumentsTypes.get(2).toCatalogDataType(), - true); - return DataType.fromCatalogType(assignmentCompatibleType); - }); - /** * constructor with 3 arguments. */ public If(Expression arg0, Expression arg1, Expression arg2) { super("if", arg0, arg1, arg2); } + private DataType getWiderType(List<AbstractDataType> argumentsTypes) { + Type assignmentCompatibleType = ScalarType.getAssignmentCompatibleType( + argumentsTypes.get(1).toCatalogDataType(), + argumentsTypes.get(2).toCatalogDataType(), + true); + return DataType.fromCatalogType(assignmentCompatibleType); + } + @Override protected FunctionSignature computeSignature(FunctionSignature signature, List<Expression> arguments) { - DataType widerType = this.widerType.get(); - signature = signature.withArgumentTypes(arguments, (sigType, argType) -> widerType) - .withReturnType(widerType); + DataType widerType = getWiderType(signature.argumentsTypes); + List<AbstractDataType> newArgumentsTypes = new ImmutableList.Builder<AbstractDataType>() + .add(signature.argumentsTypes.get(0)) + .add(widerType) + .add(widerType) + .build(); + signature = signature.withArgumentTypes(signature.hasVarArgs, newArgumentsTypes); Review Comment: missing set return type? ########## fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalRepeat.java: ########## @@ -0,0 +1,171 @@ +// 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.plans.physical; + +import org.apache.doris.nereids.memo.GroupExpression; +import org.apache.doris.nereids.properties.LogicalProperties; +import org.apache.doris.nereids.properties.PhysicalProperties; +import org.apache.doris.nereids.trees.expressions.Expression; +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.doris.nereids.trees.plans.PlanType; +import org.apache.doris.nereids.trees.plans.algebra.Repeat; +import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor; +import org.apache.doris.nereids.util.ExpressionUtils; +import org.apache.doris.nereids.util.Utils; +import org.apache.doris.statistics.StatsDeriveResult; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * PhysicalRepeat. + */ +public class PhysicalRepeat<CHILD_TYPE extends Plan> extends PhysicalUnary<CHILD_TYPE> + implements Repeat<CHILD_TYPE> { + + private final List<List<Expression>> groupingSets; + private final List<NamedExpression> outputExpressions; + + /** + * Desc: Constructor for PhysicalRepeat. + */ + public PhysicalRepeat( + List<List<Expression>> groupingSets, + List<NamedExpression> outputExpressions, + LogicalProperties logicalProperties, + CHILD_TYPE child) { + super(PlanType.PHYSICAL_REPEAT, logicalProperties, child); + this.groupingSets = Objects.requireNonNull(groupingSets, "groupingSets can not be null") + .stream() + .map(groupingSet -> ImmutableList.copyOf(groupingSet)) + .collect(ImmutableList.toImmutableList()); + this.outputExpressions = ImmutableList.copyOf( + Objects.requireNonNull(outputExpressions, "outputExpressions can not be null")); + } + + /** + * Desc: Constructor for PhysicalRepeat. + */ + public PhysicalRepeat(List<List<Expression>> groupingSets, List<NamedExpression> outputExpressions, + Optional<GroupExpression> groupExpression, LogicalProperties logicalProperties, + PhysicalProperties physicalProperties, StatsDeriveResult statsDeriveResult, CHILD_TYPE child) { + super(PlanType.PHYSICAL_REPEAT, groupExpression, logicalProperties, + physicalProperties, statsDeriveResult, child); + this.groupingSets = Objects.requireNonNull(groupingSets, "groupingSets can not be null") + .stream() + .map(groupingSet -> ImmutableList.copyOf(groupingSet)) + .collect(ImmutableList.toImmutableList()); + this.outputExpressions = ImmutableList.copyOf( + Objects.requireNonNull(outputExpressions, "outputExpressions can not be null")); + } + + @Override + public List<List<Expression>> getGroupingSets() { + return groupingSets; + } + + @Override + public List<NamedExpression> getOutputExpressions() { + return outputExpressions; + } + + @Override + public String toString() { + return Utils.toSqlString("PhysicalRepeat", + "groupingSets", groupingSets, + "outputExpressions", outputExpressions + ); + } Review Comment: ```suggestion public String toString() { return Utils.toSqlString("PhysicalRepeat", "groupingSets", groupingSets, "outputExpressions", outputExpressions, "stats", statsDeriveResult ); } ``` -- 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