arashandishgar commented on code in PR #45577: URL: https://github.com/apache/arrow/pull/45577#discussion_r1983814524
########## cpp/src/arrow/compute/kernels/scalar_string_test.cc: ########## @@ -1958,6 +1960,47 @@ TYPED_TEST(TestBaseBinaryKernels, ExtractRegex) { R"([{"letter": "a", "digit": "1"}, {"letter": "b", "digit": "3"}])", &options); } +TYPED_TEST(TestBaseBinaryKernels, ExtractRegexSpan) { + ExtractRegexSpanOptions options{"(?P<letter>[ab])(?P<digit>\\d)"}; + auto type_fixe_size_list = is_binary_like(this->type()->id()) ? int32() : int64(); + auto out_type = struct_({field("letter", fixed_size_list(type_fixe_size_list, 2)), + field("digit", fixed_size_list(type_fixe_size_list, 2))}); + this->CheckUnary("extract_regex_span", R"([])", out_type, R"([])", &options); + this->CheckUnary( + "extract_regex_span", R"(["a1", "b2", "c3", null])", out_type, + R"([{"letter":[0,1], "digit":[1,1]}, {"letter":[0,1], "digit":[1,1]}, null, null])", + &options); + this->CheckUnary( + "extract_regex_span", R"(["a1", "c3", null, "b2"])", out_type, + R"([{"letter":[0,1], "digit": [1,1]}, null, null, {"letter":[0,1], "digit":[1,1]}])", + &options); + this->CheckUnary( + "extract_regex_span", R"(["a1", "b2"])", out_type, + R"([{"letter": [0,1], "digit": [1,1]}, {"letter": [0,1], "digit": [1,1]}])", + &options); + this->CheckUnary( + "extract_regex_span", R"(["a1", "zb3z"])", out_type, + R"([{"letter": [0,1], "digit": [1,1]}, {"letter": [1,1], "digit": [2,1]}])", + &options); +} +TYPED_TEST(TestBaseBinaryKernels, ExtractRegexSpanCaptureOption) { Review Comment: > Could you make the tests less trivial and use examples with variable-length captures? > > For example have the regex be: `(?P<letter>[ab]+)(?P<digit>\\d+)` > > and then test with "abb12", "abc13", etc. I write a separate test case for that. If it is not enough,let me inform to write more test -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org