[Feature][Function] support bit_length function (#6140)

support bit_length function like mysql
This commit is contained in:
DinoZhang
2021-07-08 09:40:30 +08:00
committed by GitHub
parent c33321ff42
commit c929a8935a
8 changed files with 139 additions and 0 deletions

View File

@ -995,4 +995,14 @@ StringVal StringFunctions::replace(FunctionContext* context, const StringVal& or
}
return AnyValUtil::from_string_temp(context, orig_str);
}
// Implementation of BIT_LENGTH
// int bit_length(string input)
// Returns the length in bits of input. If input == NULL, returns
// NULL per MySQL
IntVal StringFunctions::bit_length(FunctionContext* context, const StringVal& str) {
if (str.is_null) {
return IntVal::null();
}
return IntVal(str.len * 8);
}
} // namespace doris