You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "albertlockett (via GitHub)" <gi...@apache.org> on 2026/05/01 17:06:21 UTC

[PR] [arrow-string]: add `like::eq_ascii_ignore_case` kernel [arrow-rs]

albertlockett opened a new pull request, #9871:
URL: https://github.com/apache/arrow-rs/pull/9871

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax.
   -->
   
   - Closes https://github.com/apache/arrow-rs/issues/9870
   
   # Rationale for this change
   
   <!--
   Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
   Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
   -->
   
   Users might wish to have a mechanism to do check if two strings are equal in a case-insensitive way. We already have some machinery to do this in the arrow-string crate (in the `predicate` module). This PR exposes a function so it can be invoked easily.
   
   # What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   Adds a function `like::eq_ascii_ignore_case` to the arrow-string crate that performs a case-insensitive equals check on two string arrays.
   
   # Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   
   If this PR claims a performance improvement, please include evidence such as benchmark results.
   -->
   
   yes unit tests
   
   
   # Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   
   If there are any breaking changes to public APIs, please call them out.
   -->
   
   Yes this function is public


-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [arrow-string]: add `like::eq_ascii_ignore_case` kernel [arrow-rs]

Posted by "albertlockett (via GitHub)" <gi...@apache.org>.
albertlockett commented on code in PR #9871:
URL: https://github.com/apache/arrow-rs/pull/9871#discussion_r3174251941


##########
arrow-string/src/like.rs:
##########
@@ -187,6 +189,30 @@ pub fn contains(left: &dyn Datum, right: &dyn Datum) -> Result<BooleanArray, Arr
     like_op(Op::Contains, left, right)
 }
 
+/// Perform equality check on two byte arrays using an ASCII case-insensitive match.
+///
+/// `left` and `right` must be the same type, and one of
+/// - Utf8
+/// - LargeUtf8
+/// - Utf8View
+///
+/// # Example
+/// ```
+/// # use arrow_array::{StringArray, BooleanArray};
+/// # use arrow_string::like::eq_ignore_ascii_case;
+/// let strings = StringArray::from(vec!["arrow", "rs", "arrow-rS", "Parquet"]);
+/// let patterns = StringArray::from(vec!["ARROW", "rS", "ARROW-rs", "arrow"]);
+///
+/// let result = eq_ignore_ascii_case(&strings, &patterns).unwrap();
+/// assert_eq!(result, BooleanArray::from(vec![true, true, true, false]));
+/// ```
+pub fn eq_ignore_ascii_case(

Review Comment:
   I'm hoping like is the correct module to add this function? 
   
   I added it here because I wanted to reuse a lot of the machinery that was already in place to invoke the `Predicate`, but I was hesitating because this does not have an equivalent SQL function, unlike the other functions/Operator variants in this module.



-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [arrow-string]: add `like::eq_ascii_ignore_case` kernel [arrow-rs]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #9871:
URL: https://github.com/apache/arrow-rs/pull/9871#discussion_r3191647540


##########
arrow-string/src/like.rs:
##########
@@ -187,6 +189,30 @@ pub fn contains(left: &dyn Datum, right: &dyn Datum) -> Result<BooleanArray, Arr
     like_op(Op::Contains, left, right)
 }
 
+/// Perform equality check on two byte arrays using an ASCII case-insensitive match.

Review Comment:
   It can also be string / stringview / largestring arrays too I think



##########
arrow-string/src/like.rs:
##########
@@ -1394,6 +1425,22 @@ mod tests {
         vec![true, false, true, true, true]
     );
 
+    test_utf8!(
+        test_utf8_array_eq_ignore_ascii_case,
+        vec!["arrow", "arrow", "arrow", "parquet", "parquet"],

Review Comment:
   could we add a substring test too -- like comparing `arrow` to `arro` and verify they don't match



##########
arrow-string/src/like.rs:
##########
@@ -187,6 +189,30 @@ pub fn contains(left: &dyn Datum, right: &dyn Datum) -> Result<BooleanArray, Arr
     like_op(Op::Contains, left, right)
 }
 
+/// Perform equality check on two byte arrays using an ASCII case-insensitive match.
+///
+/// `left` and `right` must be the same type, and one of
+/// - Utf8
+/// - LargeUtf8
+/// - Utf8View
+///
+/// # Example
+/// ```
+/// # use arrow_array::{StringArray, BooleanArray};
+/// # use arrow_string::like::eq_ignore_ascii_case;
+/// let strings = StringArray::from(vec!["arrow", "rs", "arrow-rS", "Parquet"]);
+/// let patterns = StringArray::from(vec!["ARROW", "rS", "ARROW-rs", "arrow"]);
+///
+/// let result = eq_ignore_ascii_case(&strings, &patterns).unwrap();
+/// assert_eq!(result, BooleanArray::from(vec![true, true, true, false]));
+/// ```
+pub fn eq_ignore_ascii_case(

Review Comment:
   Maybe we can change the module doc to be more general:
   
   from 
   ```rust
     //! Provide SQL's LIKE operators for Arrow's string arrays
   ```
   
     to something like:
   ```rust
     //! String predicate kernels for Arrow arrays.
     //!
     //! Provides SQL `LIKE`/`ILIKE` kernels as well as related
     //! string predicates such as `contains`, `starts_with`, `ends_with`, and
     //! ASCII case-insensitive equality.
   ```



##########
arrow-string/src/like.rs:
##########
@@ -187,6 +189,30 @@ pub fn contains(left: &dyn Datum, right: &dyn Datum) -> Result<BooleanArray, Arr
     like_op(Op::Contains, left, right)
 }
 
