Ports #
| Port | Direction | Kind | Required | Description |
|---|---|---|---|---|
in | input | records | yes | |
out | output | records | yes |
Parameters #
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
mapping | object | none | yes | Map of old member name to new member name. |
When to use it #
- A CSV export says
cust_id, your pipes saycustomerId: 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.
{
"mapping": {
"a": "x"
}
}{"a":1.50,"b":12345678901234567890}{"x":1.50,"b":12345678901234567890}The same step as a node of a 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.
printf '{"a":1.50,"b":12345678901234567890}\n' \
| openflange run std:rename \
--param 'mapping={"a":"x"}'{"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
mappingwith 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.
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
- Normative definition: std:rename in the standard library specification
- Manifest and tests: std/0.1/rename in the specification repository