[fix](round) Fix incorrect decimal scale inference in round functions (#34471)
* FIX NEEDED * FORMAT * FORMAT * FIX TEST
This commit is contained in:
@ -37,9 +37,12 @@ public interface ComputePrecisionForRound extends ComputePrecision {
|
||||
Expression floatLength = getArgument(1);
|
||||
int scale;
|
||||
|
||||
if (floatLength.isLiteral() || (floatLength instanceof Cast && floatLength.child(0).isLiteral()
|
||||
// If scale arg is an integer literal, or it is a cast(Integer as Integer)
|
||||
// then we will try to use its value as result scale
|
||||
// In any other cases, we will make sure result decimal has same scale with input.
|
||||
if ((floatLength.isLiteral() && floatLength.getDataType() instanceof Int32OrLessType)
|
||||
|| (floatLength instanceof Cast && floatLength.child(0).isLiteral()
|
||||
&& floatLength.child(0).getDataType() instanceof Int32OrLessType)) {
|
||||
// Scale argument is a literal or cast from other literal
|
||||
if (floatLength instanceof Cast) {
|
||||
scale = ((IntegerLikeLiteral) floatLength.child(0)).getIntValue();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user