From 314df9d970bdb033fb1d007a4198d2e22e6364c6 Mon Sep 17 00:00:00 2001 From: Dinos L Date: Tue, 4 Nov 2025 10:08:51 +0100 Subject: [PATCH 1/3] Update unnest.md to showcase the usage of keep_parent_names --- docs/stable/sql/query_syntax/unnest.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/stable/sql/query_syntax/unnest.md b/docs/stable/sql/query_syntax/unnest.md index 1d2737dc0c5..be5d42e4823 100644 --- a/docs/stable/sql/query_syntax/unnest.md +++ b/docs/stable/sql/query_syntax/unnest.md @@ -166,3 +166,24 @@ 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 │ +│ int32 │ int32 │ +├───────┼──────────┤ +│ 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. + + From 033a693dd31a1505f460d1b309200f9d2c09f7c1 Mon Sep 17 00:00:00 2001 From: Dinos L Date: Tue, 4 Nov 2025 10:19:30 +0100 Subject: [PATCH 2/3] Format fix --- docs/stable/sql/query_syntax/unnest.md | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/docs/stable/sql/query_syntax/unnest.md b/docs/stable/sql/query_syntax/unnest.md index be5d42e4823..5377e02f9a3 100644 --- a/docs/stable/sql/query_syntax/unnest.md +++ b/docs/stable/sql/query_syntax/unnest.md @@ -176,14 +176,11 @@ SELECT unnest([{'a': 0, 'b': {'bb': {'bbb': 1}}}], recursive := true, keep_paren ``` yields the following result: -``` -┌───────┬──────────┐ -│ a │ b.bb.bbb │ -│ int32 │ int32 │ -├───────┼──────────┤ -│ 0 │ 1 │ -└───────┴──────────┘ -``` + +| 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. From 838716257375d0c2700e1ecca519d729cc1a309f Mon Sep 17 00:00:00 2001 From: DinosL Date: Tue, 4 Nov 2025 11:16:19 +0100 Subject: [PATCH 3/3] moved to preview --- docs/preview/sql/query_syntax/unnest.md | 16 ++++++++++++++++ docs/stable/sql/query_syntax/unnest.md | 20 +------------------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/docs/preview/sql/query_syntax/unnest.md b/docs/preview/sql/query_syntax/unnest.md index 820f0748050..f085c4bab76 100644 --- a/docs/preview/sql/query_syntax/unnest.md +++ b/docs/preview/sql/query_syntax/unnest.md @@ -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. diff --git a/docs/stable/sql/query_syntax/unnest.md b/docs/stable/sql/query_syntax/unnest.md index 5377e02f9a3..c7e32268943 100644 --- a/docs/stable/sql/query_syntax/unnest.md +++ b/docs/stable/sql/query_syntax/unnest.md @@ -165,22 +165,4 @@ FROM (VALUES ([1, 2, 3]), ([4, 5])) tbl(l); | 2 | 2 | | 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. - - +| 5 | 2 | \ No newline at end of file