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:filter #

Keeps the items for which a Starlark expression is truthy.

For example: drop test accounts before a report.

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

Ports #

std:filter takes in and produces out, rejected.std:filterinrecordsoutrecordsrejectedrecords · optional
std:filter takes in and produces out, rejected.std:filterinrecordsoutrecordsrejectedrecords · optional
Named ports from the latest published contract. Dashed lines are optional ports.
Ports of std:filter
PortDirectionKindRequiredDescription
ininputrecordsyes
outoutputrecordsyes
rejectedoutputrecordsnoItems for which the expression is falsy.

Parameters #

Parameters of std:filter
NameTypeDefaultRequiredDescription
exprstringnoneyesStarlark 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 rejected output and the non-matching records arrive there instead of disappearing.

When to use something else

  • When both halves are processed further, std:split has two required outputs. For “the first N records” use std:limit.

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.

Parameters
{
  "expr": "item % 2 == 0"
}
Input: in
1
2
3
4
Expected output: out
2
4
Expected output: rejected

Not connected in this test.

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

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.

Command
printf '%s\n' 1 2 3 4 | openflange run std:filter --param 'expr=item % 2 == 0'
Standard output (out)
2
4

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. 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.

yaml
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