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

GH-44742: [Ruby] Fix a bug that empty struct list value can't be built #44763

Merged
merged 1 commit into from
Nov 19, 2024

Conversation

kou
Copy link
Member

@kou kou commented Nov 18, 2024

Rationale for this change

This codes add a list value but no struct value isn't added:

require "arrow"

schema = Arrow::Schema.new(
  [
   Arrow::Field.new("structs", Arrow::ListDataType.new(
     Arrow::StructDataType.new([
       Arrow::Field.new("foo", :int64),
       Arrow::Field.new("bar", :int64)
     ])
   ))
 ]
)

Arrow::RecordBatchBuilder.build(schema, [{structs: []}])

What changes are included in this PR?

Don't add a list value.

Are these changes tested?

Yes.

Are there any user-facing changes?

Yes.

Copy link

⚠️ GitHub issue #44742 has been automatically assigned in GitHub to PR creator.

@kou
Copy link
Member Author

kou commented Nov 19, 2024

+1

@kou kou merged commit 66c2cf0 into apache:main Nov 19, 2024
9 checks passed
@kou kou removed the awaiting committer review Awaiting committer review label Nov 19, 2024
@kou kou deleted the ruby-list-buidler-empty branch November 19, 2024 00:46
Copy link

After merging your PR, Conbench analyzed the 3 benchmarking runs that have been run so far on merge-commit 66c2cf0.

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.

kou added a commit that referenced this pull request Dec 9, 2024
)

### Rationale for this change

`Arrow::ListArrayBuilder#append_value` with `[]` must append an empty list as an element. In general, it works but it doesn't work when list item is struct or list. Because `Arrow::{List,Struct}ArrayBuilder#append` without arguments appends an element. It's for a backward compatibility. But it has a problem for this case.

For example, the following case has this problem:

```ruby
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
array.to_a # => must be [[]] but [] without this change
```

### What changes are included in this PR?

This should be fixed by GH-44763 but the fix was wrong. This change fixes wrong `return if` location.

### Are these changes tested?

Yes.

### Are there any user-facing changes?

Yes.
* GitHub Issue: #44918

Authored-by: Sutou Kouhei <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
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.

1 participant