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

   **Search before asking**
   - [x] I searched in the [issues](https://github.com/apache/paimon/issues) 
and found nothing similar.
   
   **Paimon version**
   master @ ffe8e5127
   
   **Compute Engine**
   Engine-agnostic (paimon-arrow writer, used by `ArrowFormatWriter` / 
`ArrowFormatCWriter`)
   
   **Minimal reproduce step**
   Write a `TIMESTAMP(0)` or `TIMESTAMP_LTZ(0)` value that is before the epoch 
and carries sub-second millis, e.g. `Timestamp.fromEpochMillis(-500)` (wall 
clock `1969-12-31T23:59:59.500`), through 
`ArrowFormatWriter.write(InternalRow)` and read it back with 
`ArrowBatchReader.readBatch()`.
   
   `ArrowUtils.nonCastedTimestampToEpoch()` 
(paimon-arrow/src/main/java/org/apache/paimon/arrow/ArrowUtils.java line 328) 
computes the epoch second as `timestamp.getMillisecond() / 1000`. Java integer 
division truncates towards zero, so `-500 / 1000` is `0` instead of `-1`.
   
   **What doesn't meet your expectations?**
   Expected `1969-12-31T23:59:59`; actual `1970-01-01T00:00` — the value moves 
forward across the epoch boundary into a different year.
   
   The other precision branches are already negative-safe, and the read 
direction was fixed the same way in #9299 
(`Arrow2PaimonVectorConverter.convertEpochToTimestamp` uses 
`Math.floorDiv`/`Math.floorMod`).
   
   **Anything else?**
   N/A
   
   **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