GH-50438: Add ArrowFormat::DurationArray.new(unit, values)#50447
Conversation
|
|
There was a problem hiding this comment.
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_convertto accept aSymbolunit (or pass through an existingDurationType). - Add
DurationType#pack_templateto enable packing Ruby values into the values buffer when building arrays from Ruby objects. - Add
DurationArray.type_classand 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. |
|
|
Signed-off-by: Aaditya Srinivasan <aadityasri03@gmail.com>
4ff852b to
ac06277
Compare
|
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. |
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:
nilAre there any user-facing changes?
Yes.
ArrowFormat::DurationArray.new(unit, values)#50438