feat(isthmus): map REGEXP_EXTRACT to Substrait regexp_match_substring#985
Draft
nielspardon wants to merge 1 commit into
Draft
feat(isthmus): map REGEXP_EXTRACT to Substrait regexp_match_substring#985nielspardon wants to merge 1 commit into
nielspardon wants to merge 1 commit into
Conversation
Calcite's BigQuery-library REGEXP_EXTRACT(value, regexp) operator had no Substrait mapping, so queries using it failed to convert. Map the two-argument form to the two-argument regexp_match_substring(input, pattern) impl, which returns the substring matching the full pattern. The function's options (case_sensitivity, multiline, dotall) are defaulted by the function matcher, the same way substring's negative_start option is handled. Patterns containing a capture group are not handled specially: the full match is returned rather than the captured group. Also repoints AutomaticDynamicFunctionMappingRoundtripTest, which used regexp_match_substring as an example of an unmapped function; since it is now mapped, the test exercises the still-unmapped regexp_count_substring instead.
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
Maps Calcite's BigQuery-library
REGEXP_EXTRACT(value, regexp)operator to Substrait's two-argumentregexp_match_substring(input, pattern).Why
REGEXP_EXTRACThad no entry inFunctionMappings, so SQL using it failed to convert to Substrait (Unable to convert call REGEXP_EXTRACT(...)). The two-argument form lines up directly with the two-argumentregexp_match_substringimpl infunctions_string.yaml.Scope / notes
position/occurrenceargs (3–4 arg forms) are not handled — Substrait has no 3/4-arg impl, so those would need argument padding to the 5-arg impl and are left for a follow-up.case_sensitivity,multiline,dotall) are defaulted automatically by the function matcher, the same waysubstring'snegative_startoption is.REGEXP_EXTRACTreturns capture group 1 when the pattern contains a capturing group; the 2-arg Substrait impl returns the full match. Identical for group-less patterns, divergent otherwise. Called out in a code comment.AutomaticDynamicFunctionMappingRoundtripTesthad usedregexp_match_substringas an example of an unmapped function. Since it is now mapped, the test is repointed at the still-unmappedregexp_count_substring.Testing
StringFunctionTestoverc16/vc32/vc.StringFunctionTest,AutomaticDynamicFunctionMappingRoundtripTest, andFunctionConversionTestpass locally.🤖 Generated with AI