projjal commented on a change in pull request #12440:
URL: https://github.com/apache/arrow/pull/12440#discussion_r827643055



##########
File path: cpp/src/gandiva/precompiled/string_ops.cc
##########
@@ -2163,31 +2163,37 @@ const char* left_utf8_int32(gdv_int64 context, const 
char* text, gdv_int32 text_
     return "";
   }
 
+  int32_t char_count = utf8_length(context, text, text_len);
+
+  // char_count is zero if input has invalid utf8 char
+  if (char_count == 0) {
+    *out_len = 0;
+    return "";
+  }
+
+  // case where left('abcdef', -6) -> "" and left('abcdef', -7) -> ""
+  if(number < 0 && abs(number) >= char_count) {

Review comment:
       nit: just use -number instead of abs(number)




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