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


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/util/DataTypeUtils.java:
##########
@@ -205,4 +211,63 @@ public static RowType addMetadataFields(
 
     return new RowType(false, mergedFields);
   }
+
+  /**
+   * Resolve the native Java object from given row data field value.
+   *
+   * <p>IMPORTANT: the logic references the row-data to avro conversion in 
{@code RowDataToAvroConverters.createConverter}
+   * and {@code HoodieAvroUtils.convertValueForAvroLogicalTypes}.
+   *
+   * @param logicalType The logical type
+   * @param fieldVal    The field value
+   * @param utcTimezone whether to use UTC timezone for timestamp data type
+   */
+  public static Object resolveOrderingValue(
+      LogicalType logicalType,
+      Object fieldVal,
+      boolean utcTimezone) {
+    switch (logicalType.getTypeRoot()) {
+      case NULL:
+        return null;
+      case TINYINT:
+        return ((Byte) fieldVal).intValue();
+      case SMALLINT:
+        return ((Short) fieldVal).intValue();
+      case DATE:
+        return LocalDate.ofEpochDay((Long) fieldVal);
+      case CHAR:
+      case VARCHAR:
+        return new Utf8(fieldVal.toString());

Review Comment:
   Utf8 is Avro type for string?



##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/util/DataTypeUtils.java:
##########
@@ -205,4 +211,63 @@ public static RowType addMetadataFields(
 
     return new RowType(false, mergedFields);
   }
+
+  /**
+   * Resolve the native Java object from given row data field value.
+   *
+   * <p>IMPORTANT: the logic references the row-data to avro conversion in 
{@code RowDataToAvroConverters.createConverter}
+   * and {@code HoodieAvroUtils.convertValueForAvroLogicalTypes}.
+   *
+   * @param logicalType The logical type
+   * @param fieldVal    The field value
+   * @param utcTimezone whether to use UTC timezone for timestamp data type
+   */
+  public static Object resolveOrderingValue(
+      LogicalType logicalType,
+      Object fieldVal,
+      boolean utcTimezone) {
+    switch (logicalType.getTypeRoot()) {
+      case NULL:
+        return null;
+      case TINYINT:
+        return ((Byte) fieldVal).intValue();
+      case SMALLINT:
+        return ((Short) fieldVal).intValue();
+      case DATE:
+        return LocalDate.ofEpochDay((Long) fieldVal);
+      case CHAR:
+      case VARCHAR:
+        return new Utf8(fieldVal.toString());

Review Comment:
   Utf8 is Avro type for string? @danny0405 



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