edubraqd opened a new pull request, #24908:
URL: https://github.com/apache/datafusion/pull/24908
## Which issue does this PR close?
- Closes #24907.
## Rationale for this change
`compute_partition_keys_by_row` turned `Date32` / `Date64` partition values
into `yyyy-mm-dd` path segments with unchecked arithmetic and an `unwrap`, so a
value outside the range of `chrono::NaiveDate` panicked the writer task
("attempt to add with overflow" or "called `Option::unwrap()` on a `None`
value").
## What changes are included in this PR?
Use checked conversions and return an execution error naming the value. For
`Date64` the milliseconds are converted to days with `div_euclid`, so a value
before the epoch lands on the correct calendar day, and the day count is
range-checked before it is narrowed to `i32`. The date formatting is shared by
both branches.
## Are these changes tested?
Yes. `copy.slt` now partitions by a date column (including a pre-epoch date)
and checks the three out-of-range cases return an error; they used to panic.
## Are there any user-facing changes?
An out-of-range date in a `PARTITIONED BY` column produces an execution
error instead of a panic. A `Date64` value before the epoch is now placed in
the correct day's partition.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]