[fix](nereids)cast string to integer type use wrong datatype's valueOf method (#28174)

select cast('12.31' as tinyint);
select cast('12.31' as smallint);
select cast('12.31' as int);

should return NULL
This commit is contained in:
starocean999
2023-12-13 17:53:07 +08:00
committed by GitHub
parent ac262fa176
commit 62859f38c1
4 changed files with 21 additions and 9 deletions

View File

@ -218,11 +218,11 @@ public abstract class Literal extends Expression implements LeafExpression, Comp
}
}
if (targetType.isTinyIntType()) {
return Literal.of(Double.valueOf(desc).byteValue());
return Literal.of(Byte.valueOf(desc).byteValue());
} else if (targetType.isSmallIntType()) {
return Literal.of(Double.valueOf(desc).shortValue());
return Literal.of(Short.valueOf(desc).shortValue());
} else if (targetType.isIntegerType()) {
return Literal.of(Double.valueOf(desc).intValue());
return Literal.of(Integer.valueOf(desc).intValue());
} else if (targetType.isBigIntType()) {
return Literal.of(Long.valueOf(desc));
} else if (targetType.isLargeIntType()) {