flatten
Flattens nested data.
Description
The flatten
function takes a record and performs actions of contained
container types:
- Records: Join nested records with a separator (
.
by default). For example, if a field namedx
is a record with fieldsa
andb
, flattening will lift the nested record into the parent scope by creating two new fieldsx.a
andx.b
. - Lists: Merge nested lists into a single (flat) list. For example,
[[[2]], [[3, 1]], [[4]]]
becomes[2, 3, 1, 4]
.
For records inside lists, flatten
"pushes lists down" into one list per record
field. For example, the record
becomes
Lists nested in records that are nested in lists will also be flattened. For example, the record
becomes
As you can see from the above examples, flattening also removes null
values.
sep = string (optional)
The separator to use for joining field names.
Defaults to "."
.