dongjoon-hyun opened a new pull request, #194: URL: https://github.com/apache/arrow-swift/pull/194
## What's Changed Arrow `Date32` and `Date64` values are signed integers (days and milliseconds since the UNIX epoch), but `Date32Array` and `Date64Array` read them as `UInt32` and `UInt64`. - `Date32Array`: a negative day such as `-1` (`1969-12-31`) is read as `4294967295`, and `UInt32 * 86400` traps with `Swift runtime failure: arithmetic overflow`. Only days in `0...49710` (`1970-01-01` to `2106-02-07`) can be read. Any date before `1970-01-01` or after `2106-02-07` crashes the process, in both debug and release builds. - `Date64Array`: a negative millisecond value wraps around to a huge positive value, so `1969-12-31` is read as about `1.8e16` seconds after the epoch. - `Date32BufferBuilder`: `Int32(seconds / 86400)` truncates toward zero, so a pre-epoch `Date` that is not at UTC midnight is stored one day later. For example, `1969-12-31T12:00:00Z` becomes `1970-01-01`. This PR: - loads `Int32` in `Date32Array` and multiplies in `TimeInterval`. Loading `Int32` alone is not enough because `Int32 * 86400` overflows for dates after `2038-01-19`. - loads `Int64` in `Date64Array`. - uses `.rounded(.down)` in `Date32BufferBuilder`, so pre-epoch values are floored to their day just like post-epoch values. This was found in the Apache Spark Connect Swift client, which vendors these sources: collecting `DATE'1969-12-31'` crashed the client. ## Testing Added three regression tests to `ArrayTests`: - `testDate32ArrayOutsideUnsignedRange` checks both the stored `Int32` day and the decoded `Date` for `0001-01-01`, `1969-12-31`, `1970-01-01`, `2038-01-20`, `2106-02-07`, `2106-02-08`, and `9999-12-31`. - `testDate32BuilderPreEpochTimeOfDay` checks that pre-epoch times of day are floored to their day. - `testDate64ArrayPreEpoch` checks `0001-01-01` and `1969-12-31`. Without this fix, `testDate32ArrayOutsideUnsignedRange` crashes with signal 5, and the other two tests fail. With this fix, the full test suite passes (52 tests, 0 failures). Generated-by: Claude Opus 5 -- 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]
