Repository navigation
GH-55256: [C++][Compute] Support string_view, binary_view, decimal32, and decimal64 in vector replace kernels - #55257
Open
Awesome06 wants to merge 1 commit into
Conversation
…mal32, and decimal64 in vector replace kernels ### Rationale for this change Vector replace kernels (`replace_with_mask`, `fill_null_forward`, and `fill_null_backward`) in `arrow/compute` lacked kernel registrations and specializations for modern Arrow data types: 1. Columnar String/Binary Views (`utf8_view`, `binary_view`): Attempting to run `replace_with_mask` or `fill_null` raised `NotImplemented: Function 'replace_with_mask' has no kernel matching input types`. 2. Small Decimals (`decimal32`, `decimal64`): Missing kernel registrations in `RegisterVectorFunction` prevented 4-byte and 8-byte decimals from using the existing `FixedSizeBinary` replace functors. ### What changes are included in this PR? 1. Registered `Type::DECIMAL32` and `Type::DECIMAL64` with `Functor<FixedSizeBinaryType>`. Since small decimals inherit from `DecimalType` (`FixedSizeBinaryType`), their byte widths (4 and 8 bytes) are natively supported by the fixed-width copy functors. 2. Updated template condition on line 123 of `vector_replace.cc` to exclude `is_binary_view_like_type<Type>::value` from the fixed-width fallback implementation. 3. Implemented `ReplaceMaskImpl<Type, enable_if_binary_view_like<Type>>` using `util::FromBinaryView` and `BinaryViewBuilder` for both scalar mask and array mask replacements. 4. Implemented `FillNullImpl<Type, enable_if_binary_view_like<Type>>` using `util::FromBinaryView` and `BinaryViewBuilder` for both forward and backward propagation. 5. Registered `Type::BINARY_VIEW` and `Type::STRING_VIEW` kernels across `replace_with_mask`, `fill_null_forward`, and `fill_null_backward`. 6. Added comprehensive C++ unit tests in `cpp/src/arrow/compute/kernels/vector_replace_test.cc` covering the Antagonistic Test Quartet (storage tiers, asymmetric slicing, embedded nulls, chunked carry-over, and decimals). 7. Added Python unit tests in `python/pyarrow/tests/test_compute.py` for views and small decimals. ### Are these changes tested? Yes, all changes are covered by comprehensive unit tests in C++ (`vector_replace_test.cc`) and Python (`test_compute.py`). ### Are there any user-facing changes? No breaking changes. This extends existing compute functions (`replace_with_mask`, `fill_null_forward`, and `fill_null_backward`) to support `string_view`, `binary_view`, `decimal32`, and `decimal64`. ### Was AI used for this PR? In accordance to the AI generation guidelines, please disclose below whether and how AI was used in this PR. PR code and description written by: - [x] Human - [x] AI Reviewed before submission by: - [x] Human - [ ] AI - [ ] Not reviewed * GitHub Issue: apache#55256 Closes apache#55256
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
Vector replace kernels (
replace_with_mask,fill_null_forward, andfill_null_backward) inarrow/computelacked kernel registrations and specializations for modern Arrow data types:utf8_view,binary_view): Attempting to runreplace_with_maskorfill_nullraisedNotImplemented: Function 'replace_with_mask' has no kernel matching input types.decimal32,decimal64): Missing kernel registrations inRegisterVectorFunctionprevented 4-byte and 8-byte decimals from using the existingFixedSizeBinaryreplace functors.What changes are included in this PR?
Kernel Registrations & View Support in
vector_replace.cc:Type::DECIMAL32andType::DECIMAL64withFunctor<FixedSizeBinaryType>. Since small decimals inherit fromDecimalType(FixedSizeBinaryType), their byte widths (4 and 8 bytes) are natively supported by the fixed-width copy functors.vector_replace.ccto excludeis_binary_view_like_type<Type>::valuefrom the fixed-width fallback implementation.ReplaceMaskImpl<Type, enable_if_binary_view_like<Type>>usingutil::FromBinaryViewandBinaryViewBuilderfor both scalar mask and array mask replacements.FillNullImpl<Type, enable_if_binary_view_like<Type>>usingutil::FromBinaryViewandBinaryViewBuilderfor both forward and backward propagation.Type::BINARY_VIEWandType::STRING_VIEWkernels acrossreplace_with_mask,fill_null_forward, andfill_null_backward.Unit Tests in
vector_replace_test.cc:TestVectorReplace.TestIssue55256: Minimal reproduction test covering all four types acrossreplace_with_mask,fill_null_forward, andfill_null_backward.TestVectorReplace.ReplaceWithMaskStringViewStorageTiers: Storage tier boundary tests covering inline short strings (0, 4, 11, 12 bytes), out-of-line strings (13 bytes, long, 4500-byte strings), scalar replacements, and scalar masks (true,false,null).TestVectorReplace.ReplaceWithMaskAsymmetricSlicing: Tests slicing with non-zero offsets on array, mask, and replacements.TestVectorReplace.ReplaceWithMaskEmbeddedNulls: Asserts full byte transparency on strings containing embedded null characters (\0) without C-string truncation.TestVectorReplace.FillNullViewsChunkedCarryOver: Multi-chunkChunkedArraycross-chunk null carry-over tests in forward and backward directions.TestVectorReplace.Decimal32AndDecimal64Full: Tests precision/scale preservation, negative values, nulls, zeroes, and validates scale-mismatch error rejection.Python Unit Tests in
python/pyarrow/tests/test_compute.py:test_replace_with_mask_viewsparameterized forpa.string_view()andpa.binary_view().test_replace_with_mask_decimalsparameterized forpa.decimal32(7, 2)andpa.decimal64(15, 2).Are these changes tested?
Yes, all changes are covered by comprehensive unit tests:
cpp/src/arrow/compute/kernels/vector_replace_test.cc.python/pyarrow/tests/test_compute.py.vector_replace.cc.objandvector_replace_test.cc.objcompile cleanly with MSVC 2019 (Exit code 0).git diff --checkpasses with zero whitespace warnings.Are there any user-facing changes?
No breaking changes. This extends existing compute functions (
replace_with_mask,fill_null_forward, andfill_null_backward) to supportstring_view,binary_view,decimal32, anddecimal64.Was AI used for this PR?
In accordance to the AI generation guidelines, please disclose below whether and how AI was used in this PR.
PR code and description written by:
Reviewed before submission by: