merge
Combines two records into a single record by merging their fields.
merge(x: record, y: record) -> record
Description
Section titled “Description”The merge
function takes two records and returns a new record containing all
fields from both records. If both records contain the same field, the value from
the second record takes precedence.
Examples
Section titled “Examples”Basic record merging
Section titled “Basic record merging”from {x: {a: 1, b: 2}, y: {c: 3, d: 4}}select result = merge(x, y)
{ result: { a: 1, b: 2, c: 3, d: 4 }}
Handling overlapping fields
Section titled “Handling overlapping fields”When fields exist in both records, the second record’s values take precedence:
from { r1: {name: "Alice", age: 30}, r2: {name: "Bob", location: "NY"},}select result = merge(r1, r2)
{ result: { name: "Bob", age: 30, location: "NY" }}
Handling null values
Section titled “Handling null values”If either input is null, the input will be ignored.
from {x: {a: 1}, y: null}select result = merge(x, y)
{ result { a: 1 }}