JingsongLi commented on a change in pull request #13605:
URL: https://github.com/apache/flink/pull/13605#discussion_r513200210



##########
File path: 
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/filesystem/FileSystemTableSink.java
##########
@@ -199,15 +202,32 @@ private Path toStagingPath() {
        }
 
        @SuppressWarnings("unchecked")
-       private OutputFormatFactory<RowData> createOutputFormatFactory() {
-               Object writer = createWriter();
+       private OutputFormatFactory<RowData> createOutputFormatFactory(Context 
sinkContext) {
+               Object writer = createWriter(sinkContext);
                return writer instanceof Encoder ?
                                path -> 
createEncoderOutputFormat((Encoder<RowData>) writer, path) :
                                path -> 
createBulkWriterOutputFormat((BulkWriter.Factory<RowData>) writer, path);
        }
 
-       private Object createWriter() {
-               FileSystemFormatFactory formatFactory = 
createFormatFactory(tableOptions);
+       private DataType getFormatDataType() {
+               TableSchema.Builder builder = TableSchema.builder();
+               schema.getTableColumns().forEach(column -> {
+                       if (!partitionKeys.contains(column.getName())) {
+                               builder.add(column);
+                       }
+               });
+               return builder.build().toRowDataType();
+       }
+
+       private Object createWriter(Context sinkContext) {
+               @SuppressWarnings("rawtypes")
+               Optional<EncodingFormat> encodingFormat = 
discoverOptionalEncodingFormat(BulkWriterFactory.class)
+                               .map(Optional::of).orElseGet(() -> 
discoverOptionalEncodingFormat(EncoderFactory.class));
+               if (encodingFormat.isPresent()) {
+                       return 
encodingFormat.get().createRuntimeEncoder(sinkContext, getFormatDataType());
+               }
+
+               FileSystemFormatFactory formatFactory = createFormatFactory();

Review comment:
       https://issues.apache.org/jira/browse/FLINK-19845




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


Reply via email to