Ports #
| Port | Direction | Kind | Required | Description |
|---|---|---|---|---|
in | input | records | yes | |
out | output | records | yes |
Parameters #
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
fields | array | none | yes | Member names to keep, in output order. |
When to use it #
- Drop internal members (notes, cost price) before records leave your system.
- Fix the order of members before
std:csv-encode, which takes its columns from the first record.
When to use something else
- A listed member that a record does not have is left out, not written as
null. For computed members usestd:map.
A tested example #
Nothing here is invented: this is the test “projects and reorders” from the pipe's own portable test file, which every conformant runner must pass.
{
"fields": [
"b",
"a"
]
}{"a":1,"b":2,"c":3}{"b":2,"a":1}The same step as a node of a pipeline.yaml:
nodes:
select:
pipe: std:select
inputs:
in: {from: inputs.in}
parameters:
fields: ["b", "a"]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' '{"a":1,"b":2,"c":3}' | openflange run std:select --param 'fields=["b","a"]'{"b":2,"a":1}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).
For each JSON object, emits a new object containing only the top-level
fields named in fields, in that order. Field values are copied as raw bytes,
so nested values and number literals are preserved exactly. A field that is
missing from a record is simply absent from the output. A non-object item
fails the run with E_RUNTIME.
Reference #
- Maturity
- Experimental
- Processing scope
record- Manifest version
0.1.0
- Normative definition: std:select in the standard library specification
- Manifest and tests: std/0.1/select in the specification repository