danny0405 commented on code in PR #9936:
URL: https://github.com/apache/hudi/pull/9936#discussion_r1375610014


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/bulk/RowDataKeyGen.java:
##########
@@ -99,7 +99,7 @@ protected RowDataKeyGen(
       this.recordKeyProjection = null;
     } else {
       this.recordKeyFields = recordKeys.get().split(",");
-      if (this.recordKeyFields.length == 1) {
+      if (this.recordKeyFields.length == 1  && this.partitionPathFields.length 
== 1) {

Review Comment:
   Nice findings ~
   
   I kind of think the handling of `RowDataKeyGen` is correct, what we need to 
fix is the `ComplexAvroKeyGenerator`, it composite the record key string as 
`key_name:key_val` even if the record key has only one field.
   
   If we take a look at the `ComplexKeyGenerator.getRecordKey(InternalRow 
internalRow, StructType schema)`, it also eliminate the `key_name` from the 
record key string even if there are multiple partiton fields. And for 
compatible interface `getRecordKey(GenericRecord record)`, it uses the delegate 
generator `ComplexAvroKeyGenerator`, which causes the inconsistency of the two 
interfaces.
   
   In summary, I think `key_name:key_val` should be a mistake when the record 
key fields is single, it should be simplified as `key_val`.



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