dmitry-chirkov-dremio commented on code in PR #49978:
URL: https://github.com/apache/arrow/pull/49978#discussion_r3244800088
##########
cpp/src/gandiva/regex_functions_holder_test.cc:
##########
@@ -604,24 +604,47 @@ TEST_F(TestExtractHolder, TestExtractInvalidPattern) {
execution_context_.Reset();
}
-TEST_F(TestExtractHolder, TestErrorWhileBuildingHolder) {
- // Create function with incorrect number of params
+TEST_F(TestExtractHolder, TestDefaultIndexExtract) {
+ // 2-arg form defaults to index 1 (first capture group)
auto field = std::make_shared<FieldNode>(arrow::field("in", arrow::utf8()));
auto pattern_node = std::make_shared<LiteralNode>(
arrow::utf8(), LiteralHolder(R"((\w+) (\w+))"), false);
auto function_node =
FunctionNode("regexp_extract", {field, pattern_node}, arrow::utf8());
+ EXPECT_OK_AND_ASSIGN(auto extract_holder,
ExtractHolder::Make(function_node));
+
+ std::string input_string = "John Doe";
+ int32_t out_length = 0;
+
+ auto& extract = *extract_holder;
+ const char* ret =
+ extract(&execution_context_, input_string.c_str(),
+ static_cast<int32_t>(input_string.length()), 1, &out_length);
+ EXPECT_EQ(std::string(ret, out_length), "John");
+
+ input_string = "Ringo Beast";
+ ret = extract(&execution_context_, input_string.c_str(),
+ static_cast<int32_t>(input_string.length()), 1, &out_length);
Review Comment:
isn't this an extract index so we are not quite testing two arg version?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]