snuyanzin commented on code in PR #29021:
URL: https://github.com/apache/flink/pull/29021#discussion_r3860114586
##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/data/binary/BinaryStringDataUtil.java:
##########
@@ -574,11 +574,34 @@ public static byte toByte(BinaryStringData str) throws
NumberFormatException {
}
public static double toDouble(BinaryStringData str) throws
NumberFormatException {
- return Double.parseDouble(str.toString());
+ return
Double.parseDouble(normalizeFloatingPointSpecialValue(str.toString()));
}
public static float toFloat(BinaryStringData str) throws
NumberFormatException {
- return Float.parseFloat(str.toString());
+ return
Float.parseFloat(normalizeFloatingPointSpecialValue(str.toString()));
+ }
+
+ /**
+ * Rewrites case-insensitive and abbreviated special values ({@code nan},
{@code inf}, {@code
+ * infinity}, with an optional sign on infinity) into the canonical tokens
{@link
+ * Double#parseDouble} and {@link Float#parseFloat} accept. Any other
input is returned
+ * unchanged.
+ */
+ private static String normalizeFloatingPointSpecialValue(String str) {
+ final String trimmed = str.trim();
Review Comment:
why do we need `trim` here?
Do we do `trim` for regular numbers?
--
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]