Skip to content

GH-51271: [Ruby] Fix Date values in ArrowFormat::Date32Array - #51272

Merged
kou merged 2 commits into
apache:mainfrom
emecii:fix/ruby-arrow-format-date-inference
Sep 11, 2026
Merged

GH-51271: [Ruby] Fix Date values in ArrowFormat::Date32Array#51272
kou merged 2 commits into
apache:mainfrom
emecii:fix/ruby-arrow-format-date-inference

Conversation

@emecii

@emecii emecii commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Rationale for this change

ArrowFormat::Date32Array currently stores Date#day, the day of the month, for Ruby Date values. Arrow Date32 values are signed day offsets from the Unix epoch, so this can silently produce incorrect data. The same conversion is used by ArrowFormat::Array.build when it infers Date32.

What changes are included in this PR?

  • Convert Ruby Date values from their Julian day to the Unix epoch day offset.
  • Cover dates before, at, and after the Unix epoch, including nulls.
  • Make the ArrayBuilder regression assert the encoded payload instead of comparing two arrays built through the same conversion path.

Are these changes tested?

Yes. The full red-arrow-format suite passes locally: 691 tests and 695 assertions. The official rake runner used the current pure-Ruby sources with the locally installed Arrow 25.0.1 native extension; the local system does not have the Arrow C++ 26 dependency needed to build the native Ruby extension from main.

Are there any user-facing changes?

Yes. Ruby Date values now produce specification-compliant Date32 day offsets.

This PR contains a "Critical Fix". It fixes incorrect Date32 data produced from Ruby Date values.

AI assistance

AI assistance was used to investigate the defect, draft the focused implementation and tests, and run the verification described above. No human review is claimed.

@kou kou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Comment thread ruby/red-arrow-format/test/test-array-builder.rb Outdated
Comment thread ruby/red-arrow-format/lib/arrow-format/array.rb Outdated
@github-actions github-actions Bot added awaiting merge Awaiting merge and removed awaiting review Awaiting review labels Sep 10, 2026
@kou
kou merged commit 0087bae into apache:main Sep 11, 2026
35 of 36 checks passed
@kou kou removed the awaiting merge Awaiting merge label Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants