snuyanzin commented on code in PR #29026:
URL: https://github.com/apache/flink/pull/29026#discussion_r3894021552
##########
flink-core/src/main/java/org/apache/flink/types/variant/BinaryVariantInternalBuilder.java:
##########
@@ -604,12 +627,44 @@ private void buildJson(JsonParser parser) throws
IOException {
appendNull();
break;
default:
- throw new JsonParseException(parser, "Unexpected token " +
token);
+ throw parseError(source, "Unexpected token " + token + ".");
+ }
+ }
+
+ /**
+ * Classifies a raw JSON number literal and appends it as an integer,
decimal, or double.
+ * Centralizing the choice here keeps every {@link JsonTokenSource}
consistent.
+ */
+ private void appendNumber(JsonTokenSource source, String text) throws
IOException {
+ if (isIntegerLiteral(text)) {
+ try {
+ appendNumeric(Long.parseLong(text));
+ return;
+ } catch (NumberFormatException outOfLongRange) {
+ // The value is an integer but too large for a long. Fall
through and store it as a
+ // decimal or double instead.
+ }
}
+ appendFloatingPoint(source, text);
}
- // Choose the smallest unsigned integer type that can store `value`. It
must be within
- // `[0, U24_MAX]`.
+ /**
+ * A JSON number is an integer literal when it has neither a fractional
part nor an exponent.
+ */
+ private static boolean isIntegerLiteral(String text) {
+ for (int i = 0; i < text.length(); ++i) {
Review Comment:
it returns `true` for empty string
is it expected?
--
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]