Repository navigation
Conversation
`COPY ... PARTITIONED BY (date_col)` panicked when a Date32/Date64 value could not be rendered as a date, and Date64 values before the epoch were placed on the wrong day because milliseconds were divided with truncation. Use Arrow's date32_to_datetime/date64_to_datetime and return an execution error naming the offending value.
Add Date32 pre-epoch and Date64 day-boundary unit cases, and sqllogictest coverage that out-of-range values error from COPY and that a negative Date64 value lands in the 1969-12-31 partition.
marko-k0
marked this pull request as ready for review
November 25, 2026 19:12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
Fork CI setup: For pull requests from a fork to
main, enable workflows in your fork's Actions tab before you push.See the fork CI setup guide.
Which issue does this PR close?
COPY ... PARTITIONED BYaDate32/Date64column panics on out-of-range values #24907.Rationale for this change
COPY ... PARTITIONED BY (date_col)panicked inside the write task when aDate32/Date64value could not be rendered as ayyyy-mm-ddpath segment, instead of failing the query. The same code also putDate64values before the epoch on the wrong day: milliseconds were divided by 86,400,000 with truncation, so-1was written as1970-01-01instead of1969-12-31.What changes are included in this PR?
date32_to_datetime/date64_to_datetimeinstead of hand-rolled epoch arithmetic. These are the conversions Arrow uses to display and cast dates, their internal math isi64soDate32cannot overflow, and they already floor negativeDate64milliseconds.EPOCH_DAYS_FROM_CEconstant andNaiveDateimport (chronois still used elsewhere in the crate).What is the testing strategy for this PR?
Unit tests in
demux.rs:partition_keys_error_on_out_of_range_date32/partition_keys_error_on_out_of_range_date64partition_keys_date64_uses_calendar_day_of_millis(day boundaries either side of the epoch)partition_keys_date32_negative_day_uses_previous_daypartition_keys_date32_epoch_and_next_daypartition_keys_far_future_dates(9999-12-31 is still accepted)partition_keys_reject_null_valuesnow also coversDate32/Date64copy.slt:COPYDate64value of-1is written to.../column2=1969-12-31and reads back as that dateAre there any user-facing changes?
Yes: out-of-range date partition values now fail with an execution error instead of panicking, and pre-epoch
Date64values go to the correct partition. No API changes.