Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions ruby/red-arrow/lib/arrow/array-builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,14 @@ def detect_builder_info(value, builder_info)
sub_builder_info = detect_builder_info(sub_value, sub_builder_info)
break if sub_builder_info and sub_builder_info[:detected]
end
if sub_builder_info and sub_builder_info[:detected]
sub_value_data_type = sub_builder_info[:builder].value_data_type
if sub_builder_info
sub_builder = sub_builder_info[:builder]
return builder_info unless sub_builder
sub_value_data_type = sub_builder.value_data_type
field = Field.new("item", sub_value_data_type)
{
builder: ListArrayBuilder.new(ListDataType.new(field)),
detected: true,
detected: !!sub_builder_info[:detected],
Copy link
Member

Choose a reason for hiding this comment

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

Is this !! for converting nil to false?

If so, we don't need it because nil is also a false value.

}
else
builder_info
Expand Down
12 changes: 12 additions & 0 deletions ruby/red-arrow/test/test-table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ def array_like.to_ary
assert_equal(Arrow::Table.new(schema, [Arrow::UInt8Array.new([1, 2, 3])]),
Arrow::Table.new(numbers: array_like))
end

test("{Symbol: nested non-negative integer Array}") do
table = Arrow::Table.new(numbers: [[0, 1, 2], [3, 4]])
assert_equal("list<item: uint8>",
table.schema["numbers"].data_type.to_s)
end

test("{Symbol: nested signed integer Array}") do
table = Arrow::Table.new(numbers: [[0, -1, 2], [3, 4]])
assert_equal("list<item: int8>",
table.schema["numbers"].data_type.to_s)
end
Copy link
Member

Choose a reason for hiding this comment

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

How about using

test("list<boolean>s") do
assert_build(Arrow::ArrayBuilder,
[
[nil, true, false],
nil,
[false],
])
end
test("list<string>s") do
assert_build(Arrow::ArrayBuilder,
[
["Hello", "World"],
["Apache Arrow"],
])
end
instead of this file?

end

test("#columns") do
Expand Down
Loading