codope commented on a change in pull request #4404:
URL: https://github.com/apache/hudi/pull/4404#discussion_r775876469



##########
File path: 
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/execution/bulkinsert/RDDCustomColumnsSortPartitioner.java
##########
@@ -55,8 +55,17 @@ public RDDCustomColumnsSortPartitioner(String[] columnNames, 
Schema schema) {
     final String[] sortColumns = this.sortColumnNames;
     final SerializableSchema schema = this.serializableSchema;
     return records.sortBy(
-        record -> HoodieAvroUtils.getRecordColumnValues(record, sortColumns, 
schema),
+        record -> {
+          Object recordValue = HoodieAvroUtils.getRecordColumnValues(record, 
sortColumns, schema);
+          // null values are replaced with empty string for null_first order
+          if (recordValue == null) {
+            return "";

Review comment:
       Consider using `StringUtils.EMPTY_STRING`.

##########
File path: 
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/execution/bulkinsert/RDDCustomColumnsSortPartitioner.java
##########
@@ -55,8 +55,17 @@ public RDDCustomColumnsSortPartitioner(String[] columnNames, 
Schema schema) {
     final String[] sortColumns = this.sortColumnNames;
     final SerializableSchema schema = this.serializableSchema;
     return records.sortBy(
-        record -> HoodieAvroUtils.getRecordColumnValues(record, sortColumns, 
schema),
+        record -> {
+          Object recordValue = HoodieAvroUtils.getRecordColumnValues(record, 
sortColumns, schema);
+          // null values are replaced with empty string for null_first order
+          if (recordValue == null) {
+            return "";
+          } else {
+            return recordValue.toString();

Review comment:
       Consider using `StringUtils#objToString`




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to