[Feature](func) Support the third argument for regexp_extract_all and regexp_extract_all_array#66050
Open
ccl125 wants to merge 1 commit into
Open
[Feature](func) Support the third argument for regexp_extract_all and regexp_extract_all_array#66050ccl125 wants to merge 1 commit into
ccl125 wants to merge 1 commit into
Conversation
… regexp_extract_all_array Add an optional group-index argument (Spark semantics, default 1) to regexp_extract_all and regexp_extract_all_array. Index 0 extracts the whole match, a positive index extracts the corresponding capturing group, an out-of-range index yields an empty result, and a negative index yields NULL. Two-argument calls are normalized in the FE by padding the default index, keeping existing behavior unchanged.
ccl125
requested review from
924060929,
englefly,
morrySnow and
starocean999
as code owners
July 25, 2026 18:34
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Issue Number: related #48203 (Spark:
regexp_extract_allfor the third argument)Problem Summary:
regexp_extract_all/regexp_extract_all_arrayonly accepted 2 arguments and always extracted the first capturing group. This PR adds the optional thirdgroupargument, following Spark semantics:regexp_extract_all(str, pattern)— unchanged, extracts group 1 (the FE pads the default index literal, same assubstringdoes)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 NImplementation:
RegexpExtractAll/RegexpExtractAllArraygain 3-arg signatures; the 2-arg constructor padsBigIntLiteral(1)(mirrorsSubstring), and the misleadingBinaryExpressionshape is dropped (mirrorsSubstringas well)RegexpExtractEngine::match_all_and_extracttakes a group index;RegexpExtractAllImplhandles the third column (const and non-const) per rowRelease note
Support the third argument (group index) for
regexp_extract_allandregexp_extract_all_array.Check List (For Author)
Test
New BE unit cases in
function_like_test.cppcover 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 totest_string_function_regexp.Behavior changed:
2-argument calls keep the exact previous behavior (group 1 extraction, empty result when the pattern has no capturing group).
Does this need documentation?
Check List (For Reviewer who merge this PR)