In the realm of Syncraft, the If-Else Pipeline acts as a decision-maker, orchestrating the flow of logic based on certain conditions. This pipeline is paramount when the data processing logic needs to diverge based on specific predicates.
The If-Else Pipeline is structured around three primary components:
[
{
"query": {
"id": {
"eq": 2
}
},
"selection": {
"id": true,
"name": true
},
"root": "Users"
},
{
"if": {
"id": {
"eq": 21
}
},
"then": {
"query": {
"id": {
"eq": 4
}
},
"selection": {
"id": true,
"name": true
},
"root": "Users"
},
"else": {
"query": {
"id": {
"eq": 1
}
},
"selection": {
"id": true,
"name": true,
"active": true
},
"root": "Users"
}
}
]
if
block contains the condition to be evaluated. In the example above, it checks if the id
field equals 21.then
block is executed. Here, it queries for a user with id
equal to 4 and selects the id
and name
fields from the Users
root.else
block is executed. In this scenario, it queries for a user with id
equal to 1 and selects the id
, name
, and active
fields from the Users
root.The If-Else Pipeline can seamlessly blend within a larger query pipeline structure, facilitating condition-driven logic flows. It can be nested within higher-order pipelines like Serial, Parallel, or Race pipelines to further fine-tune the logic flow, making the query engine versatile and adaptive to varying data scenarios.