Skip to content

GH-50438: Add ArrowFormat::DurationArray.new(unit, values)#50447

Merged
kou merged 1 commit into
apache:mainfrom
Reranko05:gh-50438-duration-array-new
Jul 10, 2026
Merged

GH-50438: Add ArrowFormat::DurationArray.new(unit, values)#50447
kou merged 1 commit into
apache:mainfrom
Reranko05:gh-50438-duration-array-new

Conversation

@Reranko05

@Reranko05 Reranko05 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Rationale for this change

Building a duration Arrow array from Ruby objects is convenient.

What changes are included in this PR?

Accept ArrowFormat::DurationArray.new(unit, values).

Are these changes tested?

Yes.

Added tests for:

  • initialization
  • mixed values with nil
  • equality
  • sliced arrays

Are there any user-facing changes?

Yes.

@Reranko05
Reranko05 requested a review from kou as a code owner July 9, 2026 13:50
Copilot AI review requested due to automatic review settings July 9, 2026 13:50
@github-actions github-actions Bot added the awaiting review Awaiting review label Jul 9, 2026
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

⚠️ GitHub issue #50438 has been automatically assigned in GitHub to PR creator.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds Ruby support for constructing ArrowFormat::DurationArray directly from Ruby values by allowing ArrowFormat::DurationArray.new(unit, values), aligning Duration arrays with existing Time32/Time64 array construction patterns.

Changes:

  • Add DurationType.try_convert to accept a Symbol unit (or pass through an existing DurationType).
  • Add DurationType#pack_template to enable packing Ruby values into the values buffer when building arrays from Ruby objects.
  • Add DurationArray.type_class and introduce a dedicated test suite covering initialization, nil handling, equality, and slicing.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
ruby/red-arrow-format/test/test-duration-array.rb Adds tests for building DurationArray from Ruby values (including nil), equality, and sliced comparisons.
ruby/red-arrow-format/lib/arrow-format/type.rb Extends DurationType with try_convert (unit symbol support) and pack_template (packing int64 values).
ruby/red-arrow-format/lib/arrow-format/array.rb Defines DurationArray.type_class so DurationArray.new(unit, values) can resolve unit into a DurationType.

@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-duration-array.rb Outdated
@github-actions github-actions Bot added awaiting merge Awaiting merge and removed awaiting review Awaiting review labels Jul 9, 2026
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

⚠️ GitHub issue #50438 has been automatically assigned in GitHub to PR creator.

Signed-off-by: Aaditya Srinivasan <aadityasri03@gmail.com>
@Reranko05
Reranko05 force-pushed the gh-50438-duration-array-new branch from 4ff852b to ac06277 Compare July 10, 2026 02:38
Copilot AI review requested due to automatic review settings July 10, 2026 02:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@kou
kou merged commit 97b8678 into apache:main Jul 10, 2026
34 checks passed
@kou kou removed the awaiting merge Awaiting merge label Jul 10, 2026
@conbench-apache-arrow

Copy link
Copy Markdown

After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit 97b8678.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about 11 possible false positives for unstable benchmarks that are known to sometimes produce them.

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.

3 participants