Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cpp/src/arrow/compute/kernels/vector_replace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,15 @@ struct ReplaceMaskImpl<Type, enable_if_null<Type>> {
static Result<int64_t> ExecScalarMask(KernelContext* ctx, const ArraySpan& array,
const BooleanScalar& mask, ExecValue replacements,
int64_t replacements_offset, ExecResult* out) {
out->value = array;
return Status::OK();
out->value = array.ToArrayData();
return replacements_offset;
}
static Result<int64_t> ExecArrayMask(KernelContext* ctx, const ArraySpan& array,
const ArraySpan& mask, int64_t mask_offset,
ExecValue replacements,
int64_t replacements_offset, ExecResult* out) {
out->value = array;
return Status::OK();
out->value = array.ToArrayData();
return replacements_offset;
}
};

Expand Down
20 changes: 20 additions & 0 deletions python/pyarrow/tests/test_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -1987,6 +1987,26 @@ def test_fill_null_array(arrow_type):
assert result.equals(expected)


def test_replace_with_mask_null_type():
# GH-47447: replace_with_mask crashed for null type arrays
a = pa.array([None], pa.null())
b = pa.array([None], pa.null())

result = pc.replace_with_mask(a, True, b)
assert result.type == pa.null()

result = pc.replace_with_mask(a, False, b)
assert result.type == pa.null()

mask = pa.array([True])
result = pc.replace_with_mask(a, mask, b)
assert result.type == pa.null()

mask = pa.array([False])
result = pc.replace_with_mask(a, mask, b)
assert result.type == pa.null()


@pytest.mark.parametrize('arrow_type', numerical_arrow_types)
def test_fill_null_chunked_array(arrow_type):
fill_value = pa.scalar(5, type=arrow_type)
Expand Down
Loading