fangchenli commented on code in PR #50479:
URL: https://github.com/apache/arrow/pull/50479#discussion_r3576059277


##########
cpp/src/arrow/compute/kernels/scalar_string_test.cc:
##########
@@ -2690,4 +2694,129 @@ TEST(TestStringKernels, UnicodeLibraryAssumptions) {
 }
 #endif
 
+// ----------------------------------------------------------------------
+// View type support for scalar string predicate/measurement kernels.
+
+// Mixes empty, inlined (<= 12 bytes), out-of-line (> 12 bytes), and null 
values
+// to cover the view layout.
+constexpr auto kViewInput =
+    R"(["", "cat", null, "the quick brown fox", "concatenation", "a cat sat", 
"CAT"])";
+
+TEST(TestStringViewPredicates, MatchSubstring) {
+  MatchSubstringOptions options{"cat"};
+  for (const auto& ty : {binary_view(), utf8_view()}) {
+    CheckScalarUnary("match_substring", ty, kViewInput, boolean(),
+                     "[false, true, null, false, true, true, false]", 
&options);
+  }
+}
+
+TEST(TestStringViewPredicates, StartsWithEndsWith) {
+  MatchSubstringOptions starts{"c"};
+  MatchSubstringOptions ends{"t"};
+  for (const auto& ty : {binary_view(), utf8_view()}) {
+    CheckScalarUnary("starts_with", ty, kViewInput, boolean(),
+                     "[false, true, null, false, true, false, false]", 
&starts);
+    CheckScalarUnary("ends_with", ty, kViewInput, boolean(),
+                     "[false, true, null, false, false, true, false]", &ends);
+  }
+}
+
+TEST(TestStringViewPredicates, FindSubstring) {
+  MatchSubstringOptions options{"cat"};
+  for (const auto& ty : {binary_view(), utf8_view()}) {
+    CheckScalarUnary("find_substring", ty, kViewInput, int32(),
+                     "[-1, 0, null, -1, 3, 2, -1]", &options);
+  }
+}
+
+TEST(TestStringViewPredicates, CountSubstring) {
+  MatchSubstringOptions options{"cat"};
+  for (const auto& ty : {binary_view(), utf8_view()}) {
+    CheckScalarUnary("count_substring", ty, kViewInput, int32(),
+                     "[0, 1, null, 0, 1, 1, 0]", &options);
+  }
+}
+
+TEST(TestStringViewPredicates, BinaryLength) {
+  for (const auto& ty : {binary_view(), utf8_view()}) {
+    CheckScalarUnary("binary_length", ty, kViewInput, int32(),
+                     "[0, 3, null, 19, 13, 9, 3]");
+  }
+}
+
+#ifdef ARROW_WITH_RE2
+TEST(TestStringViewPredicates, MatchSubstringRegex) {
+  MatchSubstringOptions options{"a+"};
+  const auto* input = R"(["", "cat", null, "aaa banana", "concatenation"])";
+  for (const auto& ty : {binary_view(), utf8_view()}) {

Review Comment:
   Good call. Added `TestStringViewPredicates.MatchSubstringIgnoreCase` in 
8082d31: it mirrors the existing `MatchSubstringIgnoreCase` coverage with 
pattern `"aé("`, `ignore_case=true`, and input `["abc", "aEb", "baÉ(", "aé(", 
"ae(", "Aé("]` → `[false, false, true, true, false, true]`. The uppercase `É` 
matching lowercase `é` only holds because `utf8_view` folds over the full 
Unicode range; if it were dispatched through the generic `BinaryViewType` path 
(ASCII/Latin1 folding only) that slot would come back `false`, so the test 
fails on that regression.



-- 
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]

Reply via email to