JingsongLi commented on a change in pull request #12010: URL: https://github.com/apache/flink/pull/12010#discussion_r422740073
########## File path: flink-table/flink-table-common/src/main/java/org/apache/flink/table/factories/FileSystemFormatFactory.java ########## @@ -127,7 +172,7 @@ /** * Get field names without partition keys. */ - default String[] getFieldNamesWithoutPartKeys() { + default String[] getFormatFieldTypes() { Review comment: `getFormatFieldNames ` ########## File path: flink-table/flink-table-common/src/main/java/org/apache/flink/table/factories/FileSystemFormatFactory.java ########## @@ -136,11 +181,23 @@ /** * Get field types without partition keys. */ - default DataType[] getFieldTypesWithoutPartKeys() { + default DataType[] getFormatFieldNames() { Review comment: `getFormatFieldTypes ` ########## File path: flink-formats/flink-json/src/test/java/org/apache/flink/formats/json/JsonBatchFileSystemITCase.java ########## @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.formats.json; + +import org.apache.flink.table.planner.runtime.batch.sql.BatchFileSystemITCaseBase; +import org.apache.flink.types.Row; +import org.apache.flink.util.FileUtils; + +import org.junit.Test; + +import java.io.File; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import scala.collection.JavaConverters; + +/** + * ITCase to test json format for {@link JsonFileSystemFormatFactory}. + */ +public class JsonBatchFileSystemITCase extends BatchFileSystemITCaseBase { + + @Override + public String[] formatProperties() { + List<String> ret = new ArrayList<>(); + ret.add("'format'='json'"); + ret.add("'format.ignore-parse-errors'='true'"); + return ret.toArray(new String[0]); + } + + @Test + public void testParseError() throws Exception { + String path = new URI(resultPath()).getPath(); + new File(path).mkdirs(); + File file = new File(path, "my_file"); + file.createNewFile(); + FileUtils.writeFileUtf8(file, + "{\"x\":\"x5\",\"y\":5,\"a\":1,\"b\":1}\n" + + "{I am a wrong json.}\n" + + "{\"x\":\"x5\",\"y\":5,\"a\":1,\"b\":1}"); + + check("select * from nonPartitionedTable", + JavaConverters.asScalaIteratorConverter(Arrays.asList( Review comment: You could add a `check(String sqlQuery, java.util.List<Row> expectedResult)` to `FileSystemITCaseBase`. ---------------------------------------------------------------- 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: us...@infra.apache.org