augustoasilva commented on a change in pull request #11287:
URL: https://github.com/apache/arrow/pull/11287#discussion_r747428585



##########
File path: cpp/src/gandiva/gdv_function_stubs.cc
##########
@@ -794,6 +795,25 @@ const char* gdv_fn_initcap_utf8(int64_t context, const 
char* data, int32_t data_
   *out_len = out_idx;
   return out;
 }
+
+GANDIVA_EXPORT
+int32_t gdv_fn_instr_utf8(const char* string, int32_t string_len, const char* 
substring,
+                          int32_t substring_len) {
+  if (substring_len == 0) {
+    return 1;
+  }
+
+  if (string_len < substring_len) {

Review comment:
       Fixed this if clause now, it will handle case when string_len == 
substring_len and when string_len < substring_len

##########
File path: cpp/src/gandiva/gdv_function_stubs_test.cc
##########
@@ -766,4 +766,62 @@ TEST(TestGdvFnStubs, TestCastVarbinaryFloat8) {
   ctx.Reset();
 }
 
+TEST(TestGdvFnStubs, TestInstr) {
+  std::string s1 = "hello world!";
+  auto s1_len = static_cast<int32_t>(s1.size());
+  std::string s2 = "world";
+  auto s2_len = static_cast<int32_t>(s2.size());
+
+  auto result = gdv_fn_instr_utf8(s1.c_str(), s1_len, s2.c_str(), s2_len);
+  EXPECT_EQ(result, 7);
+
+  s1 = "apple banana mango";

Review comment:
       Added




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