Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARROW-12906: [C++][Python] Fix fill_null segfault #10434

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion cpp/src/arrow/compute/kernels/scalar_fill_null.cc
Expand Up @@ -162,7 +162,6 @@ struct FillNullFunctor<Type, enable_if_t<is_base_binary_type<Type>::value>> {
const ArrayData& input = *batch[0].array();
const auto& fill_value_scalar =
checked_cast<const BaseBinaryScalar&>(*batch[1].scalar());
util::string_view fill_value(*fill_value_scalar.value);
ArrayData* output = out->mutable_array();

// Ensure the kernel is configured properly to have no validity bitmap /
Expand All @@ -172,6 +171,7 @@ struct FillNullFunctor<Type, enable_if_t<is_base_binary_type<Type>::value>> {
const int64_t null_count = input.GetNullCount();

if (null_count > 0 && fill_value_scalar.is_valid) {
util::string_view fill_value(*fill_value_scalar.value);
BuilderType builder(input.type, ctx->memory_pool());
RETURN_NOT_OK(builder.ReserveData(input.buffers[2]->size() +
fill_value.length() * null_count));
Expand Down
5 changes: 5 additions & 0 deletions python/pyarrow/tests/test_compute.py
Expand Up @@ -1078,6 +1078,11 @@ def test_fill_null():
expected = pa.array([b'a', b'bb', b'ccc'], type=pa.large_binary())
assert result.equals(expected)

arr = pa.array(['a', 'bb', None])
result = arr.fill_null(None)
expected = pa.array(['a', 'bb', None])
assert result.equals(expected)


@pytest.mark.parametrize('arrow_type', numerical_arrow_types)
def test_fill_null_array(arrow_type):
Expand Down