-
Notifications
You must be signed in to change notification settings - Fork 159
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
[FEAT] Add str.replace expression #2048
Conversation
src/daft-core/src/array/ops/utf8.rs
Outdated
let pattern_arrow = pattern.as_arrow(); | ||
let replacement_arrow = replacement.as_arrow(); | ||
|
||
if self.is_empty() || pattern.is_empty() || replacement.is_empty() { |
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.
Should this be &&
instead?
If any are empty, then all should be empty -- otherwise it's a length and we should throw an error?
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.
I made a separate issue (#2058) to tackle this cuz we'll probably want to add test cases for this change (and for all the other kernels), which is out of scope for this PR
src/daft-core/src/array/ops/utf8.rs
Outdated
} | ||
} | ||
}, | ||
(self_len,1,1) => { |
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.
Pretty crazy that we have so many match cases. I wonder if there's a better way to perform this.
Perhaps something like this at least?
self_iter, pattern_iter, replacement_iter = ...;
if regex {
regex_replace(...)
} else {
replace_on_literal(...)
}
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2048 +/- ##
==========================================
+ Coverage 85.23% 85.27% +0.03%
==========================================
Files 68 68
Lines 7248 7259 +11
==========================================
+ Hits 6178 6190 +12
+ Misses 1070 1069 -1
|
Closes #1932
Closes #1962
Replaces all occurrences of a pattern in a string column with a replacement string. The pattern can be a literal or a regex pattern.