[fix](nereids)use same decimalv3 type for params and return types (#20101)
This commit is contained in:
@ -512,8 +512,16 @@ public class ArithmeticExpr extends Expr {
|
||||
}
|
||||
castChild(ScalarType.createDecimalV3Type(precision, targetScale), 0);
|
||||
} else if (op == Operator.MOD) {
|
||||
castChild(type, 0);
|
||||
castChild(type, 1);
|
||||
// TODO use max int part + max scale of two operands as result type
|
||||
// because BE require the result and operands types are the exact the same decimalv3 type
|
||||
precision = Math.max(widthOfIntPart1, widthOfIntPart2) + scale;
|
||||
if (precision > ScalarType.MAX_DECIMAL128_PRECISION) {
|
||||
type = castBinaryOp(Type.DOUBLE);
|
||||
} else {
|
||||
type = ScalarType.createDecimalV3Type(precision, scale);
|
||||
castChild(type, 0);
|
||||
castChild(type, 1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case INT_DIVIDE:
|
||||
|
||||
@ -44,8 +44,10 @@ public class Mod extends BinaryArithmetic implements AlwaysNullable {
|
||||
|
||||
@Override
|
||||
public DecimalV3Type getDataTypeForDecimalV3(DecimalV3Type t1, DecimalV3Type t2) {
|
||||
// TODO use max int part + max scale of two operands as result type
|
||||
// because BE require the result and operands types are the exact the same decimalv3 type
|
||||
int scale = Math.max(t1.getScale(), t2.getScale());
|
||||
int precision = t2.getRange() + scale;
|
||||
int precision = Math.max(t1.getRange(), t2.getRange()) + scale;
|
||||
return DecimalV3Type.createDecimalV3Type(precision, scale);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user