ccl125 opened a new pull request, #66050:
URL: https://github.com/apache/doris/pull/66050

   ### What problem does this PR solve?
   
   Issue Number: related #48203 (Spark: `regexp_extract_all` for the third 
argument)
   
   Problem Summary:
   
   `regexp_extract_all` / `regexp_extract_all_array` only accepted 2 arguments 
and always extracted the first capturing group. This PR adds the optional third 
`group` argument, following Spark semantics:
   
   - `regexp_extract_all(str, pattern)` — unchanged, extracts group 1 (the FE 
pads the default index literal, same as `substring` does)
   - `regexp_extract_all(str, pattern, 0)` — extracts the whole match (also 
works for patterns without capturing groups)
   - `regexp_extract_all(str, pattern, N)` — extracts capturing group N
   - group index out of range → empty result; negative index → NULL
   
   Implementation:
   - FE: `RegexpExtractAll` / `RegexpExtractAllArray` gain 3-arg signatures; 
the 2-arg constructor pads `BigIntLiteral(1)` (mirrors `Substring`), and the 
misleading `BinaryExpression` shape is dropped (mirrors `Substring` as well)
   - BE: `RegexpExtractEngine::match_all_and_extract` takes a group index; 
`RegexpExtractAllImpl` handles the third column (const and non-const) per row
   
   ### Release note
   
   Support the third argument (group index) for `regexp_extract_all` and 
`regexp_extract_all_array`.
   
   ### Check List (For Author)
   
   - Test
       - [x] Regression test
       - [x] Unit Test
       - [ ] Manual test (add detailed scripts or steps below)
       - [ ] No need to test or manual test. Explain why:
   
     New BE unit cases in `function_like_test.cpp` cover group 0 / other groups 
/ out-of-range / negative index for both functions; existing 2-arg cases were 
ported to the normalized 3-arg form with unchanged expectations. New regression 
cases added to `test_string_function_regexp`.
   
   - Behavior changed:
       - [x] No.
       - [ ] Yes.
   
     2-argument calls keep the exact previous behavior (group 1 extraction, 
empty result when the pattern has no capturing group).
   
   - Does this need documentation?
       - [ ] No.
       - [x] Yes. Will follow up with a docs PR to apache/doris-website if this 
is accepted.
   
   ### 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]

Reply via email to