v.22.4New Feature

Added flattenTuple function for flattening nested named Tuples

Added function flattenTuple. It receives nested named Tuple as an argument and returns a flatten Tuple which elements are the paths from the original Tuple. E.g.: Tuple(a Int, Tuple(b Int, c Int)) -> Tuple(a Int, b Int, c Int). flattenTuple can be used to select all paths from type Object as separate columns. #35690 (Anton Popov).
Added the flattenTuple function that takes a nested named Tuple and returns a flattened Tuple with elements representing the paths from the original structure.

Why it matters

This feature addresses the need to transform nested Tuple 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 the flattenTuple 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.