alamb commented on a change in pull request #1074:
URL: https://github.com/apache/arrow-rs/pull/1074#discussion_r775856676
##########
File path: arrow/src/compute/kernels/comparison.rs
##########
@@ -898,6 +900,305 @@ pub fn gt_eq_utf8_scalar<OffsetSize:
StringOffsetSizeTrait>(
compare_op_scalar!(left, right, |a, b| a >= b)
}
+macro_rules! dyn_compare_scalar {
+ ($LEFT: expr, $RIGHT: expr, $OP: ident) => {{
+ let right: i128 = $RIGHT.try_into().map_err(|_| {
+ ArrowError::ComputeError(String::from("Can not convert scalar to
i128"))
+ })?;
+ match $LEFT.data_type() {
+ DataType::Int8 => {
+ let right: i8 = right.try_into().map_err(|_| {
+ ArrowError::ComputeError(String::from(
+ "Can not convert scalar to i128",
Review comment:
It affects the messages below as well
##########
File path: arrow/src/compute/kernels/comparison.rs
##########
@@ -898,6 +900,305 @@ pub fn gt_eq_utf8_scalar<OffsetSize:
StringOffsetSizeTrait>(
compare_op_scalar!(left, right, |a, b| a >= b)
}
+macro_rules! dyn_compare_scalar {
+ ($LEFT: expr, $RIGHT: expr, $OP: ident) => {{
+ let right: i128 = $RIGHT.try_into().map_err(|_| {
+ ArrowError::ComputeError(String::from("Can not convert scalar to
i128"))
+ })?;
+ match $LEFT.data_type() {
+ DataType::Int8 => {
+ let right: i8 = right.try_into().map_err(|_| {
+ ArrowError::ComputeError(String::from(
+ "Can not convert scalar to i128",
+ ))
+ })?;
+ let left = as_primitive_array::<Int8Type>($LEFT);
+ $OP::<Int8Type>(left, right)
+ }
+ DataType::Int16 => {
+ let right: i16 = right.try_into().map_err(|_| {
+ ArrowError::ComputeError(String::from(
+ "Can not convert scalar to i128",
+ ))
+ })?;
+ let left = as_primitive_array::<Int16Type>($LEFT);
+ $OP::<Int16Type>(left, right)
+ }
+ DataType::Int32 => {
+ let right: i32 = right.try_into().map_err(|_| {
+ ArrowError::ComputeError(String::from(
+ "Can not convert scalar to i128",
+ ))
+ })?;
+ let left = as_primitive_array::<Int32Type>($LEFT);
+ $OP::<Int32Type>(left, right)
+ }
+ DataType::Int64 => {
+ let right: i64 = right.try_into().map_err(|_| {
+ ArrowError::ComputeError(String::from(
+ "Can not convert scalar to i128",
+ ))
+ })?;
+ let left = as_primitive_array::<Int64Type>($LEFT);
+ $OP::<Int64Type>(left, right)
+ }
+ DataType::UInt8 => {
+ let right: u8 = right.try_into().map_err(|_| {
+ ArrowError::ComputeError(String::from(
+ "Can not convert scalar to i128",
+ ))
+ })?;
+ let left = as_primitive_array::<UInt8Type>($LEFT);
+ $OP::<UInt8Type>(left, right)
+ }
+ DataType::UInt16 => {
+ let right: u16 = right.try_into().map_err(|_| {
+ ArrowError::ComputeError(String::from(
+ "Can not convert scalar to i128",
+ ))
+ })?;
+ let left = as_primitive_array::<UInt16Type>($LEFT);
+ $OP::<UInt16Type>(left, right)
+ }
+ DataType::UInt32 => {
+ let right: u32 = right.try_into().map_err(|_| {
+ ArrowError::ComputeError(String::from(
+ "Can not convert scalar to i128",
+ ))
+ })?;
+ let left = as_primitive_array::<UInt32Type>($LEFT);
+ $OP::<UInt32Type>(left, right)
+ }
+ DataType::UInt64 => {
+ let right: u64 = right.try_into().map_err(|_| {
+ ArrowError::ComputeError(String::from(
+ "Can not convert scalar to i128",
+ ))
+ })?;
+ let left = as_primitive_array::<UInt64Type>($LEFT);
+ $OP::<UInt64Type>(left, right)
+ }
+ _ => Err(ArrowError::ComputeError(String::from(
+ "Unsupported data type",
+ ))),
+ }
+ }};
+ ($LEFT: expr, $RIGHT: expr, $KT: ident, $OP: ident) => {{
Review comment:
```suggestion
/// Applies `LEFT OP RIGHT` when `LEFT` is a `DictionaryArray` with keys
of type `KT`
($LEFT: expr, $RIGHT: expr, $KT: ident, $OP: ident) => {{
```
##########
File path: arrow/src/compute/kernels/comparison.rs
##########
@@ -898,6 +900,305 @@ pub fn gt_eq_utf8_scalar<OffsetSize:
StringOffsetSizeTrait>(
compare_op_scalar!(left, right, |a, b| a >= b)
}
+macro_rules! dyn_compare_scalar {
+ ($LEFT: expr, $RIGHT: expr, $OP: ident) => {{
Review comment:
```suggestion
/// Applies `LEFT OP RIGHT` when `LEFT` is a `DictionaryArray` with keys
of type `KT`
($LEFT: expr, $RIGHT: expr, $OP: ident) => {{
```
--
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]