Closed
Description
Is your feature request related to a problem or challenge?
Summary
Characteristic | Description |
---|---|
Function name: | flatten |
Aliases: | - |
Original function?: | No |
Function Description: | Azure DataBricks: Returns an array of the elements in the union of array1 and array2 without duplicates. Spark SQL: Creates a single array from an array of arrays column. ClickHouse: Converts an array of arrays to a flat array. Function: Applies to any depth of nested arrays. Does not change arrays that are already flat. The flattened array contains all the elements from all source arrays. DuckDB: Concatenate a list of lists into a single list. This only flattens one level of the list (see examples). |
Sources: | Concept Azure DuckDB ClickHouse Spark |
Examples:
D select flatten([[1, 2, 3], [4, 5, 6]]);
┌──────────────────────────────────────────────────────────────────────────────┐
│ flatten(main.list_value(main.list_value(1, 2, 3), main.list_value(4, 5, 6))) │
│ int32[] │
├──────────────────────────────────────────────────────────────────────────────┤
│ [1, 2, 3, 4, 5, 6] │
└──────────────────────────────────────────────────────────────────────────────┘
D select flatten([[[1, 1], [2, 2], [3, 3]], [[4, 4], [5, 5], [6, 6]]]);
┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ flatten(main.list_value(main.list_value(main.list_value(1, 1), main.list_value(2, 2), main.list_value(3, 3)), main.list_value(main.list_value(4, 4), main.li… │
│ int32[][] │
├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]] │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Describe the solution you'd like
No response
Describe alternatives you've considered
No response
Additional context
No response