You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@paimon.apache.org by "thswlsqls (via GitHub)" <gi...@apache.org> on 2026/07/21 03:34:24 UTC

[PR] [common] Fix DateTimeUtils.truncate dropping sub-precision fractional seconds [paimon]

thswlsqls opened a new pull request, #8767:
URL: https://github.com/apache/paimon/pull/8767

   ### Purpose
   
   fix #8764
   
   - `DateTimeUtils.truncate(Timestamp, int)` counted fractional-second digits with `Integer.toString(ts.toLocalDateTime().getNano())`, which strips leading zeros and under-counts fractions below 0.1s.
   - The short-circuit guard `if (fraction.length() <= precision) return ts;` then wrongly skipped truncation, so a narrowing precision cast (`TimestampToTimestampCastRule`) silently retained sub-precision nanoseconds — e.g. `.000000009`→precision 3 stayed `.000000009` instead of `.000`.
   - Now pad to 9 digits and count significant digits by stripping trailing zeros, mirroring the sibling `formatTimestamp()` in the same file.
   
   ### Tests
   
   - Added `DateTimeUtilsTest#testTruncateDropsSubPrecisionFraction` (`.000000009`→p3, `.000123456`→p6 with independent hardcoded expected nanos), `#testTruncateIsIdempotent`, `#testTruncateNoOpAtMaxPrecision`.
   - `mvn -pl paimon-common -DfailIfNoTests=false clean install` — BUILD SUCCESS (checkstyle + spotless + rat + all paimon-common tests passed), JDK 11.
   


-- 
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: issues-unsubscribe@paimon.apache.org

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


Re: [PR] [common] Fix DateTimeUtils.truncate dropping sub-precision fractional seconds [paimon]

Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on PR #8767:
URL: https://github.com/apache/paimon/pull/8767#issuecomment-5030415185

   +1


-- 
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: issues-unsubscribe@paimon.apache.org

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


Re: [PR] [common] Fix DateTimeUtils.truncate dropping sub-precision fractional seconds [paimon]

Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi merged PR #8767:
URL: https://github.com/apache/paimon/pull/8767


-- 
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: issues-unsubscribe@paimon.apache.org

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