ViniciusSouzaRoque commented on code in PR #12803: URL: https://github.com/apache/arrow/pull/12803#discussion_r844223641
########## cpp/src/gandiva/precompiled/string_ops.cc: ########## @@ -2393,152 +2393,239 @@ const char* byte_substr_binary_int32_int32(gdv_int64 context, const char* text, return ret; } +FORCE_INLINE +void concat_word(char* tmp, int* out_tmp, bool* last, const char* word, int word_len, + bool word_validity) { + if (word_validity) { + memcpy(tmp + *out_tmp, word, word_len); + *out_tmp += word_len; + *last = true; + } +} + +FORCE_INLINE +void concat_separator(char* tmp, int* out_tmp, const char* separator, int separator_len, + bool last, bool next) { + if (last && next) { + memcpy(tmp + *out_tmp, separator, separator_len); + *out_tmp += separator_len; + } +} + FORCE_INLINE const char* concat_ws_utf8_utf8(int64_t context, const char* separator, - int32_t separator_len, const char* word1, - int32_t word1_len, const char* word2, int32_t word2_len, - int32_t* out_len) { - if (word1_len < 0 || word2_len < 0 || separator_len < 0) { - gdv_fn_context_set_error_msg(context, "All words can not be null."); + int32_t separator_len, bool separator_validity, + const char* word1, int32_t word1_len, bool word1_validity, + const char* word2, int32_t word2_len, bool word2_validity, + bool* out_valid, int32_t* out_len) { + *out_len = 0; + // If separator is null, always return null + if (!separator_validity) { *out_len = 0; + *out_valid = false; return ""; } + *out_len += separator_len; + if (word1_validity) { + *out_len += word1_len; + } + if (word2_validity) { + *out_len += word2_len; + } - *out_len = word1_len + separator_len + word2_len; char* out = reinterpret_cast<char*>(gdv_fn_context_arena_malloc(context, *out_len)); if (out == nullptr) { - gdv_fn_context_set_error_msg(context, "Could not allocate memory for output string"); *out_len = 0; + *out_valid = false; Review Comment: Oh right, this is a mistake, this need return true I going change -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org