You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/11/06 08:30:36 UTC

[GitHub] [flink] JingsongLi opened a new pull request #13957: [FLINK-19823][table][fs-connector] Filesystem connector supports de/serialization schema

JingsongLi opened a new pull request #13957:
URL: https://github.com/apache/flink/pull/13957


   
   ## What is the purpose of the change
   
   Integrate de/serialization schema to Filesystem connector.
   
   ## Brief change log
   
   - Introduce `DeserializationSchemaAdapter`
   - Introduce `SerializationSchemaAdapter`
   - Clean `FileSystemFormatFactory`s
   - Integrate to `FileSystemTableSource` and `FileSystemTableSink`
   - Correct `getChangelogMode`
   
   ## Verifying this change
   
   This change is already covered by existing tests*.
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): no
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: no
     - The serializers: no
     - The runtime per-record code paths (performance sensitive): no
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: no
     - The S3 file system connector: no
   
   ## Documentation
   
     - Does this pull request introduce a new feature? yes
     - If yes, how is the feature documented? JavaDocs
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] JingsongLi merged pull request #13957: [FLINK-19823][table][fs-connector] Filesystem connector supports de/serialization schema

Posted by GitBox <gi...@apache.org>.
JingsongLi merged pull request #13957:
URL: https://github.com/apache/flink/pull/13957


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] wuchong commented on a change in pull request #13957: [FLINK-19823][table][fs-connector] Filesystem connector supports de/serialization schema

Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #13957:
URL: https://github.com/apache/flink/pull/13957#discussion_r519108294



##########
File path: flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/filesystem/FileSystemTableSink.java
##########
@@ -251,6 +258,14 @@ private RowDataPartitionComputer partitionComputer() {
 				//noinspection unchecked
 				return Optional.of(FileInputFormatCompactReader.factory((FileInputFormat<RowData>) format));
 			}
