You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ja...@apache.org on 2020/12/18 15:13:39 UTC

[flink] branch release-1.12 updated: [FLINK-19880][json] Fix ignore-parse-errors option not work for the legacy JSON format

This is an automated email from the ASF dual-hosted git repository.

jark pushed a commit to branch release-1.12
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/release-1.12 by this push:
     new 3bfb2ab  [FLINK-19880][json] Fix ignore-parse-errors option not work for the legacy JSON format
3bfb2ab is described below

commit 3bfb2ab611acff9f0db28f95878032c80f3ae815
Author: cxiiiiiii <st...@163.com>
AuthorDate: Fri Dec 18 22:35:51 2020 +0800

    [FLINK-19880][json] Fix ignore-parse-errors option not work for the legacy JSON format
    
    This closes #14415
    
    Co-authored-by: Xiao Cai <fl...@163.com>
---
 .../apache/flink/formats/json/JsonRowFormatFactory.java  |  1 +
 .../flink/formats/json/JsonRowFormatFactoryTest.java     | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/JsonRowFormatFactory.java b/flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/JsonRowFormatFactory.java
index b855d94..356594a 100644
--- a/flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/JsonRowFormatFactory.java
+++ b/flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/JsonRowFormatFactory.java
@@ -50,6 +50,7 @@ public class JsonRowFormatFactory extends TableFormatFactoryBase<Row>
 		properties.add(JsonValidator.FORMAT_JSON_SCHEMA);
 		properties.add(JsonValidator.FORMAT_SCHEMA);
 		properties.add(JsonValidator.FORMAT_FAIL_ON_MISSING_FIELD);
+		properties.add(JsonValidator.FORMAT_IGNORE_PARSE_ERRORS);
 		return properties;
 	}
 
diff --git a/flink-formats/flink-json/src/test/java/org/apache/flink/formats/json/JsonRowFormatFactoryTest.java b/flink-formats/flink-json/src/test/java/org/apache/flink/formats/json/JsonRowFormatFactoryTest.java
index 6f94094..28beacb 100644
--- a/flink-formats/flink-json/src/test/java/org/apache/flink/formats/json/JsonRowFormatFactoryTest.java
+++ b/flink-formats/flink-json/src/test/java/org/apache/flink/formats/json/JsonRowFormatFactoryTest.java
@@ -80,6 +80,22 @@ public class JsonRowFormatFactoryTest extends TestLogger {
 	}
 
 	@Test
+	public void testSchemaIgnoreParseErrors() {
+		final Map<String, String> properties = toMap(
+			new Json()
+				.schema(SCHEMA)
+				.ignoreParseErrors(true));
+
+		testSchemaSerializationSchema(properties);
+
+		final DeserializationSchema<?> actual2 = TableFactoryService
+			.find(DeserializationSchemaFactory.class, properties)
+			.createDeserializationSchema(properties);
+		final JsonRowDeserializationSchema expected2 = new JsonRowDeserializationSchema.Builder(SCHEMA).ignoreParseErrors().build();
+		assertEquals(expected2, actual2);
+	}
+
+	@Test
 	public void testJsonSchema() {
 		final Map<String, String> properties = toMap(
 			new Json()