+/// Perform equality check on two byte arrays using an ASCII case-insensitive match.
+///
+/// `left` and `right` must be the same type, and one of
+/// - Utf8
+/// - LargeUtf8
+/// - Utf8View
+///
+/// # Example
+/// ```
+/// # use arrow_array::{StringArray, BooleanArray};
+/// # use arrow_string::like::eq_ignore_ascii_case;
+/// let strings = StringArray::from(vec!["arrow", "rs", "arrow-rS", "Parquet"]);
+/// let patterns = StringArray::from(vec!["ARROW", "rS", "ARROW-rs", "arrow"]);
+///
+/// let result = eq_ignore_ascii_case(&strings, &patterns).unwrap();
+/// assert_eq!(result, BooleanArray::from(vec![true, true, true, false]));
+/// ```
+pub fn eq_ignore_ascii_case(

Review Comment:
   I think this is fine
   
   The other potential option would be in the `eq` module of arrow-ord -- but that doesn't have string stuff, so I think this is actually better



-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [arrow-string]: add `like::eq_ascii_ignore_case` kernel [arrow-rs]

Posted by "albertlockett (via GitHub)" <gi...@apache.org>.
albertlockett commented on code in PR #9871:
URL: https://github.com/apache/arrow-rs/pull/9871#discussion_r3192168899


##########
arrow-string/src/like.rs:
##########
@@ -187,6 +189,30 @@ pub fn contains(left: &dyn Datum, right: &dyn Datum) -> Result<BooleanArray, Arr
     like_op(Op::Contains, left, right)
 }
 
+/// Perform equality check on two byte arrays using an ASCII case-insensitive match.

Review Comment:
   good catch. fixed in 1f3b03cbb 
   
   "byte array" probably isn't the right wording here. I removed the word "byte" to avoid confusion, and the rust doc also lists the types.
   
   Unrelated question - wondering if e should support large string view in these functions as well?



##########
arrow-string/src/like.rs:
##########
@@ -1394,6 +1425,22 @@ mod tests {
         vec![true, false, true, true, true]
     );
 
+    test_utf8!(
+        test_utf8_array_eq_ignore_ascii_case,
+        vec!["arrow", "arrow", "arrow", "parquet", "parquet"],

Review Comment:
   yes, added in 1f3b03cbb



-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [arrow-string]: add `like::eq_ascii_ignore_case` kernel [arrow-rs]

Posted by "albertlockett (via GitHub)" <gi...@apache.org>.
albertlockett commented on PR #9871:
URL: https://github.com/apache/arrow-rs/pull/9871#issuecomment-4360567397

   I'm hoping `like` is the correct module to add this function? I added it here because I wanted to reuse a lot of the machinery that was already in place to invoke the `Predicate`, but I was hesitating because every other variant of the `Operator` enum in this crate has an equivalent SQL function


-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [arrow-string]: add `like::eq_ascii_ignore_case` kernel [arrow-rs]

Posted by "albertlockett (via GitHub)" <gi...@apache.org>.
albertlockett commented on code in PR #9871:
URL: https://github.com/apache/arrow-rs/pull/9871#discussion_r3192170104


##########
arrow-string/src/like.rs:
##########
@@ -187,6 +189,30 @@ pub fn contains(left: &dyn Datum, right: &dyn Datum) -> Result<BooleanArray, Arr
     like_op(Op::Contains, left, right)
 }
 
+/// Perform equality check on two byte arrays using an ASCII case-insensitive match.
+///
+/// `left` and `right` must be the same type, and one of
+/// - Utf8
+/// - LargeUtf8
+/// - Utf8View
+///
+/// # Example
+/// ```
+/// # use arrow_array::{StringArray, BooleanArray};
+/// # use arrow_string::like::eq_ignore_ascii_case;
+/// let strings = StringArray::from(vec!["arrow", "rs", "arrow-rS", "Parquet"]);
+/// let patterns = StringArray::from(vec!["ARROW", "rS", "ARROW-rs", "arrow"]);
+///
+/// let result = eq_ignore_ascii_case(&strings, &patterns).unwrap();
+/// assert_eq!(result, BooleanArray::from(vec![true, true, true, false]));
+/// ```
+pub fn eq_ignore_ascii_case(

Review Comment:
   yes, updated in 1f3b03cbb



-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [arrow-string]: add `like::eq_ascii_ignore_case` kernel [arrow-rs]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #9871:
URL: https://github.com/apache/arrow-rs/pull/9871#discussion_r3195801604


##########
arrow-string/src/like.rs:
##########
@@ -187,6 +189,30 @@ pub fn contains(left: &dyn Datum, right: &dyn Datum) -> Result<BooleanArray, Arr
     like_op(Op::Contains, left, right)
 }
 
+/// Perform equality check on two byte arrays using an ASCII case-insensitive match.

Review Comment:
   > Unrelated question - wondering if e should support large string view in these functions as well?
   
   Eventually yes. That would be a good follow on PR / issue perhaps



-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [arrow-string]: add `like::eq_ascii_ignore_case` kernel [arrow-rs]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #9871:
URL: https://github.com/apache/arrow-rs/pull/9871


-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org