wangshuo128 commented on code in PR #12416: URL: https://github.com/apache/doris/pull/12416#discussion_r964443875
########## fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalOneRowRelation.java: ########## @@ -0,0 +1,112 @@ +// 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.plans.Plan; +import org.apache.doris.nereids.trees.plans.PlanType; +import org.apache.doris.nereids.trees.plans.algebra.OneRowRelation; +import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor; +import org.apache.doris.nereids.util.Utils; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * A physical relation that contains only one row consist of some constant expressions. + * e.g. select 100, 'value' + */ +public class PhysicalOneRowRelation extends PhysicalLeaf implements OneRowRelation { + private List<NamedExpression> projects; Review Comment: ```suggestion private final List<NamedExpression> projects; ``` ########## fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rewrite/rules/TypeCoercion.java: ########## @@ -141,21 +140,16 @@ public Expression visitInPredicate(InPredicate inPredicate, ExpressionRewriteCon private Expression visitImplicitCastInputTypes(Expression expr, ExpressionRewriteContext ctx) { ImplicitCastInputTypes implicitCastInputTypes = (ImplicitCastInputTypes) expr; List<Expression> newChildren = Lists.newArrayListWithCapacity(expr.arity()); - AtomicInteger changed = new AtomicInteger(0); + boolean changed = false; for (int i = 0; i < implicitCastInputTypes.expectedInputTypes().size(); i++) { - newChildren.add(implicitCast(expr.child(i), implicitCastInputTypes.expectedInputTypes().get(i), ctx) - .map(e -> { - changed.incrementAndGet(); - return e; - }) - .orElse(expr.child(0)) - ); - } - if (changed.get() != 0) { - return expr.withChildren(newChildren); - } else { - return expr; + AbstractDataType expectedType = implicitCastInputTypes.expectedInputTypes().get(i); Review Comment: @qzsee please take a look. ########## fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOneRowRelation.java: ########## @@ -0,0 +1,115 @@ +// 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.logical; + +import org.apache.doris.nereids.memo.GroupExpression; +import org.apache.doris.nereids.properties.LogicalProperties; +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.OneRowRelation; +import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor; +import org.apache.doris.nereids.util.Utils; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * A relation that contains only one row consist of some constant expressions. + * e.g. select 100, 'value' + */ +public class LogicalOneRowRelation extends LogicalLeaf implements OneRowRelation { + private List<NamedExpression> projects; Review Comment: ```suggestion private final List<NamedExpression> projects; ``` ########## fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindFunction.java: ########## @@ -52,6 +53,22 @@ public class BindFunction implements AnalysisRuleFactory { @Override public List<Rule> buildRules() { return ImmutableList.of( + RuleType.BINDING_ONE_ROW_RELATION_FUNCTION.build( + logicalOneRowRelation().then(project -> { Review Comment: ```suggestion logicalOneRowRelation().then(oneRowRelation -> { ``` -- 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