public class Conditionals extends Object
ScalarValuedFunction
,
DeriveFields
Constructor and Description |
---|
Conditionals() |
Modifier and Type | Method and Description |
---|---|
static ScalarValuedFunction |
caseWhen(List<ScalarValuedFunction> expressions,
List<ScalarValuedFunction> results)
Builds a conditional expression which evaluates similarly to a chain of if..else statement.
|
static ScalarValuedFunction |
caseWhen(List<ScalarValuedFunction> expressions,
List<ScalarValuedFunction> results,
ScalarValuedFunction defaultResult)
Builds a conditional expression which evaluates similarly to a chain of if..else statement.
|
static ScalarValuedFunction |
caseWhen(ScalarValuedFunction base,
List<ScalarValuedFunction> cases,
List<ScalarValuedFunction> results)
Builds a conditional expression which evaluates similarly to a switch statement.
|
static ScalarValuedFunction |
caseWhen(ScalarValuedFunction base,
List<ScalarValuedFunction> cases,
List<ScalarValuedFunction> results,
ScalarValuedFunction defaultResult)
Builds a conditional expression which evaluates similarly to a switch statement.
|
static ScalarValuedFunction |
ifNull(ScalarValuedFunction value,
ScalarValuedFunction replacement)
Build a conditional expression which evaluates to the value of the
specified expression, if non-null.
|
static ScalarValuedFunction |
ifNull(String field,
ScalarValuedFunction replacement)
Build a conditional expression which evaluates to the value of a
field, if non-null.
|
static ScalarValuedFunction |
ifThenElse(ScalarValuedFunction predicate,
ScalarValuedFunction trueValue,
ScalarValuedFunction falseValue)
Builds a conditional expression which evaluates to one of two
subexpressions based on the result of the given predicate.
|
public static ScalarValuedFunction ifThenElse(ScalarValuedFunction predicate, ScalarValuedFunction trueValue, ScalarValuedFunction falseValue)
predicate ? trueValue : falseValue
The subexpressions 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.
predicate
- the expression selecting which of the subexpressions
to which to evaluatetrueValue
- the expression for the value to return when
the predicate evaluates to true
falseValue
- the expression for the value to return when
the predicate does not evaluate to true
public static ScalarValuedFunction ifNull(String field, ScalarValuedFunction replacement)
field
- the record field value to test/returnreplacement
- the expression for the value when the
field value is null
public static ScalarValuedFunction ifNull(ScalarValuedFunction value, ScalarValuedFunction replacement)
null
, the evaluated value of the replacement expression
is returned instead.
The subexpressions must evaluate to comparable types;
the result is of the wider of the two types.
The replacement value is only evaluated if the test expression
evaluates to null-valued.value
- the expression to evaluate, test, and possibly
returnreplacement
- the expression for the value when the
value expression evaluates to null
public static ScalarValuedFunction caseWhen(ScalarValuedFunction base, List<ScalarValuedFunction> cases, List<ScalarValuedFunction> results)
The base expression is compared to each case expression. When the first match is found, the result with the same index as the matching case expression is returned. If no match is found, null is returned.
base
- The base expression used for comparison.cases
- The list of case expressions to compare to the base expression.results
- The list of results to return for each case expression.public static ScalarValuedFunction caseWhen(ScalarValuedFunction base, List<ScalarValuedFunction> cases, List<ScalarValuedFunction> results, ScalarValuedFunction defaultResult)
The base expression is compared to each case expression. When the first match is found, the result with the same index as the matching case expression is returned. If no match is found, the default result is returned.
base
- The base expression used for comparison.cases
- The list of case expressions to compare to the base expression.results
- The list of results to return for each case expression.defaultResult
- The default result to return if no match is found.public static ScalarValuedFunction caseWhen(List<ScalarValuedFunction> expressions, List<ScalarValuedFunction> results)
Each expression is evaluated. When the first expression which returns true is found, the result with the same index as the true expression is returned. If no true expression is found, null is returned.
expressions
- The list of expressions to evaluate.results
- The list of results to return for each expression.public static ScalarValuedFunction caseWhen(List<ScalarValuedFunction> expressions, List<ScalarValuedFunction> results, ScalarValuedFunction defaultResult)
Each expression is evaluated. When the first expression which returns true is found, the result with the same index as the true expression is returned. If no true expression is found, the default result is returned.
expressions
- The list of expressions to evaluate.results
- The list of results to return for each expression.defaultResult
- The result to return if no true expression is found.Copyright © 2020 Actian Corporation. All rights reserved.