+		} else if (deserializationFormat != null) {
+			// NOTE, we need pass full format types to deserializationFormat
+			DeserializationSchema<RowData> decoder = deserializationFormat.createRuntimeDecoder(
+					createSourceContext(context), getFormatDataType());
+			int[] projectedFields = IntStream.of(0, schema.getFieldCount()).toArray();

Review comment:
       `IntStream.range`?

##########
File path: flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/filesystem/DeserializationSchemaAdapter.java
##########
@@ -0,0 +1,316 @@
+/*
+ * 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.table.filesystem;
+
+import org.apache.flink.api.common.io.DelimitedInputFormat;
+import org.apache.flink.api.common.serialization.DeserializationSchema;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.connector.file.src.FileSourceSplit;
+import org.apache.flink.connector.file.src.reader.BulkFormat;
+import org.apache.flink.connector.file.src.util.ArrayResultIterator;
+import org.apache.flink.core.fs.FileInputSplit;
+import org.apache.flink.core.fs.Path;
+import org.apache.flink.metrics.MetricGroup;
+import org.apache.flink.table.api.TableSchema;
+import org.apache.flink.table.data.GenericRowData;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.runtime.typeutils.InternalTypeInfo;
+import org.apache.flink.table.types.DataType;
+import org.apache.flink.table.types.logical.LogicalType;
+import org.apache.flink.table.types.logical.RowType;
+import org.apache.flink.table.utils.PartitionPathUtils;
+import org.apache.flink.util.Collector;
+import org.apache.flink.util.InstantiationUtil;
+import org.apache.flink.util.UserCodeClassLoader;
+
+import javax.annotation.Nullable;
+
+import java.io.IOException;
+import java.util.ArrayDeque;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Queue;
+import java.util.stream.Collectors;
+
+import static org.apache.flink.connector.file.src.util.CheckpointedPosition.NO_OFFSET;
+import static org.apache.flink.table.data.vector.VectorizedColumnBatch.DEFAULT_SIZE;
+
+/**
+ * Adapter to turn a {@link DeserializationSchema} into a {@link BulkFormat}.
+ */
+public class DeserializationSchemaAdapter implements BulkFormat<RowData, FileSourceSplit> {
+
+	private static final int BATCH_SIZE = 100;
+
+	// NOTE, deserializationSchema produce full format fields with original order
+	private final DeserializationSchema<RowData> deserializationSchema;
+
+	private final String[] fieldNames;
+	private final DataType[] fieldTypes;
+	private final int[] projectFields;
+	private final RowType projectedRowType;
+
+	private final List<String> partitionKeys;
+	private final String defaultPartValue;
+
+	private final int[] toProjectedField;
+	private final RowData.FieldGetter[] formatFieldGetters;
+
+	public DeserializationSchemaAdapter(
+			DeserializationSchema<RowData> deserializationSchema,
+			TableSchema schema,
+			int[] projectFields,
+			List<String> partitionKeys,
+			String defaultPartValue) {
+		this.deserializationSchema = deserializationSchema;
+		this.fieldNames = schema.getFieldNames();
+		this.fieldTypes = schema.getFieldDataTypes();
+		this.projectFields = projectFields;
+		this.partitionKeys = partitionKeys;
+		this.defaultPartValue = defaultPartValue;
+
+		List<String> projectedNames = Arrays.stream(projectFields)
+				.mapToObj(idx -> schema.getFieldNames()[idx])
+				.collect(Collectors.toList());
+
+		this.projectedRowType = RowType.of(
+				Arrays.stream(projectFields).mapToObj(idx ->
+						schema.getFieldDataTypes()[idx].getLogicalType()).toArray(LogicalType[]::new),
+				projectedNames.toArray(new String[0]));
+
+		List<String> formatFields = Arrays.stream(schema.getFieldNames())
+				.filter(field -> !partitionKeys.contains(field))
+				.collect(Collectors.toList());
+
+		List<String> formatProjectedFields = projectedNames.stream()
+				.filter(field -> !partitionKeys.contains(field))
+				.collect(Collectors.toList());
+
+		this.toProjectedField = formatProjectedFields.stream()
+				.mapToInt(projectedNames::indexOf)
+				.toArray();
+
+		this.formatFieldGetters = new RowData.FieldGetter[formatProjectedFields.size()];
+		for (int i = 0; i < formatProjectedFields.size(); i++) {
+			String name = formatProjectedFields.get(i);
+			this.formatFieldGetters[i] = RowData.createFieldGetter(
+					schema.getFieldDataType(name).get().getLogicalType(),
+					formatFields.indexOf(name));
+		}
+	}
+
+	private DeserializationSchema<RowData> createDeserialization() throws IOException {
+		try {
+			DeserializationSchema<RowData> deserialization = InstantiationUtil.clone(deserializationSchema);
+			deserialization.open(new DeserializationSchema.InitializationContext() {
+				@Override
+				public MetricGroup getMetricGroup() {
+					throw new UnsupportedOperationException("MetricGroup is unsupported in BulkFormat.");
+				}
+
+				@Override
+				public UserCodeClassLoader getUserCodeClassLoader() {
+					return (UserCodeClassLoader) Thread.currentThread().getContextClassLoader();
+				}
+			});
+			return deserialization;
+		} catch (Exception e) {
+			throw new IOException(e);
+		}
+	}
+
+	@Override
+	public Reader createReader(Configuration config, FileSourceSplit split) throws IOException {
+		return new Reader(config, split);
+	}
+
+	@Override
+	public Reader restoreReader(Configuration config, FileSourceSplit split) throws IOException {
+		Reader reader = new Reader(config, split);
+		reader.seek(split.getReaderPosition().get().getRecordsAfterOffset());
+		return null;

Review comment:
       return reader?

##########
File path: flink-formats/flink-json/src/test/java/org/apache/flink/formats/json/debezium/DebeziumJsonFileSystemITCase.java
##########
@@ -0,0 +1,148 @@
+/*
+ * 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.debezium;
+
+import org.apache.flink.table.planner.runtime.utils.StreamingTestBase;
+import org.apache.flink.types.Row;
+import org.apache.flink.util.CloseableIterator;
+import org.apache.flink.util.CollectionUtil;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static java.lang.String.format;
+
+/**
+ * Test Filesystem connector with DebeziumJson.
+ */
+public class DebeziumJsonFileSystemITCase extends StreamingTestBase {
+
+	private static final List<String> EXPECTED = Arrays.asList(
+			"+I(101,scooter,Small 2-wheel scooter,3.14)",
+			"+I(102,car battery,12V car battery,8.1)",
+			"+I(103,12-pack drill bits,12-pack of drill bits with sizes ranging from #40 to #3,0.8)",
+			"+I(104,hammer,12oz carpenter's hammer,0.75)",
+			"+I(105,hammer,14oz carpenter's hammer,0.875)",
+			"+I(106,hammer,16oz carpenter's hammer,1.0)",
+			"+I(107,rocks,box of assorted rocks,5.3)",
+			"+I(108,jacket,water resistent black wind breaker,0.1)",
+			"+I(109,spare tire,24 inch spare tire,22.2)",
+			"-D(106,hammer,16oz carpenter's hammer,1.0)", // -U
+			"+I(106,hammer,18oz carpenter hammer,1.0)", // +U
+			"-D(107,rocks,box of assorted rocks,5.3)", // -U
+			"+I(107,rocks,box of assorted rocks,5.1)", // +U
+			"+I(110,jacket,water resistent white wind breaker,0.2)",
+			"+I(111,scooter,Big 2-wheel scooter ,5.18)",
+			"-D(110,jacket,water resistent white wind breaker,0.2)", // -U
+			"+I(110,jacket,new water resistent white wind breaker,0.5)", // +U
+			"-D(111,scooter,Big 2-wheel scooter ,5.18)", // -U
+			"+I(111,scooter,Big 2-wheel scooter ,5.17)", // +U
+			"-D(111,scooter,Big 2-wheel scooter ,5.17)"
+	);
+
+	private File source;
+	private File sink;
+
+	private void prepareTables(boolean isPartition) throws IOException {
+		byte[] bytes = readBytes("debezium-data-schema-exclude.txt");
+		source = TEMPORARY_FOLDER.newFolder();
+		File file;
+		if (isPartition) {
+			File partition = new File(source, "p=1");
+			partition.mkdirs();
+			file = new File(partition, "my_file");
+		} else {
+			file = new File(source, "my_file");
+		}
+		file.createNewFile();
+		Files.write(file.toPath(), bytes);
+
+		sink = TEMPORARY_FOLDER.newFolder();
+
+		env().setParallelism(1);
+	}
+
+	private void createTable(String name, String path, boolean isPartition) {
+		tEnv().executeSql(format("create table %s (", name) +
+				"id int, name string, description string, weight float" +
+				(isPartition ? ", p int) partitioned by (p) " : ")") +
+				" with (" +
+				"'connector'='filesystem'," +
+				"'format'='debezium-json'," +
+				format("'path'='%s'", path) +
+				")");
+	}
+
+	@Test
+	public void testNonPartition() throws Exception {
+		prepareTables(false);
+		createTable("source", source.toURI().toString(), false);
+		createTable("sink", sink.toURI().toString(), false);
+
+		tEnv().executeSql("insert into sink select * from source").await();
+		CloseableIterator<Row> iter = tEnv().executeSql("select * from sink").collect();

Review comment:
       Select some fields to trigger the projection push down? We can write one more column into the sink, e.g `UPPER(name)`, and then select out the `upper_name` instead of the `name.

##########
File path: flink-table/flink-table-runtime-blink/src/test/java/org/apache/flink/table/data/BinaryRowDataTest.java
##########
@@ -94,6 +94,10 @@
  */
 public class BinaryRowDataTest {
 
+	public static void main(String[] args) {

Review comment:
       remove.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #13957: [FLINK-19823][table][fs-connector] Filesystem connector supports de/serialization schema

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13957:
URL: https://github.com/apache/flink/pull/13957#issuecomment-722961884


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "eded6a80f900965a008691d061057dae9c0d7cfe",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9152",
       "triggerID" : "eded6a80f900965a008691d061057dae9c0d7cfe",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0c4e62b055b5cd62d95be004423262ed9ce5eb86",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9235",
       "triggerID" : "0c4e62b055b5cd62d95be004423262ed9ce5eb86",
       "triggerType" : "PUSH"
     }, {
       "hash" : "f9c06b641c424a4e3f4e91ecc668b599dd45b6e1",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9240",
       "triggerID" : "f9c06b641c424a4e3f4e91ecc668b599dd45b6e1",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * eded6a80f900965a008691d061057dae9c0d7cfe Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9152) 
   * 0c4e62b055b5cd62d95be004423262ed9ce5eb86 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9235) 
   * f9c06b641c424a4e3f4e91ecc668b599dd45b6e1 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9240) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #13957: [FLINK-19823][table][fs-connector] Filesystem connector supports de/serialization schema

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13957:
URL: https://github.com/apache/flink/pull/13957#issuecomment-722961884


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "eded6a80f900965a008691d061057dae9c0d7cfe",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9152",
       "triggerID" : "eded6a80f900965a008691d061057dae9c0d7cfe",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0c4e62b055b5cd62d95be004423262ed9ce5eb86",
       "status" : "CANCELED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9235",
       "triggerID" : "0c4e62b055b5cd62d95be004423262ed9ce5eb86",
       "triggerType" : "PUSH"
     }, {
       "hash" : "f9c06b641c424a4e3f4e91ecc668b599dd45b6e1",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9240",
       "triggerID" : "f9c06b641c424a4e3f4e91ecc668b599dd45b6e1",
       "triggerType" : "PUSH"
     }, {
       "hash" : "41b8b8583a8b8e08979515d6bcb1475fdd231664",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "41b8b8583a8b8e08979515d6bcb1475fdd231664",
       "triggerType" : "PUSH"
     }, {
       "hash" : "e71978fc6c6da487d3b75da6a3fa8b86d6bd2f2e",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9242",
       "triggerID" : "e71978fc6c6da487d3b75da6a3fa8b86d6bd2f2e",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 0c4e62b055b5cd62d95be004423262ed9ce5eb86 Azure: [CANCELED](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9235) 
   * f9c06b641c424a4e3f4e91ecc668b599dd45b6e1 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9240) 
   * 41b8b8583a8b8e08979515d6bcb1475fdd231664 UNKNOWN
   * e71978fc6c6da487d3b75da6a3fa8b86d6bd2f2e Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9242) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #13957: [FLINK-19823][table][fs-connector] Filesystem connector supports de/serialization schema

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13957:
URL: https://github.com/apache/flink/pull/13957#issuecomment-722961884


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "eded6a80f900965a008691d061057dae9c0d7cfe",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9152",
       "triggerID" : "eded6a80f900965a008691d061057dae9c0d7cfe",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0c4e62b055b5cd62d95be004423262ed9ce5eb86",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9235",
       "triggerID" : "0c4e62b055b5cd62d95be004423262ed9ce5eb86",
       "triggerType" : "PUSH"
     }, {
       "hash" : "f9c06b641c424a4e3f4e91ecc668b599dd45b6e1",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9240",
       "triggerID" : "f9c06b641c424a4e3f4e91ecc668b599dd45b6e1",
       "triggerType" : "PUSH"
     }, {
       "hash" : "41b8b8583a8b8e08979515d6bcb1475fdd231664",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "41b8b8583a8b8e08979515d6bcb1475fdd231664",
       "triggerType" : "PUSH"
     }, {
       "hash" : "e71978fc6c6da487d3b75da6a3fa8b86d6bd2f2e",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "e71978fc6c6da487d3b75da6a3fa8b86d6bd2f2e",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * eded6a80f900965a008691d061057dae9c0d7cfe Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9152) 
   * 0c4e62b055b5cd62d95be004423262ed9ce5eb86 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9235) 
   * f9c06b641c424a4e3f4e91ecc668b599dd45b6e1 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9240) 
   * 41b8b8583a8b8e08979515d6bcb1475fdd231664 UNKNOWN
   * e71978fc6c6da487d3b75da6a3fa8b86d6bd2f2e UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #13957: [FLINK-19823][table][fs-connector] Filesystem connector supports de/serialization schema

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13957:
URL: https://github.com/apache/flink/pull/13957#issuecomment-722961884


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "eded6a80f900965a008691d061057dae9c0d7cfe",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9152",
       "triggerID" : "eded6a80f900965a008691d061057dae9c0d7cfe",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0c4e62b055b5cd62d95be004423262ed9ce5eb86",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9235",
       "triggerID" : "0c4e62b055b5cd62d95be004423262ed9ce5eb86",
       "triggerType" : "PUSH"
     }, {
       "hash" : "f9c06b641c424a4e3f4e91ecc668b599dd45b6e1",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9240",
       "triggerID" : "f9c06b641c424a4e3f4e91ecc668b599dd45b6e1",
       "triggerType" : "PUSH"
     }, {
       "hash" : "41b8b8583a8b8e08979515d6bcb1475fdd231664",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "41b8b8583a8b8e08979515d6bcb1475fdd231664",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * eded6a80f900965a008691d061057dae9c0d7cfe Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9152) 
   * 0c4e62b055b5cd62d95be004423262ed9ce5eb86 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9235) 
   * f9c06b641c424a4e3f4e91ecc668b599dd45b6e1 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9240) 
   * 41b8b8583a8b8e08979515d6bcb1475fdd231664 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #13957: [FLINK-19823][table][fs-connector] Filesystem connector supports de/serialization schema

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13957:
URL: https://github.com/apache/flink/pull/13957#issuecomment-722961884


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "eded6a80f900965a008691d061057dae9c0d7cfe",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9152",
       "triggerID" : "eded6a80f900965a008691d061057dae9c0d7cfe",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * eded6a80f900965a008691d061057dae9c0d7cfe Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9152) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] JingsongLi commented on a change in pull request #13957: [FLINK-19823][table][fs-connector] Filesystem connector supports de/serialization schema

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on a change in pull request #13957:
URL: https://github.com/apache/flink/pull/13957#discussion_r519122722



##########
File path: flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/filesystem/DeserializationSchemaAdapter.java
##########
@@ -0,0 +1,316 @@
+/*
+ * 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.table.filesystem;
+
+import org.apache.flink.api.common.io.DelimitedInputFormat;
+import org.apache.flink.api.common.serialization.DeserializationSchema;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.connector.file.src.FileSourceSplit;
+import org.apache.flink.connector.file.src.reader.BulkFormat;
+import org.apache.flink.connector.file.src.util.ArrayResultIterator;
+import org.apache.flink.core.fs.FileInputSplit;
+import org.apache.flink.core.fs.Path;
+import org.apache.flink.metrics.MetricGroup;
+import org.apache.flink.table.api.TableSchema;
+import org.apache.flink.table.data.GenericRowData;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.runtime.typeutils.InternalTypeInfo;
+import org.apache.flink.table.types.DataType;
+import org.apache.flink.table.types.logical.LogicalType;
+import org.apache.flink.table.types.logical.RowType;
+import org.apache.flink.table.utils.PartitionPathUtils;
+import org.apache.flink.util.Collector;
+import org.apache.flink.util.InstantiationUtil;
+import org.apache.flink.util.UserCodeClassLoader;
+
+import javax.annotation.Nullable;
+
+import java.io.IOException;
+import java.util.ArrayDeque;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Queue;
+import java.util.stream.Collectors;
+
+import static org.apache.flink.connector.file.src.util.CheckpointedPosition.NO_OFFSET;
+import static org.apache.flink.table.data.vector.VectorizedColumnBatch.DEFAULT_SIZE;
+
+/**
+ * Adapter to turn a {@link DeserializationSchema} into a {@link BulkFormat}.
+ */
+public class DeserializationSchemaAdapter implements BulkFormat<RowData, FileSourceSplit> {
+
+	private static final int BATCH_SIZE = 100;
+
+	// NOTE, deserializationSchema produce full format fields with original order
+	private final DeserializationSchema<RowData> deserializationSchema;
+
+	private final String[] fieldNames;
+	private final DataType[] fieldTypes;
+	private final int[] projectFields;
+	private final RowType projectedRowType;
+
+	private final List<String> partitionKeys;
+	private final String defaultPartValue;
+
+	private final int[] toProjectedField;
+	private final RowData.FieldGetter[] formatFieldGetters;
+
+	public DeserializationSchemaAdapter(
+			DeserializationSchema<RowData> deserializationSchema,
+			TableSchema schema,
+			int[] projectFields,
+			List<String> partitionKeys,
+			String defaultPartValue) {
+		this.deserializationSchema = deserializationSchema;
+		this.fieldNames = schema.getFieldNames();
+		this.fieldTypes = schema.getFieldDataTypes();
+		this.projectFields = projectFields;
+		this.partitionKeys = partitionKeys;
+		this.defaultPartValue = defaultPartValue;
+
+		List<String> projectedNames = Arrays.stream(projectFields)
+				.mapToObj(idx -> schema.getFieldNames()[idx])
+				.collect(Collectors.toList());
+
+		this.projectedRowType = RowType.of(
+				Arrays.stream(projectFields).mapToObj(idx ->
+						schema.getFieldDataTypes()[idx].getLogicalType()).toArray(LogicalType[]::new),
+				projectedNames.toArray(new String[0]));
+
+		List<String> formatFields = Arrays.stream(schema.getFieldNames())
+				.filter(field -> !partitionKeys.contains(field))
+				.collect(Collectors.toList());
+
+		List<String> formatProjectedFields = projectedNames.stream()
+				.filter(field -> !partitionKeys.contains(field))
+				.collect(Collectors.toList());
+
+		this.toProjectedField = formatProjectedFields.stream()
+				.mapToInt(projectedNames::indexOf)
+				.toArray();
+
+		this.formatFieldGetters = new RowData.FieldGetter[formatProjectedFields.size()];
+		for (int i = 0; i < formatProjectedFields.size(); i++) {
+			String name = formatProjectedFields.get(i);
+			this.formatFieldGetters[i] = RowData.createFieldGetter(
+					schema.getFieldDataType(name).get().getLogicalType(),
+					formatFields.indexOf(name));
+		}
+	}
+
+	private DeserializationSchema<RowData> createDeserialization() throws IOException {
+		try {
+			DeserializationSchema<RowData> deserialization = InstantiationUtil.clone(deserializationSchema);
+			deserialization.open(new DeserializationSchema.InitializationContext() {
+				@Override
+				public MetricGroup getMetricGroup() {
+					throw new UnsupportedOperationException("MetricGroup is unsupported in BulkFormat.");
+				}
+
+				@Override
+				public UserCodeClassLoader getUserCodeClassLoader() {
+					return (UserCodeClassLoader) Thread.currentThread().getContextClassLoader();
+				}
+			});
+			return deserialization;
+		} catch (Exception e) {
+			throw new IOException(e);
+		}
+	}
+
+	@Override
+	public Reader createReader(Configuration config, FileSourceSplit split) throws IOException {
+		return new Reader(config, split);
+	}
+
+	@Override
+	public Reader restoreReader(Configuration config, FileSourceSplit split) throws IOException {
+		Reader reader = new Reader(config, split);
+		reader.seek(split.getReaderPosition().get().getRecordsAfterOffset());
+		return null;

Review comment:
       But there is no way, because the current file system does not support streaming reading




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #13957: [FLINK-19823][table][fs-connector] Filesystem connector supports de/serialization schema

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13957:
URL: https://github.com/apache/flink/pull/13957#issuecomment-722961884


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "eded6a80f900965a008691d061057dae9c0d7cfe",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9152",
       "triggerID" : "eded6a80f900965a008691d061057dae9c0d7cfe",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0c4e62b055b5cd62d95be004423262ed9ce5eb86",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9235",
       "triggerID" : "0c4e62b055b5cd62d95be004423262ed9ce5eb86",
       "triggerType" : "PUSH"
     }, {
       "hash" : "f9c06b641c424a4e3f4e91ecc668b599dd45b6e1",
       "status" : "CANCELED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9240",
       "triggerID" : "f9c06b641c424a4e3f4e91ecc668b599dd45b6e1",
       "triggerType" : "PUSH"
     }, {
       "hash" : "41b8b8583a8b8e08979515d6bcb1475fdd231664",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "41b8b8583a8b8e08979515d6bcb1475fdd231664",
       "triggerType" : "PUSH"
     }, {
       "hash" : "e71978fc6c6da487d3b75da6a3fa8b86d6bd2f2e",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9242",
       "triggerID" : "e71978fc6c6da487d3b75da6a3fa8b86d6bd2f2e",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * f9c06b641c424a4e3f4e91ecc668b599dd45b6e1 Azure: [CANCELED](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9240) 
   * 41b8b8583a8b8e08979515d6bcb1475fdd231664 UNKNOWN
   * e71978fc6c6da487d3b75da6a3fa8b86d6bd2f2e Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9242) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #13957: [FLINK-19823][table][fs-connector] Filesystem connector supports de/serialization schema

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13957:
URL: https://github.com/apache/flink/pull/13957#issuecomment-722961884


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "eded6a80f900965a008691d061057dae9c0d7cfe",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9152",
       "triggerID" : "eded6a80f900965a008691d061057dae9c0d7cfe",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * eded6a80f900965a008691d061057dae9c0d7cfe Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9152) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #13957: [FLINK-19823][table][fs-connector] Filesystem connector supports de/serialization schema

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13957:
URL: https://github.com/apache/flink/pull/13957#issuecomment-722961884


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "eded6a80f900965a008691d061057dae9c0d7cfe",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9152",
       "triggerID" : "eded6a80f900965a008691d061057dae9c0d7cfe",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0c4e62b055b5cd62d95be004423262ed9ce5eb86",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9235",
       "triggerID" : "0c4e62b055b5cd62d95be004423262ed9ce5eb86",
       "triggerType" : "PUSH"
     }, {
       "hash" : "f9c06b641c424a4e3f4e91ecc668b599dd45b6e1",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9240",
       "triggerID" : "f9c06b641c424a4e3f4e91ecc668b599dd45b6e1",
       "triggerType" : "PUSH"
     }, {
       "hash" : "41b8b8583a8b8e08979515d6bcb1475fdd231664",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "41b8b8583a8b8e08979515d6bcb1475fdd231664",
       "triggerType" : "PUSH"
     }, {
       "hash" : "e71978fc6c6da487d3b75da6a3fa8b86d6bd2f2e",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9242",
       "triggerID" : "e71978fc6c6da487d3b75da6a3fa8b86d6bd2f2e",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 41b8b8583a8b8e08979515d6bcb1475fdd231664 UNKNOWN
   * e71978fc6c6da487d3b75da6a3fa8b86d6bd2f2e Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9242) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #13957: [FLINK-19823][table][fs-connector] Filesystem connector supports de/serialization schema

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13957:
URL: https://github.com/apache/flink/pull/13957#issuecomment-722961884


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "eded6a80f900965a008691d061057dae9c0d7cfe",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9152",
       "triggerID" : "eded6a80f900965a008691d061057dae9c0d7cfe",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0c4e62b055b5cd62d95be004423262ed9ce5eb86",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "0c4e62b055b5cd62d95be004423262ed9ce5eb86",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * eded6a80f900965a008691d061057dae9c0d7cfe Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9152) 
   * 0c4e62b055b5cd62d95be004423262ed9ce5eb86 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #13957: [FLINK-19823][table][fs-connector] Filesystem connector supports de/serialization schema

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13957:
URL: https://github.com/apache/flink/pull/13957#issuecomment-722961884


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "eded6a80f900965a008691d061057dae9c0d7cfe",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9152",
       "triggerID" : "eded6a80f900965a008691d061057dae9c0d7cfe",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0c4e62b055b5cd62d95be004423262ed9ce5eb86",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9235",
       "triggerID" : "0c4e62b055b5cd62d95be004423262ed9ce5eb86",
       "triggerType" : "PUSH"
     }, {
       "hash" : "f9c06b641c424a4e3f4e91ecc668b599dd45b6e1",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "f9c06b641c424a4e3f4e91ecc668b599dd45b6e1",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * eded6a80f900965a008691d061057dae9c0d7cfe Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9152) 
   * 0c4e62b055b5cd62d95be004423262ed9ce5eb86 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9235) 
   * f9c06b641c424a4e3f4e91ecc668b599dd45b6e1 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] JingsongLi commented on a change in pull request #13957: [FLINK-19823][table][fs-connector] Filesystem connector supports de/serialization schema

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on a change in pull request #13957:
URL: https://github.com/apache/flink/pull/13957#discussion_r519122574



##########
File path: flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/filesystem/FileSystemTableSink.java
##########
@@ -251,6 +258,14 @@ private RowDataPartitionComputer partitionComputer() {
 				//noinspection unchecked
 				return Optional.of(FileInputFormatCompactReader.factory((FileInputFormat<RowData>) format));
 			}
+		} else if (deserializationFormat != null) {
+			// NOTE, we need pass full format types to deserializationFormat
+			DeserializationSchema<RowData> decoder = deserializationFormat.createRuntimeDecoder(
+					createSourceContext(context), getFormatDataType());
+			int[] projectedFields = IntStream.of(0, schema.getFieldCount()).toArray();

Review comment:
       I'll add Json Compaction test




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot commented on pull request #13957: [FLINK-19823][table][fs-connector] Filesystem connector supports de/serialization schema

Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #13957:
URL: https://github.com/apache/flink/pull/13957#issuecomment-722950119


   Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
   to review your pull request. We will use this comment to track the progress of the review.
   
   
   ## Automated Checks
   Last check on commit eded6a80f900965a008691d061057dae9c0d7cfe (Fri Nov 06 08:33:12 UTC 2020)
   
   **Warnings:**
    * No documentation files were touched! Remember to keep the Flink docs up to date!
    * **This pull request references an unassigned [Jira ticket](https://issues.apache.org/jira/browse/FLINK-19823).** According to the [code contribution guide](https://flink.apache.org/contributing/contribute-code.html), tickets need to be assigned before starting with the implementation work.
   
   
   <sub>Mention the bot in a comment to re-run the automated checks.</sub>
   ## Review Progress
   
   * ❓ 1. The [description] looks good.
   * ❓ 2. There is [consensus] that the contribution should go into to Flink.
   * ❓ 3. Needs [attention] from.
   * ❓ 4. The change fits into the overall [architecture].
   * ❓ 5. Overall code [quality] is good.
   
   Please see the [Pull Request Review Guide](https://flink.apache.org/contributing/reviewing-prs.html) for a full explanation of the review process.<details>
    The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot approve description` to approve one or more aspects (aspects: `description`, `consensus`, `architecture` and `quality`)
    - `@flinkbot approve all` to approve all aspects
    - `@flinkbot approve-until architecture` to approve everything until `architecture`
    - `@flinkbot attention @username1 [@username2 ..]` to require somebody's attention
    - `@flinkbot disapprove architecture` to remove an approval you gave earlier
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] JingsongLi commented on a change in pull request #13957: [FLINK-19823][table][fs-connector] Filesystem connector supports de/serialization schema

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on a change in pull request #13957:
URL: https://github.com/apache/flink/pull/13957#discussion_r519119368



##########
File path: flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/filesystem/DeserializationSchemaAdapter.java
##########
@@ -0,0 +1,316 @@
+/*
+ * 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.table.filesystem;
+
+import org.apache.flink.api.common.io.DelimitedInputFormat;
+import org.apache.flink.api.common.serialization.DeserializationSchema;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.connector.file.src.FileSourceSplit;
+import org.apache.flink.connector.file.src.reader.BulkFormat;
+import org.apache.flink.connector.file.src.util.ArrayResultIterator;
+import org.apache.flink.core.fs.FileInputSplit;
+import org.apache.flink.core.fs.Path;
+import org.apache.flink.metrics.MetricGroup;
+import org.apache.flink.table.api.TableSchema;
+import org.apache.flink.table.data.GenericRowData;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.runtime.typeutils.InternalTypeInfo;
+import org.apache.flink.table.types.DataType;
+import org.apache.flink.table.types.logical.LogicalType;
+import org.apache.flink.table.types.logical.RowType;
+import org.apache.flink.table.utils.PartitionPathUtils;
+import org.apache.flink.util.Collector;
+import org.apache.flink.util.InstantiationUtil;
+import org.apache.flink.util.UserCodeClassLoader;
+
+import javax.annotation.Nullable;
+
+import java.io.IOException;
+import java.util.ArrayDeque;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Queue;
+import java.util.stream.Collectors;
+
+import static org.apache.flink.connector.file.src.util.CheckpointedPosition.NO_OFFSET;
+import static org.apache.flink.table.data.vector.VectorizedColumnBatch.DEFAULT_SIZE;
+
+/**
+ * Adapter to turn a {@link DeserializationSchema} into a {@link BulkFormat}.
+ */
+public class DeserializationSchemaAdapter implements BulkFormat<RowData, FileSourceSplit> {
+
+	private static final int BATCH_SIZE = 100;
+
+	// NOTE, deserializationSchema produce full format fields with original order
+	private final DeserializationSchema<RowData> deserializationSchema;
+
+	private final String[] fieldNames;
+	private final DataType[] fieldTypes;
+	private final int[] projectFields;
+	private final RowType projectedRowType;
+
+	private final List<String> partitionKeys;
+	private final String defaultPartValue;
+
+	private final int[] toProjectedField;
+	private final RowData.FieldGetter[] formatFieldGetters;
+
+	public DeserializationSchemaAdapter(
+			DeserializationSchema<RowData> deserializationSchema,
+			TableSchema schema,
+			int[] projectFields,
+			List<String> partitionKeys,
+			String defaultPartValue) {
+		this.deserializationSchema = deserializationSchema;
+		this.fieldNames = schema.getFieldNames();
+		this.fieldTypes = schema.getFieldDataTypes();
+		this.projectFields = projectFields;
+		this.partitionKeys = partitionKeys;
+		this.defaultPartValue = defaultPartValue;
+
+		List<String> projectedNames = Arrays.stream(projectFields)
+				.mapToObj(idx -> schema.getFieldNames()[idx])
+				.collect(Collectors.toList());
+
+		this.projectedRowType = RowType.of(
+				Arrays.stream(projectFields).mapToObj(idx ->
+						schema.getFieldDataTypes()[idx].getLogicalType()).toArray(LogicalType[]::new),
+				projectedNames.toArray(new String[0]));
+
+		List<String> formatFields = Arrays.stream(schema.getFieldNames())
+				.filter(field -> !partitionKeys.contains(field))
+				.collect(Collectors.toList());
+
+		List<String> formatProjectedFields = projectedNames.stream()
+				.filter(field -> !partitionKeys.contains(field))
+				.collect(Collectors.toList());
+
+		this.toProjectedField = formatProjectedFields.stream()
+				.mapToInt(projectedNames::indexOf)
+				.toArray();
+
+		this.formatFieldGetters = new RowData.FieldGetter[formatProjectedFields.size()];
+		for (int i = 0; i < formatProjectedFields.size(); i++) {
+			String name = formatProjectedFields.get(i);
+			this.formatFieldGetters[i] = RowData.createFieldGetter(
+					schema.getFieldDataType(name).get().getLogicalType(),
+					formatFields.indexOf(name));
+		}
+	}
+
+	private DeserializationSchema<RowData> createDeserialization() throws IOException {
+		try {
+			DeserializationSchema<RowData> deserialization = InstantiationUtil.clone(deserializationSchema);
+			deserialization.open(new DeserializationSchema.InitializationContext() {
+				@Override
+				public MetricGroup getMetricGroup() {
+					throw new UnsupportedOperationException("MetricGroup is unsupported in BulkFormat.");
+				}
+
+				@Override
+				public UserCodeClassLoader getUserCodeClassLoader() {
+					return (UserCodeClassLoader) Thread.currentThread().getContextClassLoader();
+				}
+			});
+			return deserialization;
+		} catch (Exception e) {
+			throw new IOException(e);
+		}
+	}
+
+	@Override
+	public Reader createReader(Configuration config, FileSourceSplit split) throws IOException {
+		return new Reader(config, split);
+	}
+
+	@Override
+	public Reader restoreReader(Configuration config, FileSourceSplit split) throws IOException {
+		Reader reader = new Reader(config, split);
+		reader.seek(split.getReaderPosition().get().getRecordsAfterOffset());
+		return null;

Review comment:
       Streaming restore case: no test cover

##########
File path: flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/filesystem/FileSystemTableSink.java
##########
@@ -251,6 +258,14 @@ private RowDataPartitionComputer partitionComputer() {
 				//noinspection unchecked
 				return Optional.of(FileInputFormatCompactReader.factory((FileInputFormat<RowData>) format));
 			}
+		} else if (deserializationFormat != null) {
+			// NOTE, we need pass full format types to deserializationFormat
+			DeserializationSchema<RowData> decoder = deserializationFormat.createRuntimeDecoder(
+					createSourceContext(context), getFormatDataType());
+			int[] projectedFields = IntStream.of(0, schema.getFieldCount()).toArray();

Review comment:
       Streaming sink compaction case: no test cover




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #13957: [FLINK-19823][table][fs-connector] Filesystem connector supports de/serialization schema

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13957:
URL: https://github.com/apache/flink/pull/13957#issuecomment-722961884


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "eded6a80f900965a008691d061057dae9c0d7cfe",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9152",
       "triggerID" : "eded6a80f900965a008691d061057dae9c0d7cfe",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0c4e62b055b5cd62d95be004423262ed9ce5eb86",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9235",
       "triggerID" : "0c4e62b055b5cd62d95be004423262ed9ce5eb86",
       "triggerType" : "PUSH"
     }, {
       "hash" : "f9c06b641c424a4e3f4e91ecc668b599dd45b6e1",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9240",
       "triggerID" : "f9c06b641c424a4e3f4e91ecc668b599dd45b6e1",
       "triggerType" : "PUSH"
     }, {
       "hash" : "41b8b8583a8b8e08979515d6bcb1475fdd231664",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "41b8b8583a8b8e08979515d6bcb1475fdd231664",
       "triggerType" : "PUSH"
     }, {
       "hash" : "e71978fc6c6da487d3b75da6a3fa8b86d6bd2f2e",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9242",
       "triggerID" : "e71978fc6c6da487d3b75da6a3fa8b86d6bd2f2e",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * eded6a80f900965a008691d061057dae9c0d7cfe Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9152) 
   * 0c4e62b055b5cd62d95be004423262ed9ce5eb86 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9235) 
   * f9c06b641c424a4e3f4e91ecc668b599dd45b6e1 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9240) 
   * 41b8b8583a8b8e08979515d6bcb1475fdd231664 UNKNOWN
   * e71978fc6c6da487d3b75da6a3fa8b86d6bd2f2e Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9242) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #13957: [FLINK-19823][table][fs-connector] Filesystem connector supports de/serialization schema

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13957:
URL: https://github.com/apache/flink/pull/13957#issuecomment-722961884


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "eded6a80f900965a008691d061057dae9c0d7cfe",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9152",
       "triggerID" : "eded6a80f900965a008691d061057dae9c0d7cfe",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0c4e62b055b5cd62d95be004423262ed9ce5eb86",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9235",
       "triggerID" : "0c4e62b055b5cd62d95be004423262ed9ce5eb86",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * eded6a80f900965a008691d061057dae9c0d7cfe Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9152) 
   * 0c4e62b055b5cd62d95be004423262ed9ce5eb86 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9235) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org