[fix](Nereids)set oepration type coercion is diff with legacy planner (#15982)
This commit is contained in:
@ -17,6 +17,7 @@
|
||||
|
||||
package org.apache.doris.nereids.trees.plans.logical;
|
||||
|
||||
import org.apache.doris.catalog.Type;
|
||||
import org.apache.doris.nereids.memo.GroupExpression;
|
||||
import org.apache.doris.nereids.properties.LogicalProperties;
|
||||
import org.apache.doris.nereids.trees.expressions.Cast;
|
||||
@ -129,25 +130,16 @@ public abstract class LogicalSetOperation extends AbstractLogicalPlan implements
|
||||
List<Expression> newRightOutpus = new ArrayList<>();
|
||||
// Ensure that the output types of the left and right children are consistent and expand upward.
|
||||
for (int i = 0; i < resetNullableForLeftOutputs.size(); ++i) {
|
||||
boolean hasPushed = false;
|
||||
Slot left = resetNullableForLeftOutputs.get(i);
|
||||
Slot right = child(1).getOutput().get(i);
|
||||
if (TypeCoercionUtils.canHandleTypeCoercion(left.getDataType(), right.getDataType())) {
|
||||
Optional<DataType> tightestCommonType =
|
||||
TypeCoercionUtils.findTightestCommonType(null, left.getDataType(), right.getDataType());
|
||||
if (tightestCommonType.isPresent()) {
|
||||
Expression newLeft = TypeCoercionUtils.castIfNotSameType(left, tightestCommonType.get());
|
||||
Expression newRight = TypeCoercionUtils.castIfNotSameType(right, tightestCommonType.get());
|
||||
newLeftOutputs.add(newLeft);
|
||||
newRightOutpus.add(newRight);
|
||||
hasPushed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasPushed) {
|
||||
newLeftOutputs.add(left);
|
||||
newRightOutpus.add(right);
|
||||
}
|
||||
DataType compatibleType = DataType.convertFromCatalogDataType(Type.getAssignmentCompatibleType(
|
||||
left.getDataType().toCatalogDataType(),
|
||||
right.getDataType().toCatalogDataType(),
|
||||
false));
|
||||
Expression newLeft = TypeCoercionUtils.castIfNotSameType(left, compatibleType);
|
||||
Expression newRight = TypeCoercionUtils.castIfNotSameType(right, compatibleType);
|
||||
newLeftOutputs.add(newLeft);
|
||||
newRightOutpus.add(newRight);
|
||||
}
|
||||
|
||||
List<List<Expression>> resultExpressions = new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user