kangkaisen commented on a change in pull request #3439:
URL: https://github.com/apache/incubator-doris/pull/3439#discussion_r417732926



##########
File path: be/src/exprs/string_functions.cpp
##########
@@ -212,6 +212,28 @@ StringVal StringFunctions::rpad(
     }
     return result;
 }
+
+StringVal 
StringFunctions::append_trailing_char_if_absent(doris_udf::FunctionContext* 
context,
+        const doris_udf::StringVal& str, const doris_udf::StringVal& 
trailing_char) {
+    if (str.is_null || trailing_char.is_null) {
+        return StringVal::null();
+    }
+    if (str.len == 0) {
+        return trailing_char;
+    }
+    if (str.ptr[str.len-1] == trailing_char.ptr[0]) {
+        return str;
+    }
+
+    StringVal result(context, str.len + trailing_char.len);
+    if (UNLIKELY(result.is_null)) {

Review comment:
       Why new result could null?




----------------------------------------------------------------
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to