W3cubDocs

/Nushell

merge for filters

Merge the input with a record or table, overwriting values in matching columns.

Signature

> merge {flags} (value)

Parameters

  • value: the new value to merge with

Input/output types:

input output
record record
table table

Examples

Add an 'index' column to the input table

> [abc] |wrapname|merge ( [123] |wrapindex )
╭───┬──────╮
# │ name │
├───┼──────┤
1a
2b
3c
╰───┴──────╯

Merge two records

> {a:1, b:2} |merge {c:3}
╭───┬───╮
a1
b2
c3
╰───┴───╯

Merge two tables, overwriting overlapping columns

> [{columnA:A0columnB:B0}] |merge [{columnA:'A0*'}]
╭───┬─────────┬─────────╮
# │ columnA │ columnB │
├───┼─────────┼─────────┤
0A0*B0
╰───┴─────────┴─────────╯

Notes

You may provide a column structure to merge

When merging tables, row 0 of the input table is overwritten with values from row 0 of the provided table, then repeating this process with row 1, and so on.

Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/merge.html