Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ruby] Creating a table based on an empty ChunkedArray raises exception #35681

Closed
stenlarsson opened this issue May 19, 2023 · 1 comment · Fixed by #35682
Closed

[Ruby] Creating a table based on an empty ChunkedArray raises exception #35681

stenlarsson opened this issue May 19, 2023 · 1 comment · Fixed by #35682

Comments

@stenlarsson
Copy link
Contributor

Describe the bug, including details regarding any error messages, version, and platform.

In some situations we end up with an empty table. When trying to create a new table based on this it crashes. Here is the simplest example I can think of:

require 'arrow'

array = Arrow::Int64DataType.new.build_array([1])
table = Arrow::Table.new('foo' => array)
empty_table = table.filter([false])
empty_table.select_columns('foo')

This results in the following exception:

/Users/stenlarsson/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/gobject-introspection-4.1.2/lib/gobject-introspection/loader.rb:689:in `invoke': [chunked-array][combine]: Invalid: Must pass at least one array (Arrow::Error::Invalid)
	from /Users/stenlarsson/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/gobject-introspection-4.1.2/lib/gobject-introspection/loader.rb:689:in `invoke'
	from /Users/stenlarsson/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/gobject-introspection-4.1.2/lib/gobject-introspection/loader.rb:560:in `combine'
	from /Users/stenlarsson/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/red-arrow-11.0.0/lib/arrow/chunked-array.rb:32:in `to_arrow_array'
	from /Users/stenlarsson/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/red-arrow-11.0.0/lib/arrow/array.rb:53:in `try_convert'
	from /Users/stenlarsson/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/gobject-introspection-4.1.2/lib/gobject-introspection/registered-type-info.rb:31:in `try_convert'
	from /Users/stenlarsson/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/gobject-introspection-4.1.2/lib/gobject-introspection/type-tag.rb:172:in `try_convert_interface'
	from /Users/stenlarsson/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/gobject-introspection-4.1.2/lib/gobject-introspection/type-tag.rb:22:in `try_convert'
	from /Users/stenlarsson/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/gobject-introspection-4.1.2/lib/gobject-introspection/type-info.rb:20:in `try_convert'
	from /Users/stenlarsson/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/gobject-introspection-4.1.2/lib/gobject-introspection/type-tag.rb:120:in `block in try_convert_array_like'
	from /Users/stenlarsson/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/gobject-introspection-4.1.2/lib/gobject-introspection/type-tag.rb:118:in `collect'
	from /Users/stenlarsson/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/gobject-introspection-4.1.2/lib/gobject-introspection/type-tag.rb:118:in `try_convert_array_like'
	from /Users/stenlarsson/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/gobject-introspection-4.1.2/lib/gobject-introspection/type-tag.rb:146:in `try_convert_array'
	from /Users/stenlarsson/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/gobject-introspection-4.1.2/lib/gobject-introspection/type-tag.rb:22:in `try_convert'
	from /Users/stenlarsson/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/gobject-introspection-4.1.2/lib/gobject-introspection/type-info.rb:20:in `try_convert'
	from /Users/stenlarsson/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/gobject-introspection-4.1.2/lib/gobject-introspection/loader.rb:777:in `block in normalize_arguments!'
	from /Users/stenlarsson/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/gobject-introspection-4.1.2/lib/gobject-introspection/loader.rb:774:in `times'
	from /Users/stenlarsson/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/gobject-introspection-4.1.2/lib/gobject-introspection/loader.rb:774:in `normalize_arguments!'
	from /Users/stenlarsson/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/gobject-introspection-4.1.2/lib/gobject-introspection/loader.rb:679:in `invoke'
	from /Users/stenlarsson/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/gobject-introspection-4.1.2/lib/gobject-introspection/loader.rb:347:in `block (2 levels) in initialize'
	from /Users/stenlarsson/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/gobject-introspection-4.1.2/lib/gobject-introspection/loader.rb:346:in `catch'
	from /Users/stenlarsson/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/gobject-introspection-4.1.2/lib/gobject-introspection/loader.rb:346:in `block in initialize'
	from /Users/stenlarsson/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/gobject-introspection-4.1.2/lib/gobject-introspection/loader.rb:345:in `each'
	from /Users/stenlarsson/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/gobject-introspection-4.1.2/lib/gobject-introspection/loader.rb:345:in `initialize'
	from /Users/stenlarsson/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/red-arrow-11.0.0/lib/arrow/table.rb:184:in `initialize'
	from /Users/stenlarsson/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/red-arrow-11.0.0/lib/arrow/column-containable.rb:102:in `new'
	from /Users/stenlarsson/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/red-arrow-11.0.0/lib/arrow/column-containable.rb:102:in `select_columns'
	from empty_table_bug.rb:6:in `<main>'

What happens here is that we end up with a ChunkedArray with no Arrays inside, and you are not allowed to call combine on it. Note that this doesn't happen if you have a ChunkedArray with one empty array.

Component(s)

Ruby

kou added a commit that referenced this issue May 19, 2023
…5682)

### Rationale for this change

We can't use `garrow_chunked_array_combine()` with an empty `GArrowChunkedArray`.

### What changes are included in this PR?

Create an empty array instead of combining with an empty `GArrowChunkedArray`.

### Are these changes tested?

Yes.

### Are there any user-facing changes?

Yes.
* Closes: #35681

Authored-by: Sutou Kouhei <kou@clear-code.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
@kou kou added this to the 13.0.0 milestone May 19, 2023
@kou
Copy link
Member

kou commented May 19, 2023

Thanks for your report!
I've fixed this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants