alexeykudinkin commented on code in PR #7413: URL: https://github.com/apache/hudi/pull/7413#discussion_r1053766388
########## hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/execution/bulkinsert/RDDCustomColumnsSortPartitioner.java: ########## @@ -43,14 +43,14 @@ public RDDCustomColumnsSortPartitioner(HoodieWriteConfig config) { this.serializableSchema = new SerializableSchema(new Schema.Parser().parse(config.getSchema())); - this.sortColumnNames = getSortColumnName(config); + this.sortColumnNames = BulkInsertPartitioner.prependPartitionPathColumn(getSortColumnName(config), config); Review Comment: We need to make sure we only prepend for partitioned tables ########## hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/BulkInsertPartitioner.java: ########## @@ -72,4 +79,37 @@ default Option<WriteHandleFactory> getWriteHandleFactory(int partitionId) { return Option.empty(); } + /* + * If possible, we want to sort the data by partition path. Doing so will reduce the number of files written. + **/ + static String[] prependPartitionPathColumn(String[] columnNames, HoodieWriteConfig config) { + if (config.getMetadataConfig().populateMetaFields()) { Review Comment: Let's unify both branches of this conditional: the only difference b/w them should be how we obtain the partition-field (meta-field vs configured one) ########## hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/BulkInsertPartitioner.java: ########## @@ -72,4 +79,37 @@ default Option<WriteHandleFactory> getWriteHandleFactory(int partitionId) { return Option.empty(); } + /* + * If possible, we want to sort the data by partition path. Doing so will reduce the number of files written. Review Comment: Let's also elaborate that prepending partition columns wouldn't affect sorting order for partition table and hence it's a safe operation (for partition tables only though!) -- 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-unsubscr...@hudi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org