Different pipes. One standard.

Type to search this site.

Search runs in your browser against a static index built with this site (Pagefind). Nothing you type is sent to a server.

TransformExperimental

std:split #

Routes each item to matched or unmatched by a boolean expression.

For example: send paid orders one way and unpaid ones another.

A pipe is a data processing step with declared inputs and outputs; standard pipes are built into the runner.

Ports #

std:split takes in and produces matched, unmatched.std:splitinrecordsmatchedrecordsunmatchedrecords
std:split takes in and produces matched, unmatched.std:splitinrecordsmatchedrecordsunmatchedrecords
Named ports from the latest published contract. Dashed lines are optional ports.
Ports of std:split
PortDirectionKindRequiredDescription
ininputrecordsyes
matchedoutputrecordsyes
unmatchedoutputrecordsyes

Parameters #

Parameters of std:split
NameTypeDefaultRequiredDescription
exprstringnoneyesStarlark expression over item and params.

When to use it #

  • Two branches that are both processed: paid orders go to invoicing, the rest to a reminder step.
  • Separate records that have a value from those that do not: truthiness decides, so an empty list or a missing member counts as “no”.

When to use something else

  • When only one side matters, std:filter is simpler: its second output is optional. For more than two branches use std:partition or chain splits.

How it works #

std:split routes four items to two outputsThe items 1, 10, 5 and 20 go in. With the expression item >= 10, the items 10 and 20 leave on matched and the items 1 and 5 leave on unmatched, each in their original order.in110520std:splitexpr: item >= 10matched1020unmatched15std:split routes four items to two outputsThe items 1, 10, 5 and 20 go in. With the expression item >= 10, the items 10 and 20 leave on matched and the items 1 and 5 leave on unmatched, each in their original order.in110520std:splitexpr: item >= 10matched1020unmatched15

The items 1, 10, 5 and 20 go in. With the expression item >= 10, the items 10 and 20 leave on matched and the items 1 and 5 leave on unmatched, each in their original order.

Drawn from a real run of the reference implementation.

Every item goes somewhere #

expr is evaluated for every item. A truthy result sends the item, unchanged, to matched; anything else sends it to unmatched. Truthiness is Starlark's: False, None, 0, an empty string and an empty list or dict all count as “no”. The order of the items is kept on each output.

Both outputs are required. Each needs a consumer, or an explicit discard: true — a pipeline that forgets one side does not validate, so nothing is lost by accident. An expression that fails on an item (for example item['missing']) fails the run with E_RUNTIME.

Split, filter or partition #

  • One side matters: std:filter keeps the matching items and drops the rest, or passes them to its optional rejected output.
  • Two sides matter: std:split.
  • More than two: std:partition routes by key to up to eight outputs, or chain several splits. A split whose expression names the output is not part of v0.1 — ports are static.

A tested example #

Nothing here is invented: this is the test “routes both ways” from the pipe's own portable test file, which every conformant runner must pass.

Parameters
{
  "expr": "item >= 10"
}
Input: in
1
10
5
20
Expected output: matched
10
20
Expected output: unmatched
1
5

The same step as a node of a pipeline.yaml:

pipeline.yaml
nodes:
  split:
    pipe: std:split
    inputs:
      in: {from: inputs.in}
    parameters:
      expr: "item >= 10"

Run it #

The pipe runs on its own from a shell. The input is the test input above. The quickstart shows how to get the openflange command.

Command
printf '%s\n' 1 10 5 20 \
  | openflange run std:split \
      --param 'expr=item >= 10' \
      --output matched=- \
      --output unmatched=unmatched.ndjson
Standard output (matched)
10
20
File unmatched.ndjson (unmatched)
1
5

Executed with openflange 0.0.1 (go1.27.1 linux/amd64), built from commit 11cf8cc of the reference implementation; the output shown is what it printed, and it matches the test.

Notes from the manifest #

The pipe's manifest, OPENFLANGE.md, carries these notes.

Part of the OpenFlange standard library (std, version 0.1).

Evaluates expr for every item and routes the unchanged item to matched (truthy) or unmatched (falsy). Each output preserves the input order of its items. Both outputs are required: each needs a consumer or an explicit discard: true (use std:filter when only one side is wanted).

v0.1 has exactly these two outputs. For more branches chain several splits or use std:partition.

yaml
nodes:
  route:
    pipe: std:split
    inputs: {in: {from: inputs.orders}}
    parameters: {expr: "item['total'] >= 100"}
outputs:
  large: {from: route.outputs.matched}
  small: {from: route.outputs.unmatched}

Reference #

Maturity
Experimental
Processing scope
record
Manifest version
0.1.0