andygrove commented on a change in pull request #8660:
URL: https://github.com/apache/arrow/pull/8660#discussion_r523237664
##########
File path: rust/datafusion/src/physical_plan/expressions.rs
##########
@@ -969,6 +975,42 @@ macro_rules! compute_utf8_op {
}};
}
+/// Invoke a compute kernel on a data array and a scalar value
+macro_rules! compute_utf8_op_scalar {
+ ($LEFT:expr, $RIGHT:expr, $OP:ident, $DT:ident) => {{
+ let ll = $LEFT
+ .as_any()
+ .downcast_ref::<$DT>()
+ .expect("compute_op failed to downcast array");
+ if let ScalarValue::Utf8(Some(string_value)) = $RIGHT {
+ Ok(Arc::new(paste::expr! {[<$OP _utf8_scalar>]}(
+ &ll,
+ &string_value,
+ )?))
+ } else {
+ Err(ExecutionError::General(format!(
+ "compute_utf8_op_scalar failed to cast literal value {}",
+ $RIGHT
+ )))
+ }
+ }};
+}
+
+/// Invoke a compute kernel on a data array and a scalar value
+macro_rules! compute_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");
+ Ok(Arc::new(paste::expr! {[<$OP _scalar>]}(
Review comment:
Could you add a comment explaining what is happening here? I am not
familiar with this syntax
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]