MazterQyou commented on code in PR #1846: URL: https://github.com/apache/arrow-rs/pull/1846#discussion_r895954685
########## arrow/src/compute/kernels/comparison.rs: ########## @@ -548,6 +548,89 @@ pub fn ilike_utf8_scalar<OffsetSize: OffsetSizeTrait>( Ok(BooleanArray::from(data)) } +/// Perform SQL `left NOT ILIKE right` operation on [`StringArray`] / +/// [`LargeStringArray`]. +/// +/// See the documentation on [`like_utf8`] for more details. +pub fn nilike_utf8<OffsetSize: OffsetSizeTrait>( + left: &GenericStringArray<OffsetSize>, + right: &GenericStringArray<OffsetSize>, +) -> Result<BooleanArray> { + regex_like(left, right, true, |re_pattern| { + Regex::new(&format!("(?i)^{}$", re_pattern)).map_err(|e| { + ArrowError::ComputeError(format!( + "Unable to build regex from ILIKE pattern: {}", + e + )) + }) + }) +} + +/// Perform SQL `left NOT ILIKE right` operation on [`StringArray`] / +/// [`LargeStringArray`] and a scalar. +/// +/// See the documentation on [`like_utf8`] for more details. +pub fn nilike_utf8_scalar<OffsetSize: OffsetSizeTrait>( + left: &GenericStringArray<OffsetSize>, + right: &str, +) -> Result<BooleanArray> { + let null_bit_buffer = left.data().null_buffer().cloned(); + let mut result = BooleanBufferBuilder::new(left.len()); + + if !right.contains(is_like_pattern) { + // fast path, can use equals + for i in 0..left.len() { + result.append(left.value(i) != right); + } + } else if right.ends_with('%') && !right[..right.len() - 1].contains(is_like_pattern) + { + // fast path, can use ends_with + for i in 0..left.len() { + result.append( + !left + .value(i) + .to_uppercase() Review Comment: I have simply re-used this code from the already existing `ilike` comparator function, so I have no idea regarding that. I agree, it does make sense to do some benchmarks. Although I feel `ends_with` and `starts_with` sound simple enough to be much faster than a regexp match implicitly. -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org