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


##########
hudi-common/src/main/java/org/apache/hudi/common/avro/AvroOrderingValueConverter.java:
##########
@@ -72,11 +77,28 @@ public Comparable convert(Comparable value) {
   }
 
   private Comparable convertFieldValue(Comparable value, HoodieSchema 
fieldSchema) {
-    if (value == null) {
-      return null;
+    // Decoded decimals already use the representation needed for comparison.
+    if (value == null || value instanceof BigDecimal) {
+      return value;
+    }
+    Schema avroSchema = fieldSchema.toAvroSchema();
+    LogicalType logicalType = avroSchema.getLogicalType();
+    // Normalize decoded delete values here. Timestamp precision and 
configuration
+    // handling remain shared with data records.
+    if (value instanceof String) {
+      return new Utf8((String) value);
+    }
+    if (value instanceof Date) {
+      return ((Date) value).toLocalDate();
+    }
+    if (value instanceof Timestamp) {
+      if (logicalType == LogicalTypes.localTimestampMillis() || logicalType == 
LogicalTypes.localTimestampMicros()) {
+        value = ((Timestamp) value).toLocalDateTime();

Review Comment:
   toLocalDateTime() is only an intermediate step. The ordering field in an 
insert/update record is normalized to a Long in milliseconds or microseconds. A 
delete record’s ordering value must use the same representation so they can be 
compared. So the following helper is stilled needed to produce the matching 
representation.



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