flatten_all

Aliases: flattenall (deprecated).

flatten_all pathexpression: col array or object, [suggesttypes: bool]?

Given an object or array input, recursively flatten all child and intermediate elements into key-value columns.

The referenced column is removed. New columns include a string path (_c_<column>_path), a variant value column (_c_<column>_value), and a hidden int64 flatten id (_c_<column>_flattenid). Optional second argument suggesttypes must be a constant boolean literal; when true, an extra hidden string column (_c_<column>_type) records the suggested OPAL type for each value. The path column is appended to any existing primary key, grouping keys are cleared, and the result is no longer strongly keyed. Every path appears, including containers: intermediate rows carry object or array values, while flatten would show null for those same paths. flatten_leaves keeps only leaf rows, and flatten_single expands just one level without recursing.

For similarly nested data, flatten is substantially more expensive than flatten_leaves or flatten_single.

Categories

Accelerable

flatten_all is always accelerable if the input is accelerable. A dataset that only uses accelerable verbs can be accelerated, making queries on the dataset respond faster.

Examples

make_col doc:parse_json('{"a":1,"b":{"c":2}}')
flatten_all doc

Recursively unnests a nested JSON object so every path is a row, including the intermediate object at b whose value is still the nested structure.

make_col doc:parse_json('{"tags":["a","b"]}')
flatten_all doc, true

Runs flatten_all with suggesttypes true on an object containing an array so container and element paths both appear with type hints for each value.