Skip to content

GH-51273: [Ruby] Add FixedSizeListArray values constructor - #51274

Merged
kou merged 2 commits into
apache:mainfrom
emecii:gh-51273-fixed-size-list
Sep 24, 2026
Merged

kou merged 2 commits into
apache:mainfrom
emecii:gh-51273-fixed-size-list

Conversation

@emecii

@emecii emecii commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Rationale for this change

GH-50382 requests explicit value constructors for all existing ArrowFormat::Type subclasses before the broader builder API is exposed. Fixed-size lists still require callers to manually construct the parent validity buffer and flattened child array.

This is the focused fixed-size-list prerequisite requested in the GH-50382 maintainer discussion. It is distinct from variable-size ListArray support in GH-51262.

What changes are included in this PR?

  • Add ArrowFormat::FixedSizeListArray.new(type, values) while preserving the existing low-level four-argument constructor.
  • Build the parent validity bitmap and the child array from nested Ruby values.
  • Preserve exactly type.size child slots for null parent lists.
  • Reject non-null lists whose size differs from the declared fixed size.
  • Delegate child construction to the declared child field type.
  • Add focused coverage for typed construction, parent and child nulls, invalid sizes, empty input, and the low-level constructor.

Are these changes tested?

Yes.

RUBYLIB=/opt/homebrew/lib/ruby/gems/4.0.0/gems/red-arrow-25.0.1/lib GI_TYPELIB_PATH=/opt/homebrew/lib/girepository-1.0 bundle exec ruby test/run.rb test-fixed-size-list-array.rb
# 6 tests, 12 assertions, 0 failures, 0 errors

RUBYLIB=/opt/homebrew/lib/ruby/gems/4.0.0/gems/red-arrow-25.0.1/lib GI_TYPELIB_PATH=/opt/homebrew/lib/girepository-1.0 bundle exec rake test
# 696 tests, 705 assertions, 0 failures, 0 errors

I also wrote an Arrow IPC file containing [[1, 2], nil, [3, nil]] with the new constructor and loaded it with the native Arrow reader; the values round-tripped unchanged.

The tests use the current red-arrow-format sources with the locally installed Arrow 25.0.1 native extension. Upstream CI remains authoritative for the matching main-branch native runtime.

Are there any user-facing changes?

Yes. ArrowFormat::FixedSizeListArray gains a two-argument values constructor. The existing low-level constructor remains supported.

AI assistance disclosure

OpenAI Codex assisted with issue research, implementation, test generation, validation commands, and drafting this pull request. The submitted behavior is supported by the focused regression, full package suite, and IPC round-trip results above.

@emecii
emecii force-pushed the gh-51273-fixed-size-list branch from 59cd9df to 316c16d Compare September 13, 2026 04:42

@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 on lines +60 to +65

def test_low_level
child = ArrowFormat::Int16Array.new([1, 2])
array = ArrowFormat::FixedSizeListArray.new(@type, 1, nil, child)
assert_equal([[1, 2]], array.to_a)
end

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.

We don't need this because this case is already tested in the reader tests.

Suggested change
def test_low_level
child = ArrowFormat::Int16Array.new([1, 2])
array = ArrowFormat::FixedSizeListArray.new(@type, 1, nil, child)
assert_equal([[1, 2]], array.to_a)
end

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed both redundant checks in 2e9f61c. The Ruby format suite passes: 700 tests, 714 assertions.

values = [[-1, 0], [1, 2]]
array = ArrowFormat::FixedSizeListArray.new(@type, values)
assert_same(@type, array.type)
assert_same(@type.child.type, array.child.type)

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.

This is redundant. assert_same(@type, array.type) covers this.

Suggested change
assert_same(@type.child.type, array.child.type)

@github-actions github-actions Bot added awaiting merge Awaiting merge and removed awaiting review Awaiting review labels Sep 21, 2026
@emecii

emecii commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

The Windows MinGW job failed before compilation: MSYS2 downloads for clang, boost and ghostscript timed out (log). Could you rerun that job? GitHub rejected my retry with HTTP 403 (repository admin rights required).

@kou

kou commented Sep 24, 2026

Copy link
Copy Markdown
Member

Re-run the job and the job passed.

I'll merge this.

@kou
kou merged commit 1f789ff into apache:main Sep 24, 2026
38 of 39 checks passed
@kou kou removed the awaiting merge Awaiting merge label Sep 24, 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