libenchao commented on a change in pull request #11119: [FLINK-15396][json] 
Support to ignore parse errors for JSON format
URL: https://github.com/apache/flink/pull/11119#discussion_r386253447
 
 

 ##########
 File path: 
flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/JsonRowDeserializationSchema.java
 ##########
 @@ -130,6 +135,9 @@ public Row deserialize(byte[] message) throws IOException {
                        final JsonNode root = objectMapper.readTree(message);
                        return (Row) runtimeConverter.convert(objectMapper, 
root);
                } catch (Throwable t) {
+                       if (ignoreParseErrors) {
+                               return null;
+                       }
 
 Review comment:
   We have two parsing error actually:  
   - `objectMapper.readTree` will throw parsing error when data is not a valid 
json, it will throw `IOException`
   - converters will throw parsing error when data cannot converted to 
specified type, we can make converters throw a custom exception
   
   So we can check exceptions for just these two types of exception, and apply 
ignore parse errors strategy.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to