Awesome06 opened a new pull request, #55257:
URL: https://github.com/apache/arrow/pull/55257
### 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. **Kernel Registrations & View Support in `vector_replace.cc`:**
- 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.
- 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.
- Implemented `ReplaceMaskImpl<Type, enable_if_binary_view_like<Type>>`
using `util::FromBinaryView` and `BinaryViewBuilder` for both scalar mask and
array mask replacements.
- Implemented `FillNullImpl<Type, enable_if_binary_view_like<Type>>`
using `util::FromBinaryView` and `BinaryViewBuilder` for both forward and
backward propagation.
- Registered `Type::BINARY_VIEW` and `Type::STRING_VIEW` kernels across
`replace_with_mask`, `fill_null_forward`, and `fill_null_backward`.
2. **Creative Unit Tests in `vector_replace_test.cc`:**
- `TestVectorReplace.TestIssue55256`: Minimal reproduction test covering
all four types across `replace_with_mask`, `fill_null_forward`, and
`fill_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-chunk
`ChunkedArray` cross-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.
3. **Python Unit Tests in `python/pyarrow/tests/test_compute.py`:**
- Added `test_replace_with_mask_views` parameterized for
`pa.string_view()` and `pa.binary_view()`.
- Added `test_replace_with_mask_decimals` parameterized for
`pa.decimal32(7, 2)` and `pa.decimal64(15, 2)`.
### Are these changes tested?
Yes, all changes are covered by comprehensive unit tests:
- C++ tests in `cpp/src/arrow/compute/kernels/vector_replace_test.cc`.
- Python tests in `python/pyarrow/tests/test_compute.py`.
- Both `vector_replace.cc.obj` and `vector_replace_test.cc.obj` compile
cleanly with MSVC 2019 (Exit code 0).
- `git diff --check` passes with zero whitespace warnings.
### 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: #55256
Closes #55256
--
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]