Jimexist commented on a change in pull request #1163:
URL: https://github.com/apache/arrow-datafusion/pull/1163#discussion_r753660303
##########
File path: datafusion/src/physical_plan/expressions/binary.rs
##########
@@ -126,6 +186,47 @@ macro_rules! compute_utf8_op_scalar {
}};
}
+/// Invoke a compute kernel on a boolean data array and a scalar value
+macro_rules! compute_bool_op_scalar {
+ ($LEFT:expr, $RIGHT:expr, $OP:ident, $DT:ident) => {{
+ use std::convert::TryInto;
+ let ll = $LEFT
+ .as_any()
+ .downcast_ref::<$DT>()
+ .expect("compute_op failed to downcast array");
+ // generate the scalar function name, such as lt_scalar, from the $OP
parameter
+ // (which could have a value of lt) and the suffix _scalar
+ Ok(Arc::new(paste::expr! {[<$OP _bool_scalar>]}(
+ &ll,
+ $RIGHT.try_into()?,
+ )?))
+ }};
+}
+
+/// Invoke a bool compute kernel on array(s)
+macro_rules! compute_bool_op {
+ // invoke binary operator
+ ($LEFT:expr, $RIGHT:expr, $OP:ident, $DT:ident) => {{
+ let ll = $LEFT
+ .as_any()
+ .downcast_ref::<$DT>()
+ .expect("compute_op failed to downcast array");
Review comment:
```suggestion
.expect("compute_op failed to downcast left side array");
```
##########
File path: datafusion/src/physical_plan/expressions/binary.rs
##########
@@ -126,6 +186,47 @@ macro_rules! compute_utf8_op_scalar {
}};
}
+/// Invoke a compute kernel on a boolean data array and a scalar value
+macro_rules! compute_bool_op_scalar {
+ ($LEFT:expr, $RIGHT:expr, $OP:ident, $DT:ident) => {{
+ use std::convert::TryInto;
+ let ll = $LEFT
+ .as_any()
+ .downcast_ref::<$DT>()
+ .expect("compute_op failed to downcast array");
+ // generate the scalar function name, such as lt_scalar, from the $OP
parameter
+ // (which could have a value of lt) and the suffix _scalar
+ Ok(Arc::new(paste::expr! {[<$OP _bool_scalar>]}(
+ &ll,
+ $RIGHT.try_into()?,
+ )?))
+ }};
+}
+
+/// Invoke a bool compute kernel on array(s)
+macro_rules! compute_bool_op {
+ // invoke binary operator
+ ($LEFT:expr, $RIGHT:expr, $OP:ident, $DT:ident) => {{
+ let ll = $LEFT
+ .as_any()
+ .downcast_ref::<$DT>()
+ .expect("compute_op failed to downcast array");
+ let rr = $RIGHT
+ .as_any()
+ .downcast_ref::<$DT>()
+ .expect("compute_op failed to downcast array");
Review comment:
```suggestion
.expect("compute_op failed to downcast right side array");
```
##########
File path: datafusion/src/physical_plan/expressions/binary.rs
##########
@@ -126,6 +186,47 @@ macro_rules! compute_utf8_op_scalar {
}};
}
+/// Invoke a compute kernel on a boolean data array and a scalar value
+macro_rules! compute_bool_op_scalar {
+ ($LEFT:expr, $RIGHT:expr, $OP:ident, $DT:ident) => {{
+ use std::convert::TryInto;
+ let ll = $LEFT
+ .as_any()
+ .downcast_ref::<$DT>()
+ .expect("compute_op failed to downcast array");
+ // generate the scalar function name, such as lt_scalar, from the $OP
parameter
+ // (which could have a value of lt) and the suffix _scalar
+ Ok(Arc::new(paste::expr! {[<$OP _bool_scalar>]}(
+ &ll,
+ $RIGHT.try_into()?,
+ )?))
+ }};
+}
+
+/// Invoke a bool compute kernel on array(s)
+macro_rules! compute_bool_op {
+ // invoke binary operator
+ ($LEFT:expr, $RIGHT:expr, $OP:ident, $DT:ident) => {{
+ let ll = $LEFT
+ .as_any()
+ .downcast_ref::<$DT>()
+ .expect("compute_op failed to downcast array");
+ let rr = $RIGHT
+ .as_any()
+ .downcast_ref::<$DT>()
+ .expect("compute_op failed to downcast array");
+ Ok(Arc::new(paste::expr! {[<$OP _bool>]}(&ll, &rr)?))
+ }};
+ // invoke unary operator
+ ($OPERAND:expr, $OP:ident, $DT:ident) => {{
+ let operand = $OPERAND
+ .as_any()
+ .downcast_ref::<$DT>()
+ .expect("compute_op failed to downcast array");
Review comment:
```suggestion
.expect("compute_op failed to downcast operant array");
```
--
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]