pick from master #37889 we use unscaled value of BigDecimal in tablet prune. So we need to ensure BigDecimal's precision and scale is same with the literal contains it.
This commit is contained in:
@ -29,6 +29,7 @@ import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -72,10 +73,15 @@ public class SimplifyDecimalV3Comparison implements ExpressionPatternRuleFactory
|
||||
BigDecimal trailingZerosValue = right.getValue().stripTrailingZeros();
|
||||
int scale = org.apache.doris.analysis.DecimalLiteral.getBigDecimalScale(trailingZerosValue);
|
||||
int precision = org.apache.doris.analysis.DecimalLiteral.getBigDecimalPrecision(trailingZerosValue);
|
||||
try {
|
||||
trailingZerosValue = trailingZerosValue.setScale(scale, RoundingMode.UNNECESSARY);
|
||||
} catch (ArithmeticException e) {
|
||||
return cp;
|
||||
}
|
||||
|
||||
Expression castChild = left.child();
|
||||
Preconditions.checkState(castChild.getDataType() instanceof DecimalV3Type);
|
||||
DecimalV3Type leftType = (DecimalV3Type) castChild.getDataType();
|
||||
|
||||
if (scale <= leftType.getScale() && precision - scale <= leftType.getPrecision() - leftType.getScale()) {
|
||||
// precision and scale of literal all smaller than left, we don't need the cast
|
||||
DecimalV3Literal newRight = new DecimalV3Literal(
|
||||
|
||||
Reference in New Issue
Block a user