Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cpp/src/arrow/compute/kernels/scalar_string.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1332,7 +1332,7 @@ struct ReplaceSubString {

if (batch[0].kind() == Datum::ARRAY) {
// We already know how many strings we have, so we can use Reserve/UnsafeAppend
RETURN_NOT_OK(offset_builder.Reserve(batch[0].array()->length));
RETURN_NOT_OK(offset_builder.Reserve(batch[0].array()->length + 1));
offset_builder.UnsafeAppend(0); // offsets start at 0

const ArrayData& input = *batch[0].array();
Expand Down
8 changes: 8 additions & 0 deletions cpp/src/arrow/compute/kernels/scalar_string_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,14 @@ TYPED_TEST(TestStringKernels, ReplaceSubstringRegex) {
ReplaceSubstringOptions options_regex2{"(a.a)", "aba\\1"};
this->CheckUnary("replace_substring_regex", R"(["aaaaaa"])", this->type(),
R"(["abaaaaabaaaa"])", &options_regex2);

// ARROW-12774
ReplaceSubstringOptions options_regex3{"X", "Y"};
this->CheckUnary("replace_substring_regex",
R"(["A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A"])",
this->type(),
R"(["A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A"])",
&options_regex3);
}

TYPED_TEST(TestStringKernels, ReplaceSubstringRegexLimited) {
Expand Down