You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2023/01/13 09:42:12 UTC

[GitHub] [hudi] scxwhite commented on a diff in pull request #7664: [HUDI-5551] support seconds unit on event_time

scxwhite commented on code in PR #7664:
URL: https://github.com/apache/hudi/pull/7664#discussion_r1069151140


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/WriteStatus.java:
##########
@@ -101,7 +101,18 @@ public void markSuccess(HoodieRecord record, Option<Map<String, String>> optiona
       String eventTimeVal = optionalRecordMetadata.get().getOrDefault(METADATA_EVENT_TIME_KEY, null);
       try {
         if (!StringUtils.isNullOrEmpty(eventTimeVal)) {
-          long eventTime = DateTimeUtils.parseDateTime(eventTimeVal).toEpochMilli();
+          int length = eventTimeVal.length();
+          long millisEventTime;
+          // eventTimeVal in seconds unit
+          if (length == 10) {
+            millisEventTime = Long.parseLong(eventTimeVal) * 1000;
+          } else if (length == 13) {
+            // eventTimeVal in millis unit
+            millisEventTime = Long.parseLong(eventTimeVal);
+          } else {
+            throw new IllegalArgumentException("not support event_time format:" + eventTimeVal);

Review Comment:
   > Is it reasonable to throw directly here ? And if possible, can we add some tests.
   Thanks for your review.
   This code is in try catch block. When the user's log level is set to debug, you can see these exception logs.
   I will try to add some tests next week.



##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/WriteStatus.java:
##########
@@ -101,7 +101,18 @@ public void markSuccess(HoodieRecord record, Option<Map<String, String>> optiona
       String eventTimeVal = optionalRecordMetadata.get().getOrDefault(METADATA_EVENT_TIME_KEY, null);
       try {
         if (!StringUtils.isNullOrEmpty(eventTimeVal)) {
-          long eventTime = DateTimeUtils.parseDateTime(eventTimeVal).toEpochMilli();
+          int length = eventTimeVal.length();
+          long millisEventTime;
+          // eventTimeVal in seconds unit
+          if (length == 10) {
+            millisEventTime = Long.parseLong(eventTimeVal) * 1000;
+          } else if (length == 13) {
+            // eventTimeVal in millis unit
+            millisEventTime = Long.parseLong(eventTimeVal);
+          } else {
+            throw new IllegalArgumentException("not support event_time format:" + eventTimeVal);

Review Comment:
   > Is it reasonable to throw directly here ? And if possible, can we add some tests.
   
   Thanks for your review.
   This code is in try catch block. When the user's log level is set to debug, you can see these exception logs.
   I will try to add some tests next week.



-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org