FORK
Serverless Stack
The FORK processing command creates multiple execution branches to operate
on the same input data and combines the results in a single output table.
Syntax
FORK ( <processing_commands> ) ( <processing_commands> ) ... ( <processing_commands> )
Description
The FORK processing command creates multiple execution branches to operate
on the same input data and combines the results in a single output table. A discriminator column (_fork) is added to identify which branch each row came from.
Branch identification:
- The
_forkcolumn identifies each branch with values likefork1,fork2,fork3 - Values correspond to the order branches are defined
fork1always indicates the first branch
Column handling:
FORKbranches can output different columns- Columns with the same name must have the same data type across all branches
- Missing columns are filled with
nullvalues
Row ordering:
FORKpreserves row order within each branch- Rows from different branches may be interleaved
- Use
SORT _forkto group results by branch
Note
FORK branches default to LIMIT 1000 if no LIMIT is provided.
Limitations
FORKsupports at most 8 execution branches.- Using remote cluster references and
FORKis not supported. - Using more than one
FORKcommand in a query is not supported.
Examples
In the following example, each FORK branch returns one row.
Notice how FORK adds a _fork column that indicates which row the branch originates from:
FROM employees
| FORK ( WHERE emp_no == 10001 )
( WHERE emp_no == 10002 )
| KEEP emp_no, _fork
| SORT emp_no
| emp_no:integer | _fork:keyword |
|---|---|
| 10001 | fork1 |
| 10002 | fork2 |