[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:
@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user