coalesce()coalesce()
计算表达式列表,并返回第一个非 null(或非空,适用于字符串)表达式。Evaluates a list of expressions and returns the first non-null (or non-empty for string) expression.
coalesce(tolong("not a number"), tolong("42"), 33) == 42
语法Syntax
coalesce(
expr_1,
expr_2,
...)coalesce(
expr_1,
expr_2,
...)
参数Arguments
- expr_i:要计算的标量表达式。expr_i : A scalar expression, to be evaluated.
- 所有参数的类型必须相同。All arguments must be of the same type.
- 最多支持 64 个参数。Maximum of 64 arguments is supported.
返回Returns
其值不为 null(或不为空,适用于字符串表达式)的第一个 expr_i 的值。The value of the first expr_i whose value is not null (or not-empty for string expressions).
示例Example
print result=coalesce(tolong("not a number"), tolong("42"), 33)
resultresult |
---|
4242 |