You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/04/29 00:32:33 UTC

[GitHub] [arrow] jpedroantunes commented on a change in pull request #10155: ARROW-12534: [C++][Gandiva] Implement LEFT and RIGHT functions on Gandiva for string input values

jpedroantunes commented on a change in pull request #10155:
URL: https://github.com/apache/arrow/pull/10155#discussion_r622658277



##########
File path: cpp/src/gandiva/precompiled/string_ops.cc
##########
@@ -1481,6 +1481,82 @@ const char* split_part(gdv_int64 context, const char* text, gdv_int32 text_len,
   return "";
 }
 
+FORCE_INLINE
+const char* left(gdv_int64 context, const char* text, gdv_int32 text_len,
+                 gdv_int32 number, gdv_int32* out_len) {
+  // returns the 'number' left most characters of a given text
+  if (text_len == 0 || number == 0) {
+    *out_len = 0;
+    return "";
+  }
+
+  // initially counts the number of utf8 characters in the defined text
+  int32_t charCount = utf8_length(context, text, text_len);
+  // charCount is zero if input has invalid utf8 char
+  if (charCount == 0) {

Review comment:
       I did to keep the compatibility with the function which we based. When UTF8 char is found, an error is set.
   If you think it still makes sense to enforce this behavior, I can do it




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

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