Was this helpful?
Conditional Functions
The Conditionals category provides functions that apply logic for conditionally selecting input values. The ifNull() function is useful for handling null data values with the result of the replacement function. The replacement function can simply be the value of another input field.
The ifThenElse() function is useful for selecting the sub-expression value wanted based on the result of a predicate expression. A predicate expression returns a boolean (true or false) value.
Function Name
Description
Output Type
Parameters
Conditionals.ifNull
Builds a conditional expression that evaluates to the value of a field, if non-null. Otherwise, it evaluates to the value of the replacement expression.
The input field and replacement expression must evaluate to comparable types; the result is of the wider of the two types. The replacement value is only evaluated if the test field is null-valued.
Wider of the input field type and the replacement expression output type.
Input data value
Replacement expression
Conditionals.ifThenElse
Builds a conditional expression that evaluates to one of two sub-expressions based on the result of the given predicate. This is equivalent to to the ternary operator in Java:
predicate ? trueValue : falseValue
The sub-expressions must evaluate to comparable types; the result is of the wider of the two types.
The result expressions are only evaluated as required; that is, only one of the value expressions will be evaluated per invocation.
Wider of the output types of the given sub-expressions.
Boolean valued expression defining which sub-expression to use
Expression to use for true conditions
Expression to use for false conditions
Conditionals.caseWhen
Builds a conditional expression that evaluates to one of many possible values, similarly to a switch or case statement.
If a base expression is given, it is compared against each case expression, and when the first match is found, the associated return value (that with the same index as the matching case expression) is returned.
If no base expression is given, each case expression must be a Boolean predicate. The first one that evaluates to true is considered a match, and the associated return value is returned.
If no match is found, the function will return null, or, if a default result is given, that value.
Wider of the output types of the given result sub-expressions.
Base expression to compare against each case (optional)
A list of case expressions
A list of result expressions, one for each case
A default result expression (optional)
Last modified date: 06/14/2024