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

Keeps only the listed members of each record.

For example: keep only the columns a report needs.

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

Ports #

std:select takes in and produces out.std:selectinrecordsoutrecords
std:select takes in and produces out.std:selectinrecordsoutrecords
Named ports from the latest published contract. Dashed lines are optional ports.
Ports of std:select
PortDirectionKindRequiredDescription
ininputrecordsyes
outoutputrecordsyes

Parameters #

Parameters of std:select
NameTypeDefaultRequiredDescription
fieldsarraynoneyesMember 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 use std: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.

Parameters
{
  "fields": [
    "b",
    "a"
  ]
}
Input: in
{"a":1,"b":2,"c":3}
Expected output: out
{"b":2,"a":1}

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

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.

Command
printf '%s\n' '{"a":1,"b":2,"c":3}' | openflange run std:select --param 'fields=["b","a"]'
Standard output (out)
{"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