thswlsqls opened a new issue, #8764:
URL: https://github.com/apache/paimon/issues/8764

   **Search before asking**
   - [x] I searched in the [issues](https://github.com/apache/paimon/issues) 
and found nothing similar.
   
   **Paimon version**
   master @ 345526e26
   
   **Compute Engine**
   Engine-agnostic (core) — surfaces on any narrowing TIMESTAMP-to-TIMESTAMP 
cast.
   
   **Minimal reproduce step**
   `DateTimeUtils.truncate(Timestamp, int)` (paimon-common 
`.../utils/DateTimeUtils.java` line 651) counts fractional-second digits via 
`Integer.toString(ts.toLocalDateTime().getNano())`. `Integer.toString` strips 
leading zeros, so a nano value below 0.1s (e.g. `getNano()==9` → `"9"`, length 
1) is under-counted. The guard `if (fraction.length() <= precision) return ts;` 
then wrongly skips truncation. Its only caller is 
`TimestampToTimestampCastRule.create()` (higher-to-lower precision cast).
   
   **What doesn't meet your expectations?**
   Casting `.000000009` to precision 3 should yield `.000`, but the 
sub-precision nanoseconds are silently retained (result still `.000000009`). 
Likewise `.000123456` cast to precision 6 keeps `.000123456` instead of 
`.000123`.
   
   **Anything else?**
   The sibling `formatTimestamp()` in the same file pads to 9 digits (`pad(9, 
ldt.getNano())`) before counting. `truncate` should mirror it: pad, then count 
significant digits by stripping trailing zeros.
   
   **Are you willing to submit a PR?**
   - [x] I'm willing to submit a PR!
   
   


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