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
9 changes: 2 additions & 7 deletions cpp/src/arrow/compute/kernels/scalar_string.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1635,20 +1635,15 @@ struct ExtractRegex : public ExtractRegexBase {
checked_cast<BuilderType*>(struct_builder->field_builder(i)));
}

auto visit_null = [&]() {
for (int i = 0; i < group_count; i++) {
RETURN_NOT_OK(field_builders[i]->AppendEmptyValue());
}
return struct_builder->AppendNull();
};
auto visit_null = [&]() { return struct_builder->AppendNull(); };
auto visit_value = [&](util::string_view s) {
if (Match(s)) {
for (int i = 0; i < group_count; i++) {
RETURN_NOT_OK(field_builders[i]->Append(ToStringView(found_values[i])));
}
return struct_builder->Append();
} else {
return visit_null();
return struct_builder->AppendNull();
}
};
const ArrayData& input = *batch[0].array();
Expand Down
4 changes: 4 additions & 0 deletions cpp/src/arrow/compute/kernels/scalar_string_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,10 @@ TYPED_TEST(TestStringKernels, ExtractRegex) {
"extract_regex", R"(["a1", "b2", "c3", null])", type,
R"([{"letter": "a", "digit": "1"}, {"letter": "b", "digit": "2"}, null, null])",
&options);
this->CheckUnary(
"extract_regex", R"(["a1", "c3", null, "b2"])", type,
R"([{"letter": "a", "digit": "1"}, null, null, {"letter": "b", "digit": "2"}])",
&options);
this->CheckUnary("extract_regex", R"(["a1", "b2"])", type,
R"([{"letter": "a", "digit": "1"}, {"letter": "b", "digit": "2"}])",
&options);
Expand Down