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


##########
hudi-common/src/main/java/org/apache/hudi/common/table/timeline/HoodieInstantTimeGenerator.java:
##########
@@ -106,17 +106,18 @@ public static String instantTimePlusMillis(String 
timestamp, long milliseconds)
   }
 
   public static String instantTimeMinusMillis(String timestamp, long 
milliseconds) {
+    final String timestampInMillis = fixInstantTimeCompatibility(timestamp);
     try {
-      String timestampInMillis = fixInstantTimeCompatibility(timestamp);
-      // To work with tests, that generate arbitrary timestamps, we need to 
pad the timestamp with 0s.
-      if (timestampInMillis.length() < MILLIS_INSTANT_TIMESTAMP_FORMAT_LENGTH) 
{
-        return String.format("%0" + timestampInMillis.length() + "d", 0);
-      }
       LocalDateTime dt = LocalDateTime.parse(timestampInMillis, 
MILLIS_INSTANT_TIME_FORMATTER);
       ZoneId zoneId = HoodieTimelineTimeZone.UTC.equals(commitTimeZone) ? 
ZoneId.of("UTC") : ZoneId.systemDefault();
       return 
MILLIS_INSTANT_TIME_FORMATTER.format(dt.atZone(zoneId).toInstant().minusMillis(milliseconds).atZone(zoneId).toLocalDateTime());
     } catch (DateTimeParseException e) {
-      throw new HoodieException(e);
+      // To work with tests, that generate arbitrary timestamps, we need to 
pad the timestamp with 0s.
+      if (isValidInstantTime(timestampInMillis)) {
+        return String.format("%0" + timestampInMillis.length() + "d", 
Long.parseLong(timestampInMillis) - milliseconds);
+      } else {
+        throw new HoodieException(e);
+      }

Review Comment:
   > do we allow arbitrary timestamps any more
   
   we allows it now, because the start instant time does not really affect the 
correctness, only the compaction instant time and completion time does.
   
   It's better to add real time for tests in the future to keep the test more 
in line with real production env.



-- 
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-unsubscr...@hudi.apache.org

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

Reply via email to