yihua commented on code in PR #13208:
URL: https://github.com/apache/hudi/pull/13208#discussion_r2059116096


##########
hudi-common/src/main/java/org/apache/hudi/common/engine/HoodieReaderContext.java:
##########
@@ -244,8 +258,22 @@ public boolean castToBoolean(Object value) {
    * @return The record key in String.
    */
   public String getRecordKey(T record, Schema schema) {
-    Object val = getValue(record, schema, RECORD_KEY_METADATA_FIELD);
-    return val.toString();
+    if (metaFieldsPopulated) {
+      Object val = getValue(record, schema, RECORD_KEY_METADATA_FIELD);
+      return val.toString();
+    }
+    return constructRecordKey(record, schema);
+  }
+
+  private String constructRecordKey(T record, Schema schema) {
+    List<Object> recordKeyValues = recordKeyFields.stream().map(recordKeyField 
-> {
+      try {
+        return getValue(record, schema, recordKeyField);
+      } catch (HoodieException e) {
+        throw new HoodieKeyException("Record key field '" + recordKeyField + 
"' does not exist in the input record");
+      }
+    }).collect(Collectors.toList());
+    return KeyGenerator.constructRecordKey(recordKeyFields, recordKeyValues);

Review Comment:
   Similar here that a function of fetching the record key value can be passed 
in to avoid constructing a list.



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