alamb commented on a change in pull request #870:
URL: https://github.com/apache/arrow-datafusion/pull/870#discussion_r691317655
##########
File path: datafusion/src/physical_plan/expressions/binary.rs
##########
@@ -339,6 +340,72 @@ macro_rules! boolean_op {
}};
}
+macro_rules! regexp_match_op {
+ ($LEFT:expr, $RIGHT:expr, $NOT:expr, $CASE:expr) => {{
+ match $LEFT.data_type() {
+ DataType::Utf8 => {
+ regexp_match_array_op!(StringArray, $LEFT, $RIGHT, $NOT, $CASE)
+ }
+ DataType::LargeUtf8 => {
+ regexp_match_array_op!(LargeStringArray, $LEFT, $RIGHT, $NOT,
$CASE)
+ }
+ other => Err(DataFusionError::Internal(format!(
+ "Data type {:?} not supported for regexp_match operation on
string array",
+ other
+ ))),
+ }
+ }};
+}
+
+/// Invoke a regexp_match kernel on a pair of arrays
+macro_rules! regexp_match_array_op {
+ ($ARRAYTYPE:ident, $LEFT:expr, $RIGHT:expr, $NOT:expr, $CASE:expr) => {{
+ let ll = $LEFT
+ .as_any()
+ .downcast_ref::<$ARRAYTYPE>()
+ .expect("regexp_match_array_op failed to downcast array");
+ let rr = $RIGHT
+ .as_any()
+ .downcast_ref::<$ARRAYTYPE>()
+ .expect("regexp_match_array_op failed to downcast array");
+
+ let array = match $CASE {
+ true => regexp_match(&ll, &rr, Some(&$ARRAYTYPE::from(vec!["i";
ll.len()])))?,
Review comment:
It unfortunate that the `arrow-rs` doesn't have a `regexp_filter` style
kernel that returns a BooleanArray --
https://sourcegraph.com/github.com/apache/arrow-rs/-/blob/arrow/src/compute/kernels/regexp.rs?L16
I filed https://github.com/apache/arrow-rs/issues/697 and
https://github.com/apache/arrow-datafusion/issues/905 to track that potential
work, if we want to improve performance of these operators in future versions
of DataFusion,
--
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]