snuyanzin commented on a change in pull request #17800:
URL: https://github.com/apache/flink/pull/17800#discussion_r750156313



##########
File path: 
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/data/binary/BinaryStringDataUtil.java
##########
@@ -525,56 +545,102 @@ public static Integer toInt(BinaryStringData str) {
         while (i < sizeInBytes) {
             byte currentByte = tmpBytes[i];
             if (currentByte < '0' || currentByte > '9') {
-                return null;
+                throw numberFormatExceptionFor(str, "INT", "Invalid character 
found");
             }
             i++;
         }
 
         if (!negative) {
             result = -result;
             if (result < 0) {
-                return null;
+                throw numberFormatExceptionFor(str, "INT", "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);

Review comment:
       It seems that in case of value out of int range it will complain with 
`Table Cannot parse STRING to INT` instead of `Table Cannot parse STRING to 
SHORT`

##########
File path: 
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/data/binary/BinaryStringDataUtil.java
##########
@@ -525,56 +545,102 @@ public static Integer toInt(BinaryStringData str) {
         while (i < sizeInBytes) {
             byte currentByte = tmpBytes[i];
             if (currentByte < '0' || currentByte > '9') {
-                return null;
+                throw numberFormatExceptionFor(str, "INT", "Invalid character 
found");
             }
             i++;
         }
 
         if (!negative) {
             result = -result;
             if (result < 0) {
-                return null;
+                throw numberFormatExceptionFor(str, "INT", "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 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);

Review comment:
       It seems that in case of value out of int range it will complain with 
`Table Cannot parse STRING to INT` instead of `Table Cannot parse STRING to 
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]


Reply via email to