[Fix](Nereids) fix append_trailing_char_if_absent function return null (#41157)
cherry-pick: https://github.com/apache/doris/pull/40820 example: select append_trailing_char_if_absent('it','a') would return null in original design, it can not return null when folding constant on fe any time
This commit is contained in:
@ -105,13 +105,19 @@ public class ExecutableFunctions {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* append_trailing_char_if_absent function
|
||||
*/
|
||||
@ExecFunction(name = "append_trailing_char_if_absent", argTypes = {"VARCHAR", "VARCHAR"}, returnType = "VARCHAR")
|
||||
public static Expression appendTrailingIfCharAbsent(StringLikeLiteral literal, StringLikeLiteral chr) {
|
||||
if (literal.getValue().length() != 1) {
|
||||
return null;
|
||||
if (chr.getValue().length() != 1) {
|
||||
return new NullLiteral(literal.getDataType());
|
||||
}
|
||||
if (literal.getValue().endsWith(chr.getValue())) {
|
||||
return literal;
|
||||
} else {
|
||||
return new VarcharLiteral(literal.getValue() + chr.getValue());
|
||||
}
|
||||
return literal.getValue().endsWith(chr.getValue()) ? literal
|
||||
: new VarcharLiteral(literal.getValue() + chr.getValue());
|
||||
}
|
||||
|
||||
@ExecFunction(name = "e", argTypes = {}, returnType = "DOUBLE")
|
||||
|
||||
Reference in New Issue
Block a user