[fix](Nereids) decimalv2 and int/date bit arithmetic need cast to bigint (#32311)

This commit is contained in:
morrySnow
2024-03-20 18:20:34 +08:00
committed by yiguolei
parent b92a764665
commit 2a1d2ad647
4 changed files with 1598 additions and 1596 deletions

View File

@ -798,12 +798,6 @@ public class TypeCoercionUtils {
commonType = DoubleType.INSTANCE;
}
// we treat decimalv2 vs dicimalv3, largeint or bigint as decimalv3 way.
if ((t1.isDecimalV3Type() || t1.isBigIntType() || t1.isLargeIntType()) && t2.isDecimalV2Type()
|| t1.isDecimalV2Type() && (t2.isDecimalV3Type() || t2.isBigIntType() || t2.isLargeIntType())) {
return processDecimalV3BinaryArithmetic(binaryArithmetic, left, right);
}
if (t1.isDecimalV2Type() || t2.isDecimalV2Type()) {
// to be consistent with old planner
// see findCommonType() method in ArithmeticExpr.java
@ -832,6 +826,12 @@ public class TypeCoercionUtils {
return binaryArithmetic;
}
// we treat decimalv2 vs dicimalv3, largeint or bigint as decimalv3 way.
if ((t1.isDecimalV3Type() || t1.isBigIntType() || t1.isLargeIntType()) && t2.isDecimalV2Type()
|| t1.isDecimalV2Type() && (t2.isDecimalV3Type() || t2.isBigIntType() || t2.isLargeIntType())) {
return processDecimalV3BinaryArithmetic(binaryArithmetic, left, right);
}
// if double as common type, all arithmetic should cast both side to double
if (isArithmetic && commonType.isDoubleType()) {
return castChildren(binaryArithmetic, left, right, commonType);