[fix](Nereids) result type of add precision is 1 more than expected (#27136)
This commit is contained in:
@ -50,7 +50,7 @@ public class Add extends BinaryArithmetic implements CheckOverflowNullable {
|
||||
@Override
|
||||
public DecimalV3Type getDataTypeForDecimalV3(DecimalV3Type t1, DecimalV3Type t2) {
|
||||
DecimalV3Type decimalV3Type = (DecimalV3Type) DecimalV3Type.widerDecimalV3Type(t1, t2, false);
|
||||
return (DecimalV3Type) DecimalV3Type.createDecimalV3Type(decimalV3Type.getPrecision() + 1,
|
||||
return DecimalV3Type.createDecimalV3Type(decimalV3Type.getPrecision() + 1,
|
||||
decimalV3Type.getScale());
|
||||
}
|
||||
|
||||
|
||||
@ -59,7 +59,11 @@ public abstract class BinaryArithmetic extends BinaryOperator implements Propaga
|
||||
return getDataTypeForDecimalV2((DecimalV2Type) t1, (DecimalV2Type) t2);
|
||||
}
|
||||
if (t1.isDecimalV3Type() && t2.isDecimalV3Type()) {
|
||||
return getDataTypeForDecimalV3((DecimalV3Type) t1, (DecimalV3Type) t2);
|
||||
if (this instanceof Add || this instanceof Subtract || this instanceof Mod) {
|
||||
return t1;
|
||||
} else {
|
||||
return getDataTypeForDecimalV3((DecimalV3Type) t1, (DecimalV3Type) t2);
|
||||
}
|
||||
}
|
||||
return getDataTypeForOthers(t1, t2);
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ public class Subtract extends BinaryArithmetic implements CheckOverflowNullable
|
||||
@Override
|
||||
public DecimalV3Type getDataTypeForDecimalV3(DecimalV3Type t1, DecimalV3Type t2) {
|
||||
DecimalV3Type decimalV3Type = (DecimalV3Type) DecimalV3Type.widerDecimalV3Type(t1, t2, false);
|
||||
return (DecimalV3Type) DecimalV3Type.createDecimalV3Type(decimalV3Type.getPrecision() + 1,
|
||||
return DecimalV3Type.createDecimalV3Type(decimalV3Type.getPrecision() + 1,
|
||||
decimalV3Type.getScale());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user