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


##########
hudi-common/src/main/java/org/apache/hudi/common/avro/AvroRecordContext.java:
##########
@@ -107,6 +119,36 @@ public Object getValue(IndexedRecord record, HoodieSchema 
schema, String fieldNa
     return getFieldValueFromIndexedRecord(record, fieldName);
   }
 
+  @Override
+  public Comparable getOrderingValue(IndexedRecord record, HoodieSchema 
schema, List<String> orderingFieldNames) {
+    return OrderingValues.create(orderingFieldNames, field -> {
+      Object value = getOrderingValueFromIndexedRecord(record, field, 
consistentLogicalTimestampEnabled);
+      return value == null ? OrderingValues.getDefault() : 
ensureComparability(value);
+    });
+  }
+
+  @Override
+  public Comparable getOrderingValue(IndexedRecord record, HoodieSchema 
schema, String[] orderingFieldNames) {
+    return orderingFieldNames == null
+        ? OrderingValues.getDefault()
+        : OrderingValues.create(orderingFieldNames, field -> {
+          Object value = getOrderingValueFromIndexedRecord(record, field, 
consistentLogicalTimestampEnabled);
+          return value == null ? OrderingValues.getDefault() : 
ensureComparability(value);
+        });
+  }
+
+  /**
+   * Extracts an ordering field from a generic Avro record, normalizing its 
logical type.
+   *
+   * @param record the record to read; must be a {@link GenericRecord}
+   * @param fieldName the field name, which may be a nested path
+   * @param consistentLogicalTimestampEnabled whether to use consistent 
logical timestamp conversion
+   * @return the ordering value, or null if the field or its value is missing
+   */
+  public static Object getOrderingValueFromIndexedRecord(IndexedRecord record, 
String fieldName, boolean consistentLogicalTimestampEnabled) {

Review Comment:
   diff this method with `getFieldValueFromIndexedRecord` and see why we can 
not reuse `HoodieAvroUtils.getNestedFieldVal`.



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