mrhhsg opened a new pull request, #71285:
URL: https://github.com/apache/doris/pull/71285
### What problem does this PR solve?
Issue Number: None
Related PR: #68428
Cherry-picked from #68428 (master) to `branch-4.2`.
Repeated RE2 searches previously treated each remaining suffix as a new
input. This could make `^` match repeatedly and lose the original word-boundary
context in `regexp_extract_all`, `regexp_count`, and `split_by_regexp`. Empty
matches also advanced from the previous search position by one byte instead of
from the actual match position.
This backport:
- Keeps the original RE2 subject and advances only the search offset.
- Advances empty extraction/counting matches by one UTF-8 character from
their actual position, falls back to one-byte progress for malformed UTF-8, and
stops at an empty end-of-input match. Empty matches remain excluded from
extraction results and counts.
- Keeps split-match offsets relative to the original input and removes
suffix copying/searching from repeated extraction.
- Preserves the target branch's existing Boost.Regex behavior, empty-match
filtering, and split limits.
Branch-specific adaptations: retain the existing Boost zero-width coverage
and compile-check guards. `branch-4.2` does not provide
`regexp_extract_all_array`, so this backport does not introduce that separate
API; SQL coverage uses the existing functions and its expected output was
regenerated and verified by a normal comparison run.
### Release note
Fix incorrect anchors and word-boundary context during repeated regexp
searches, and correct UTF-8 progress after empty extraction/counting matches.
### Check List (For Author)
- Test
- [x] Unit Test: **18/18 passed under ASAN**.
```bash
./run-be-ut.sh --run -j 48
--filter='FunctionLikeTest.regexp*:FunctionLikeTest.split_by_regexp_preserves_original_anchor:function_string_test.function_regexp_count_mixed_const_test'
```
- [x] Regression test: **5/5 suites passed**, with no failed, fatal, or
skipped scripts, after loading the existing shared SQL fixtures. The new suite
was also generated and rerun in normal comparison mode. The regression wrapper
invokes this runner with an isolated configuration:
```bash
./run-regression-test.sh --conf <isolated-regression-conf> --run \
-d query_p0/sql_functions/string_functions \
-s
test_regexp_repeated_search_anchor,test_string_function_regexp,test_split_by_regexp,test_regexp_extended_nonconstant_pattern,test_regexp_chinese
```
- [x] Manual test:
- RELEASE BE and FE production build:
```bash
env FE_MAVEN_THREADS=16 MVN_OPT=-Dmaven.test.skip=true ./build.sh
--be --fe -j 48
```
- FE Checkstyle: zero violations.
- clang-format 16: all four changed C++ files passed.
- `git diff --check`: passed.
Validation scope: FE unit tests were not run. Production packaging used
`-Dmaven.test.skip=true` because the unchanged
`GroupCommitManagerBackendSelectionTest` fails test compilation with an
unresolved `Assertions` symbol; Checkstyle remained enabled. SQL regression
used native BE functions with Java support disabled; Java UDF and Java-based
external-catalog paths were not tested. Standalone clang-tidy was not run.
- Behavior changed:
- [ ] No.
- [x] Yes. Repeated RE2 searches preserve the original input's anchors
and boundaries; empty-match progress respects UTF-8 character boundaries.
- Does this need documentation?
- [x] No. Backport of a correctness fix; no new API or configuration.
- [ ] Yes.
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label
--
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]