snuyanzin commented on a change in pull request #17800:
URL: https://github.com/apache/flink/pull/17800#discussion_r750229185
##########
File path:
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/data/binary/BinaryStringDataUtil.java
##########
@@ -525,56 +549,102 @@ public static Integer toInt(BinaryStringData str) {
while (i < sizeInBytes) {
byte currentByte = tmpBytes[i];
if (currentByte < '0' || currentByte > '9') {
- return null;
+ throw numberFormatExceptionFor(str, typeName, "Invalid
character found");
}
i++;
}
if (!negative) {
result = -result;
if (result < 0) {
- return null;
+ throw numberFormatExceptionFor(str, typeName, "Overflow");
}
}
return result;
}
- public static Short toShort(BinaryStringData str) {
- Integer intValue = toInt(str);
- if (intValue != null) {
- short result = intValue.shortValue();
- if (result == intValue) {
- return result;
- }
+ public static short toShort(BinaryStringData str) throws TableException {
+ int intValue = toInt(str, "SHORT");
+ short result = (short) intValue;
+ if (result == intValue) {
+ return result;
}
- return null;
+ throw numberFormatExceptionFor(str, "SHORT", "Overflow");
}
- public static Byte toByte(BinaryStringData str) {
- Integer intValue = toInt(str);
- if (intValue != null) {
- byte result = intValue.byteValue();
- if (result == intValue) {
- return result;
- }
+ public static byte toByte(BinaryStringData str) throws TableException {
+ int intValue = toInt(str, "SHORT");
Review comment:
I think it should be `BYTE` here like
```suggestion
int intValue = toInt(str, "BYTE");
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]