set
Assigns a value to a field, creating it if necessary.
field = exprset field=expr...
Description
Section titled “Description”Assigns a value to a field, creating it if necessary. If the field does not
exist, it is appended to the end. If the field name is a path such as
foo.bar.baz
, records for foo
and bar
will be created if they do not exist
yet.
Within assignments, the move
keyword in front of a field causes a field to be
removed from the input after evaluation.
Examples
Section titled “Examples”Append a new field
Section titled “Append a new field”from {a: 1, b: 2}c = a + b
{a: 1, b: 2, c: 3}
Update an existing field
Section titled “Update an existing field”from {a: 1, b: 2}a = "Hello"
{a: "Hello", b: 2}
Move a field
Section titled “Move a field”from {a: 1}b = move a
{b: 1}