Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs/preview/sql/query_syntax/unnest.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,19 @@ FROM (VALUES ([1, 2, 3]), ([4, 5])) tbl(l);
| 3 | 3 |
| 4 | 1 |
| 5 | 2 |

### Keep Column Names When Recursively Unnesting

The `keep_parent_names` parameter can be used to retain the parent column names when recursively unnesting a named struct. For example, unnesting the following query with `keep_parent_names` enabled:

```sql
SELECT unnest([{'a': 0, 'b': {'bb': {'bbb': 1}}}], recursive := true, keep_parent_names := true);
```

yields the following result:

| a | b.bb.bbb |
|----:|---------:|
| 0 | 1 |

In this case, the field names are preserved, showing the path to the innermost value. This is particularly useful when working with complex nested data structures, as it maintains the structure and naming convention of the original data. The parameter can also be used in conjunction with the `max_depth` parameter, allowing more control and enabling more precise management of nested structures.
2 changes: 1 addition & 1 deletion docs/stable/sql/query_syntax/unnest.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,4 @@ FROM (VALUES ([1, 2, 3]), ([4, 5])) tbl(l);
| 2 | 2 |
| 3 | 3 |
| 4 | 1 |
| 5 | 2 |
| 5 | 2 |