Skip to content

Commit

Permalink
apacheGH-34953: [Ruby] Change null selection behavior in `Table.slice…
Browse files Browse the repository at this point in the history
…` to `:drop` (apache#34954)

### Rationale for this change

`Table.slice` behaves as `FilterOptions.null_selection_behavior = :emit_null` for backward compatibility.
But this is a differnt behavior from `Table#filter` and `Slicer::ColumnCondition#select` 
which use default option `:drop`.

This request will change the behavior of `Table#slice` to align with the default of `FilterOptions`.

### What changes are included in this PR?

Set `FilterOptions.null_selection_behavior` to the default value `:drop` from `:emit_null` .

### Are these changes tested?

Yes. Rebased after apache#34952.

### Are there any user-facing changes?

Yes.

**This PR includes breaking changes to public APIs.**

* Closes: apache#34953

Authored-by: Hirokazu SUZUKI <heronshoes877@gmail.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
  • Loading branch information
heronshoes authored and liujiacheng777 committed May 11, 2023
1 parent f4e8b59 commit 693029c
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 175 deletions.
4 changes: 1 addition & 3 deletions ruby/red-arrow/lib/arrow/table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,6 @@ def slice(*args)
end
end

filter_options = Arrow::FilterOptions.new
filter_options.null_selection_behavior = :emit_null
sliced_tables = []
slicers.each do |slicer|
slicer = slicer.evaluate if slicer.respond_to?(:evaluate)
Expand All @@ -339,7 +337,7 @@ def slice(*args)
to += n_rows if to < 0
sliced_tables << slice_by_range(from, to)
when ::Array, BooleanArray, ChunkedArray
sliced_tables << filter(slicer, filter_options)
sliced_tables << filter(slicer)
else
message = "slicer must be Integer, Range, (from, to), " +
"Arrow::ChunkedArray of Arrow::BooleanArray, " +
Expand Down
Loading

0 comments on commit 693029c

Please sign in to comment.