github-actions[bot] commented on code in PR #66050:
URL: https://github.com/apache/doris/pull/66050#discussion_r3682115251
##########
be/src/exprs/function/function_regexp.cpp:
##########
@@ -159,29 +165,35 @@ struct RegexpExtractEngine {
pos += 1;
continue;
}
- // Extract first capturing group
- if (matches.size() > 1 && !matches[1].empty()) {
- results.emplace_back(matches[1].data(), matches[1].size());
+ // Extract the capturing group with the given index
+ if (static_cast<size_t>(index) < matches.size()) {
+ const re2::StringPiece& group = matches[index];
+ if (group.data() != nullptr) {
+ results.emplace_back(group.data(), group.size());
+ } else {
+ results.emplace_back();
+ }
}
- // Move position forward
- auto offset = std::string(str_pos, str_size)
- .find(std::string(matches[0].data(),
matches[0].size()));
- pos += offset + matches[0].size();
+ // Move position forward. matches[0] points into the searched
string,
+ // so its address gives the exact match offset — no textual
find needed.
+ pos += (matches[0].data() - str_pos) + matches[0].size();
Review Comment:
[P1] Preserve the original regex subject between matches
This exact-pointer advance fixes the earlier textual-`find` bug, but the
next iteration still passes `StringPiece(str_pos, str_size)` (and Boost
`[search_start, search_end)`) as a brand-new subject. That changes left context
after any non-empty match: `regexp_extract_all_array('aa', '^a', 0)` treats the
second byte as another beginning and returns `["a","a"]` instead of Spark's
single anchored match; with extended regex, `regexp_extract_all_array('ab',
'a|(?<=a)b', 0)` loses the `a` before `search_start` and misses the valid `b`.
This is distinct from the existing zero-width/progress threads. Please keep the
original subject/range and advance a search offset/flags that preserve
beginning and previous-character context.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]