Subodh-17 opened a new pull request, #12477: URL: https://github.com/apache/arrow-rs/pull/12477
# Which issue does this PR close? - Closes #12425. # Rationale for this change `take` with null indices on an empty or zero-sliced `StructArray` or `FixedSizeListArray` still fails when a child is `RunEndEncoded` with a non-nullable values field or `Union` with no nullable field, even though #12365 fixed the non-empty parent case and the parent's own validity bitmap records those rows as null. In `take_masked_child`, `values.is_empty()` previously fell back unconditionally to `take_impl(values, indices)`. That forwarded null indices directly into `take_run` or `take_union_type_ids`, failing instead of returning an all-null parent array with an unmasked placeholder child. # What changes are included in this PR? - In `arrow-select/src/take.rs`, update `take_masked_child` so that when `values.is_empty()`, every index is null (`indices.null_count() == indices.len()`), and `can_construct_take_placeholder(values.data_type())` holds, it constructs a length-`indices.len()` placeholder child via `ArrayData::new_null` stripped of inner null bitmaps (`strip_non_null_datatype_nulls`). - Keep 0-field unions (and `RunEndEncoded` / `Dictionary` wrappers around a 0-field union) on `take_impl` so they continue returning their existing `ComputeError` rather than panicking inside `ArrayData::new_null`. - Keep mixed null/non-null indices (`0 < indices.null_count() < indices.len()`) and non-null indices on `take_impl` so out-of-bounds validation (`check_bounds: true` and unchecked error/panic behavior) is unchanged. - Handle empty inner `Dictionary` value buffers inside `strip_non_null_datatype_nulls` so placeholder `RunEndEncoded` or `Union` children holding non-nullable dictionaries pass `validate_full()` with zero key bounds errors. # Are these changes tested? Yes: - Updated `test_take_null_indices_masked_by_parent` in `arrow-select/src/take.rs` so empty/zero-sliced `RunEndEncoded` and single-child non-nullable `Union` arrays now succeed while 0-field `Union` (and `RunEndEncoded` over 0-field `Union`) still preserve their error. - Added `test_take_null_indices_masked_by_empty_parent` and `test_take_mixed_oob_indices_empty_parent_not_masked` covering empty and `.slice(1, 0)` / `.slice(0, 0)` `StructArray` and `FixedSizeListArray` parents (including length 0 and length 2, nested `Struct`, and empty `REE` over non-nullable `Dictionary`), `validate_full()`, null-free child constraints, empty indices, and out-of-bounds `[Some(0), None]` / `[Some(0)]` behavior. - Pre-fix ablation confirmed failure on `origin/main` (`fcef72b`). Locally validated after the final edit with formatting (`cargo fmt --all -- --check`), strict clippy (`arrow-select --all-targets`), `arrow-select` (`535` unit tests + `filter_bits` bench + `20` doctests), `arrow-cast` (`78` unit + `367` integration tests), and `arrow-ord` (`277` unit tests). Note: offline `cargo test -p arrow --lib` could not run locally because `memmap2 v0.9.12` is absent from the offline Cargo cache; full workspace CI will cover it. # Are there any significant user-facing changes? None (no public API changes). # AI usage disclosure An AI coding assistant (Antigravity) assisted with reproducing #12425, writing the localized fix and regression tests in `arrow-select/src/take.rs`, and auditing edge cases (`Dictionary` / 0-field `Union` / OOB invariants). I reviewed the full diff and verified the pre-fix failure and post-fix validation results locally. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
