[Function] Support null_or_empty function (#2977)

It returns true if the string is empty or NULL. Otherwise it returns false.
This commit is contained in:
Lishi
2020-03-01 17:35:45 +08:00
committed by GitHub
parent 078e35a62e
commit 0d1e28746e
6 changed files with 141 additions and 1 deletions

View File

@ -99,6 +99,15 @@ BooleanVal StringFunctions::ends_with(
return BooleanVal(str_sp.ends_with(suffix_sp));
}
BooleanVal StringFunctions::null_or_empty(
FunctionContext* context, const StringVal& str) {
if (str.is_null || str.len == 0) {
return 1;
} else {
return 0;
}
}
StringVal StringFunctions::space(FunctionContext* context, const IntVal& len) {
if (len.is_null){
return StringVal::null();