Reduces a nested {data} structure into a flat list. All levels are flattened into one single row unless you specify a depth limit.

Parameter List


The {data} structure to flatten.

[optional] depth

The number of levels to flatten in the {data} structure. By default, all levels are flattened into one list.

  • Use 1 to only flatten items one level down but retain the hierarchy for items in the second level and deeper.
  • Use 2 to flatten items two levels down and so on.
More details

The depth is counted from the top of the data structure all the way down to the down to the deepest node.

For example, suppose that you have a data schema that describes a humanoid 3D model. The hierarchy might look something like this:

Before Flatten

If you flattened it down to level 2 only, it would look like this:

After Flatten

The "Iris" node is still nested underneath the "leftEye" node, but the rest of the structure is flattened into one level.


FLATTEN('{"location": {"city": "Berlin"}', 1) returns {"location.city": "Berlin"}