Ports #
| Port | Direction | Kind | Required | Description |
|---|---|---|---|---|
in | input | records | yes | |
out | output | records | yes | |
rejected | output | records | no | Items for which the expression is falsy. |
Parameters #
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
expr | string | none | yes | Starlark expression over item and params. |
When to use it #
- Keep only the records a later step should see:
item['status'] == 'paid'. - Remove test or internal accounts before counting customers.
- Look at what was removed: connect the optional
rejectedoutput and the non-matching records arrive there instead of disappearing.
When to use something else
A tested example #
Nothing here is invented: this is the test “keeps matching items” from the pipe's own portable test file, which every conformant runner must pass.
{
"expr": "item % 2 == 0"
}1
2
3
42
4Not connected in this test.
The same step as a node of a pipeline.yaml:
nodes:
filter:
pipe: std:filter
inputs:
in: {from: inputs.in}
parameters:
expr: "item % 2 == 0"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.
printf '%s\n' 1 2 3 4 | openflange run std:filter --param 'expr=item % 2 == 0'2
4Executed 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. Truthy → the item is passed to out
byte-for-byte (it is not re-encoded, so number literals are preserved).
Falsy → the item goes to the optional output rejected when that port is
connected, and is dropped otherwise. Dropping is this pipe's documented
purpose; it is not an error.
nodes:
adults:
pipe: std:filter
inputs: {in: {from: inputs.people}}
parameters: {expr: "item['age'] >= 18"}Reference #
- Maturity
- Experimental
- Processing scope
record- Manifest version
0.1.0
- Normative definition: std:filter in the standard library specification
- Manifest and tests: std/0.1/filter in the specification repository
- Expression parameters are Starlark: how expressions are evaluated