-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Implementation for regex_instr #15928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 13 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
45b45c3
Implementation for regex_instr
cipherstakes 4fb0cca
linting and typo addressed in bench
cipherstakes cff8d42
prettier formatting
cipherstakes 2e70881
scalar_functions_formatting
cipherstakes 0b12a21
Merge branch 'main' into complete-regexp-instr
alamb c3131ed
linting format macros
cipherstakes eeeac8d
formatting
cipherstakes 4bd7eb6
Merge branch 'main' into complete-regexp-instr
blaginin 89e2315
address comments to PR
cipherstakes fad6e7b
formatting
cipherstakes 93c35c8
clippy
cipherstakes 990a653
fmt
cipherstakes 1120043
address docs typo
cipherstakes ef43f28
remove unnecessary struct and comment
cipherstakes ec71d2b
delete redundant lines
cipherstakes 265db0e
refactor get_index
cipherstakes d25d21d
Merge branch 'main' into complete-regexp-instr
nirnayroy 94df4c8
comments addressed
cipherstakes 5d1044a
update doc
cipherstakes 581af20
clippy upgrade
cipherstakes 71fc485
Merge branch 'main' into complete-regexp-instr
blaginin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -17,15 +17,20 @@ | |||||
|
|
||||||
| //! "regex" DataFusion functions | ||||||
|
|
||||||
| use arrow::error::ArrowError; | ||||||
| use regex::Regex; | ||||||
| use std::collections::hash_map::Entry; | ||||||
| use std::collections::HashMap; | ||||||
| use std::sync::Arc; | ||||||
|
|
||||||
| pub mod regexpcount; | ||||||
| pub mod regexpinstr; | ||||||
| pub mod regexplike; | ||||||
| pub mod regexpmatch; | ||||||
| pub mod regexpreplace; | ||||||
|
|
||||||
| // create UDFs | ||||||
| make_udf_function!(regexpcount::RegexpCountFunc, regexp_count); | ||||||
| make_udf_function!(regexpinstr::RegexpInstrFunc, regexp_instr); | ||||||
| make_udf_function!(regexpmatch::RegexpMatchFunc, regexp_match); | ||||||
| make_udf_function!(regexplike::RegexpLikeFunc, regexp_like); | ||||||
| make_udf_function!(regexpreplace::RegexpReplaceFunc, regexp_replace); | ||||||
|
|
@@ -60,6 +65,34 @@ pub mod expr_fn { | |||||
| super::regexp_match().call(args) | ||||||
| } | ||||||
|
|
||||||
| /// Returns index of regular expression matches in a string. | ||||||
| pub fn regexp_instr( | ||||||
| values: Expr, | ||||||
| regex: Expr, | ||||||
| start: Option<Expr>, | ||||||
| n: Option<Expr>, | ||||||
| endoption: Option<Expr>, | ||||||
| flags: Option<Expr>, | ||||||
| subexpr: Option<Expr>, | ||||||
| ) -> Expr { | ||||||
| let mut args = vec![values, regex]; | ||||||
| if let Some(start) = start { | ||||||
| args.push(start); | ||||||
| }; | ||||||
| if let Some(n) = n { | ||||||
| args.push(n); | ||||||
| }; | ||||||
| if let Some(endoption) = endoption { | ||||||
| args.push(endoption); | ||||||
| }; | ||||||
| if let Some(flags) = flags { | ||||||
| args.push(flags); | ||||||
| }; | ||||||
| if let Some(subexpr) = subexpr { | ||||||
| args.push(subexpr); | ||||||
| }; | ||||||
| super::regexp_instr().call(args) | ||||||
| } | ||||||
| /// Returns true if a has at least one match in a string, false otherwise. | ||||||
|
||||||
| /// Returns true if a has at least one match in a string, false otherwise. | |
| /// Returns true if a regex has at least one match in a string, false otherwise. |
Outdated
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change
| "regexp_count() does not support global flag".to_string(), | |
| "regexp_count()/regexp_instr() does not support the global flag".to_string(), |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.