alamb commented on code in PR #5931:
URL: https://github.com/apache/arrow-rs/pull/5931#discussion_r1650045799
##########
arrow-string/src/like.rs:
##########
@@ -399,358 +451,433 @@ mod tests {
};
}
+ /// Applying `op(left, right)`, left side is array, right side is scalar
+ /// The macro tests four types of array implementations:
+ /// - `StringArray`
+ /// - `LargeStringArray`
+ /// - `StringViewArray`
+ /// - `DictionaryArray`
macro_rules! test_utf8_scalar {
($test_name:ident, $left:expr, $right:expr, $op:expr, $expected:expr)
=> {
#[test]
fn $test_name() {
let expected = BooleanArray::from($expected);
let left = StringArray::from($left);
- let res = $op(&left, $right).unwrap();
+ let right = StringArray::from_iter_values([$right]);
+ let res = $op(&left, &Scalar::new(&right)).unwrap();
assert_eq!(res, expected);
let left = LargeStringArray::from($left);
- let res = $op(&left, $right).unwrap();
+ let right = LargeStringArray::from_iter_values([$right]);
+ let res = $op(&left, &Scalar::new(&right)).unwrap();
+ assert_eq!(res, expected);
+
+ let left = StringViewArray::from($left);
+ let right = StringViewArray::from_iter_values([$right]);
+ let res = $op(&left, &Scalar::new(&right)).unwrap();
+ assert_eq!(res, expected);
+
+ let left: DictionaryArray<Int8Type> =
$left.into_iter().collect();
+ let right: DictionaryArray<Int8Type> =
[$right].into_iter().collect();
+ let res = $op(&left, &Scalar::new(&right)).unwrap();
assert_eq!(res, expected);
}
};
- ($test_name:ident, $test_name_dyn:ident, $left:expr, $right:expr,
$op:expr, $op_dyn:expr, $expected:expr) => {
- test_utf8_scalar!($test_name, $left, $right, $op, $expected);
- test_utf8_scalar!($test_name_dyn, $left, $right, $op_dyn,
$expected);
- };
}
test_utf8!(
test_utf8_array_like,
- vec!["arrow", "arrow", "arrow", "arrow", "arrow", "arrows", "arrow",
"arrow"],
- vec!["arrow", "ar%", "%ro%", "foo", "arr", "arrow_", "arrow_", ".*"],
- like_utf8,
- vec![true, true, true, false, false, true, false, false]
- );
-
- test_dict_utf8!(
- test_utf8_array_like_dict,
- vec!["arrow", "arrow", "arrow", "arrow", "arrow", "arrows", "arrow",
"arrow"],
+ vec![
+ "arrow",
+ "arrow_long_string_more than 12 bytes",
Review Comment:
👍
##########
arrow-string/src/predicate.rs:
##########
@@ -95,11 +95,10 @@ impl<'a> Predicate<'a> {
///
/// If `negate` is true the result of the predicate will be negated
#[inline(never)]
- pub fn evaluate_array<O: OffsetSizeTrait>(
- &self,
- array: &GenericStringArray<O>,
- negate: bool,
- ) -> BooleanArray {
+ pub fn evaluate_array<'i, T>(&self, array: T, negate: bool) -> BooleanArray
Review Comment:
Eventually I think we should consider making some special variant of this
function for StringViews (that can take advantage of the inlined views)
Maybe we could add some method to `ArrayAccessor` for quickly checking
prefix-equality 🤔
--
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]