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


##########
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:
   Could we add one `utf8_view` case with `ignore_case=true` and non-ASCII 
input here (for example mirroring the existing `MatchSubstringIgnoreCase` 
coverage)?
   
   The implementation intentionally registers `utf8_view` as `StringViewType` 
instead of using the generic `BinaryViewType` dispatch, so it would be good to 
have a test that would fail if we accidentally lost the UTF-8/Latin1 
distinction. The current view-specific tests are mostly ASCII, so they wouldn't 
catch 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