-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs: Add unnest
to SQL Reference
#10839
Conversation
31d6c29
to
22be392
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much @gloomweaver -- this is great. I have another suggestion for documenting unnest for structs as well.
| 5 | | ||
+------------------------------------------------------------------+ | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnest also works for structs. Can you possibly add this example too?
> create table foo as values (named_struct('a', 5, 'b', 'a string'));
0 row(s) fetched.
Elapsed 0.008 seconds.
> select * from foo;
+---------------------+
| column1 |
+---------------------+
| {a: 5, b: a string} |
+---------------------+
1 row(s) fetched.
Elapsed 0.003 seconds.
> select unnest(column1) from foo;
+-----------------------+-----------------------+
| unnest(foo.column1).a | unnest(foo.column1).b |
+-----------------------+-----------------------+
| 5 | a string |
+-----------------------+-----------------------+
1 row(s) fetched.
Elapsed 0.003 seconds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could merge this PR as is, as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, sure. This should be in Struct Functions
right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also love to add a range example
select unnest(range(0, 100000))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, sure. This should be in Struct Functions right?
I think that would make sense.
FWIW here is an example:
DataFusion CLI v39.0.0
> select unnest(range(0, 10));
+-----------------------------------+
| unnest(range(Int64(0),Int64(10))) |
+-----------------------------------+
| 0 |
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
| 7 |
| 8 |
| 9 |
+-----------------------------------+
10 row(s) fetched.
Elapsed 0.054 seconds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added docs for struct unnest and example this range for array.
Couldn't link to it because of the name.
Is there a way to assign custom id to a block with sphinx? Tried labels, didn't work, so named it unnest (struct)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to assign custom id to a block with sphinx? Tried labels, didn't work, so named it unnest (struct).
I am not sure to be honest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
love it, thanks @gloomweaver
@gloomweaver please run the prettier locally, it will reformat the MD files a little bit |
|
I took the liberty of running prettier locally to save @gloomweaver the trouble of installing it locally |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much @gloomweaver and @comphead
@@ -3480,6 +3524,34 @@ select named_struct('field_a', a, 'field_b', b) from t; | |||
Can be a constant, column, or function, and any combination of arithmetic or | |||
string operators. | |||
|
|||
|
|||
### `unnest (struct)` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
Thanks again @gloomweaver and @comphead |
* Add unnest to SQL Reference * Add unnest docs for struct, add additional example for unnest array * unnest -> unnest (struct) * prettier --------- Co-authored-by: Andrew Lamb <[email protected]>
Which issue does this PR close?
Closes #.
Rationale for this change
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?