If component
The If component can evaluate an expression involving variables and direct the flow of an orchestration pipeline depending upon whether the expression evaluates to "true" or "false".
The If component has three output connectors. The blue (top) connector is followed when the expression evaluates to "true". The orange (center) connector is followed when the expression evaluates to "false". The red (bottom) connector is followed if a runtime error occurs during evaluation.
Variables involved in the expression must be declared in advance as pipeline variables or project variables. Read Variables for more information.
Properties
Mode
= drop-down
Select:
- Simple: uses the Condition and Combine Conditions properties to define an expression.
- Advanced: provides a code editor to write your own JavaScript expression.
Condition
(Advanced mode) = code editor
A JavaScript expression, which will be evaluated to determine whether it is true or false. If the expression is not itself a true or false value, then any non-empty string is considered true, as is any non-zero number.
Only used if Mode is set to Advanced
.
Example:
If you have a grid variable new_orders
with columns order_id
, customer_id
, and order_value
, and you want to perform actions based on the number of orders, you can use:
new_orders.order_id.length
You can then use this in an If component to determine the flow, such as checking if there are any new orders and directing the flow accordingly.
Condition
(Simple mode) = column editor
Click + to add a condition. Any number of conditions can be added; the Combine Conditions property will define how they work together.
For each condition, enter the following:
- Input Variable: The variable to use in the comparison. If the input variable is null, it will be considered blank.
- Qualifier: Select Is or Not. Not reverses the meaning of the comparator; for example, changing an "Equals" to a "Does Not Equal" expression.
- Comparator: Select the comparison operator.
- Value: Most commonly a constant value, but can also be a variable reference or expression. The value is parsed according to the type of the input variable.
Only used if Mode is set to Simple
.
Example:
The condition in Simple mode allows users to define conditions using input variables, comparators, and values. Multiple conditions can be combined using the Combine Conditions property to evaluate whether an expression is true or false.
If you have a variable gv_test1
containing a grid with columns col_1
, col_2
, and col_3
, you would need to reference the column and row as follows to check the value in the first row of col_1
:
gv_test1.col_1[0] == "b"
This example will check if the value in the first row of col_1
is equal to "b"
. In Simple mode, you don't need to use ${}
syntax as in Advanced mode, since you're directly comparing values.
Combine Conditions
= drop-down
Use the defined conditions in combination with one another according to either "And" or "Or". Only used if Mode is set to Simple
.
Snowflake | Databricks | Amazon Redshift |
---|---|---|
✅ | ✅ | ✅ |