snuyanzin commented on code in PR #29026:
URL: https://github.com/apache/flink/pull/29026#discussion_r3902739018


##########
flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/JsonParserToRowDataConverters.java:
##########
@@ -328,7 +328,10 @@ private StringData convertToString(JsonParser jp) throws 
IOException {
     }
 
     private BinaryVariant convertToVariant(JsonParser jp) throws IOException {
-        return 
BinaryVariantInternalBuilder.parseJson(jp.readValueAsTree().toString(), false);
+        // Read the whole value first so a parse error inside the variant 
cannot desync the shared
+        // parser and drop sibling fields. traverse() streams it without 
re-serializing to a String.
+        // Duplicate keys keep the last value, matching how a Jackson tree 
would collapse them.
+        return 
BinaryVariantInternalBuilder.parseJson(jp.readValueAsTree().traverse(), true);

Review Comment:
   Do I understand correctly: right now we parse 2 times and store DOM in 
between?
   like 
   ```
   bytes -> readValueAsTree() -> JsonNode tree -> traverse()+parseJson -> 
BinaryVariant
   ```
   can we parse only once?
   



-- 
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