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

Renames members of each record.

For example: rename the columns of an export to the names your pipes expect.

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

Ports #

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

Parameters #

Parameters of std:rename
NameTypeDefaultRequiredDescription
mappingobjectnoneyesMap of old member name to new member name.

When to use it #

  • A CSV export says cust_id, your pipes say customerId: rename once, right after decoding.
  • Give two sources the same member names before you combine them with std:merge.

When to use something else

  • It never overwrites data: a rename onto a member that already exists fails the item. To build a member from other members, use std:map.

A tested example #

Nothing here is invented: this is the test “renames in place and keeps order and literals” from the pipe's own portable test file, which every conformant runner must pass.

Parameters
{
  "mapping": {
    "a": "x"
  }
}
Input: in
{"a":1.50,"b":12345678901234567890}
Expected output: out
{"x":1.50,"b":12345678901234567890}

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

pipeline.yaml
nodes:
  rename:
    pipe: std:rename
    inputs:
      in: {from: inputs.in}
    parameters:
      mapping: {a: "x"}

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 '{"a":1.50,"b":12345678901234567890}\n' \
  | openflange run std:rename \
      --param 'mapping={"a":"x"}'
Standard output (out)
{"x":1.50,"b":12345678901234567890}

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

Renames the top-level fields listed in mapping (old: new). Fields keep their position, and values are copied as raw bytes, so nested values and number literals are preserved exactly. A field that is absent from a record is ignored. One object in, one object out.

Errors:

  • two entries of mapping with the same new name → E_PARAM (before the run);
  • a rename that would give one record the same field name twice → E_RUNTIME;
  • a non-object item → E_RUNTIME.
yaml
nodes:
  tidy:
    pipe: std:rename
    inputs: {in: {from: inputs.rows}}
    parameters:
      mapping: {fname: firstName, lname: lastName}

Reference #

Maturity
Experimental
Processing scope
record
Manifest version
0.1.0