v.22.4New Feature
Added flattenTuple function for flattening nested named Tuples
Added functionflattenTuple. It receives nested namedTupleas an argument and returns a flattenTuplewhich elements are the paths from the originalTuple. E.g.:Tuple(a Int, Tuple(b Int, c Int)) -> Tuple(a Int, b Int, c Int).flattenTuplecan be used to select all paths from typeObjectas separate columns. #35690 (Anton Popov).
Why it matters
This feature addresses the need to transform nestedTuple types into a flat structure, simplifying data manipulation and extraction. It is especially useful for working with Object-typed data, allowing users to select all nested paths as separate columns easily.How to use it
Use theflattenTuple function by passing a nested named Tuple to it. The function will return a single-level Tuple with all nested elements flattened. For example:SELECT flattenTuple(Tuple(a Int, Tuple(b Int, c Int)))
-- Returns: Tuple(a Int, b Int, c Int)This can be applied to extract individual columns from nested
Object types.