mrhhsg opened a new pull request, #71367:
URL: https://github.com/apache/doris/pull/71367
### What problem does this PR solve?
Issue Number: None
Related PR: #68428
Cherry-picked from #68428 to `branch-4.1`.
Repeated RE2 searches previously treated each remaining suffix as a new
subject. This could reapply a start anchor to later suffixes and lose the
original boundary context. Empty matches also advanced from the previous search
position by one byte rather than from the actual match position.
### Changes
- Keep the original RE2 subject and advance a search offset in
`regexp_count`, `regexp_extract_all`, and `split_by_regexp`.
- For extraction/counting, advance past an empty match by one UTF-8
character, fall back to one byte for malformed UTF-8, and stop at an empty
match at the subject end. Empty matches remain excluded from extraction/count
results.
- Interpret split offsets relative to the original input, preserving the
existing split-limit and zero-length-match handling.
- Adapt the backport to the existing release-branch function set. This does
not introduce `regexp_extract_all_array` or the unrelated master API
refactoring. Retain the applicable unit/regression coverage and regenerate the
release-branch expected output.
### Testing
Validation performed on this branch:
- `./build.sh --be --fe -j 48`: RELEASE BE/FE build and packaging passed,
including Checkstyle with zero violations.
- `./run-be-ut.sh --run -j 48
--filter='FunctionLikeTest.regexp_*:FunctionLikeTest.split_by_regexp_preserves_original_anchor:function_string_test.function_regexp_count*'`:
16 ASAN BE tests passed, zero failures.
- SQL regression output generation and a separate non-generation run of
`test_regexp_repeated_search_anchor` passed.
- After initializing the existing `query_p0/load.groovy` fixture, the new
suite and four adjacent suites passed together: 5 suites, zero failures, fatal
scripts, or skips.
- Clang-format 16 check of the four changed C++ files and `git diff --check`
passed.
The combined regression invocation was run with an isolated local
configuration (its machine-specific path is omitted):
```bash
./run-regression-test.sh --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
```
SQL validation used one local FE/BE with Java extensions disabled. FE unit
tests, Java-extension execution, multi-BE and mixed-version testing, remote CI,
and standalone clang-tidy were not run.
### Release note
Fix repeated regular-expression searches to preserve the original
anchor/boundary context and advance correctly after empty matches, including
UTF-8 input.
### Check List (For Author)
- Test:
- [x] Regression test
- [x] Unit Test
- Behavior changed:
- [x] Yes. Correct repeated-search anchor and empty-match progression
semantics.
- Does this need documentation?
- [x] No. This restores the existing regular-expression semantics
without adding a SQL API.
--
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]