morrySnow commented on code in PR #49087: URL: https://github.com/apache/doris/pull/49087#discussion_r2004755656
########## fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/StringArithmetic.java: ########## @@ -1010,6 +1004,29 @@ public static Expression quote(StringLikeLiteral first) { */ @ExecFunction(name = "replace_empty") public static Expression replaceEmpty(StringLikeLiteral first, StringLikeLiteral second, StringLikeLiteral third) { + if (second.getValue().isEmpty()) { + if (first.getValue().isEmpty()) { + return castStringLikeLiteral(first, third.getValue()); + } + byte[] input = first.getValue().getBytes(StandardCharsets.UTF_8); + byte[] replace = third.getValue().getBytes(StandardCharsets.UTF_8); + byte[] output = new byte[input.length + (input.length + 1) * replace.length]; + for (int i = 0; i < replace.length; i++) { + output[i] = replace[i]; + } + int last = replace.length; + for (int i = 0; i < input.length; i++) { + for (int j = 0; j < input.length; j++) { + output[last] = input[j]; + last++; + } + for (int j = 0; j < replace.length; j++) { + output[last] = replace[j]; + last++; + } + } Review Comment: maybe reuse splitByGrapheme is a better way. let splitByGrapheme return List<String> instead of ArrayLiteral. and then we can use it here to split input -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org