leaves12138 commented on code in PR #833:
URL: https://github.com/apache/paimon-rust/pull/833#discussion_r4011720503


##########
crates/paimon/src/spec/partition_utils.rs:
##########
@@ -460,26 +461,28 @@ fn format_timestamp_legacy(dt: NaiveDateTime) -> String {
     let mut result = format!("{date_hour_min}:{sec:02}");
     if nano > 0 {
         let frac = format!("{nano:09}");
-        let trimmed = frac.trim_end_matches('0');
+        let digits = if nano.is_multiple_of(1_000_000) {
+            3
+        } else if nano.is_multiple_of(1_000) {
+            6
+        } else {
+            9
+        };
         result.push('.');
-        result.push_str(trimmed);
+        result.push_str(&frac[..digits]);
     }
     result
 }
 
 /// Format a timestamp using non-legacy `DateTimeUtils.formatTimestamp()` 
semantics.
 ///
 /// Always uses space separator: `yyyy-MM-dd HH:mm:ss[.fraction]`.
-/// Fraction: pad nano to 9 digits, strip trailing zeros down to at most 
`precision` digits.
+/// Fraction: pad nano to 9 digits, strip trailing zeros while keeping at 
least `precision` digits.
 fn format_timestamp_non_legacy(dt: NaiveDateTime, precision: u32) -> String {
     let nano = dt.nanosecond();
     let ymdhms = dt.format("%Y-%m-%d %H:%M:%S").to_string();
 
-    if precision == 0 || nano == 0 {
-        return ymdhms;
-    }
-
-    // Pad nano to 9 digits, then strip trailing zeros but keep at least up to 
`precision` digits.
+    // Whole seconds keep the declared precision; nonzero fractions are never 
truncated.

Review Comment:
   With the requirement clarified, Java is the authoritative format and 
compatibility with the incorrect directory spellings written by Rust 0.3.0 is 
intentionally out of scope. I am withdrawing this blocking request; no fallback 
for those spellings is needed. The Java parity and new-write/read validations 
passed, and I have no other blocking findings at 5c5acff.



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