Skip to content

Commit

Permalink
apacheGH-44742: [Ruby] Fix a bug that empty struct list value can't b…
Browse files Browse the repository at this point in the history
…e built
  • Loading branch information
kou committed Nov 18, 2024
1 parent 00de992 commit 23b02cf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions ruby/red-arrow/lib/arrow/list-array-builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def append_value(*args)
when nil
append_null
when ::Array
return if value.empty?
append_value_raw
@value_builder ||= value_builder
@value_builder.append(*value)
Expand Down
9 changes: 9 additions & 0 deletions ruby/red-arrow/test/test-list-array-builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ def setup
array = @builder.finish
assert_equal([true, false, true], array[0].to_a)
end

test("Struct[]") do
item_type = Arrow::StructDataType.new([{name: "visible", type: :boolean}])
data_type = Arrow::ListDataType.new(name: "struct", data_type: item_type)
builder = Arrow::ListArrayBuilder.new(data_type)
builder.append_value([])
array = builder.finish
assert_equal([], array[0].to_a)
end
end

sub_test_case("#append_values") do
Expand Down

0 comments on commit 23b02cf

Please sign in to comment.