Skip to content

Commit

Permalink
Add ASCII fast path for ILIKE scalar
Browse files Browse the repository at this point in the history
  • Loading branch information
tustvold committed Dec 9, 2022
1 parent d11da24 commit 0fb5ea5
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions arrow-string/src/like.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,11 +590,17 @@ fn ilike_scalar_op<'a, F: Fn(bool) -> bool, L: ArrayAccessor<Item = &'a str>>(
) -> Result<BooleanArray, ArrowError> {
if !right.contains(is_like_pattern) {
// fast path, can use equals
let right_uppercase = right.to_uppercase();

Ok(BooleanArray::from_unary(left, |item| {
op(item.to_uppercase() == right_uppercase)
}))
if right.is_ascii() {
// This avoids additional allocations
Ok(BooleanArray::from_unary(left, |item| {
op(item.eq_ignore_ascii_case(right))
}))
} else {
let right_uppercase = right.to_uppercase();
Ok(BooleanArray::from_unary(left, |item| {
op(item.to_uppercase() == right_uppercase)
}))
}
} else if right.ends_with('%')
&& !right.ends_with("\\%")
&& !right[..right.len() - 1].contains(is_like_pattern)
Expand Down

0 comments on commit 0fb5ea5

Please sign in to comment.