You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by "vortual (via GitHub)" <gi...@apache.org> on 2023/01/31 10:04:12 UTC

[GitHub] [hudi] vortual commented on a diff in pull request #7795: [HUDI-5651] sort the inputs by record keys for bulk insert tasks

vortual commented on code in PR #7795:
URL: https://github.com/apache/hudi/pull/7795#discussion_r1091705308


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/utils/Pipelines.java:
##########
@@ -139,10 +142,17 @@ public static DataStreamSink<Object> bulkInsert(Configuration conf, RowType rowT
         dataStream = dataStream.partitionCustom(partitioner, rowDataKeyGen::getPartitionPath);
       }
       if (conf.getBoolean(FlinkOptions.WRITE_BULK_INSERT_SORT_INPUT)) {
-        SortOperatorGen sortOperatorGen = new SortOperatorGen(rowType, partitionFields);
-        // sort by partition keys
+        String[] sortFields = partitionFields;
+        if (conf.getBoolean(FlinkOptions.WRITE_BULK_INSERT_SORT_INPUT_BY_RECORD_KEY)) {
+          // sort by record keys
+          ArrayList<String> sortList = new ArrayList<>(Arrays.asList(partitionFields));
+          Collections.addAll(sortList, conf.getString(FlinkOptions.RECORD_KEY_FIELD).split(","));
+          sortFields = sortList.toArray(new String[0]);
+        }
+        SortOperatorGen sortOperatorGen = new SortOperatorGen(rowType, sortFields);
+        // sort by partition keys or (partition keys and record keys)
         dataStream = dataStream
-            .transform("partition_key_sorter",
+            .transform("partition_and_record_key_sorter",
                 InternalTypeInfo.of(rowType),
                 sortOperatorGen.createSortOperator())

Review Comment:
   ![image](https://user-images.githubusercontent.com/22464945/215727618-219e3ec1-bb86-4e16-9cca-fce058a4fe96.png)
   Hello, I have modified the code, please help to see if there is anything else to change @danny0405 



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

To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org