safe_not_null
TABLE OF CONTENTS
Return the result of first expression that doesn't resolve to null
Definition
any safe_not_null(any $input, expression->any *$expressions)
Evaluates a series of one or more expressions against $input and returns the first non-null result. If all the expressions evaluate to null, returns null.
Parameters
any $input
Input data to evaluate the expressions on.
expression->any *$expressions
Expressions to evaluate the input data.
Returns
any
The result of the first expression that returns a non-null result, or null if all of them return null.
Examples
Transformation
{
a: safe_not_null(`null`, @, @.a, !@, has_value(@)),
b: safe_not_null(`{}`, @.a, safe_mode(avg(@)), length(@))
}Result
{
"a": true,
"b": 0
}Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article