alamb commented on code in PR #10839:
URL: https://github.com/apache/datafusion/pull/10839#discussion_r1633387340


##########
docs/source/user-guide/sql/scalar_functions.md:
##########
@@ -3346,6 +3347,30 @@ trim_array(array, n)
   Can be a constant, column, or function, and any combination of array 
operators.
 - **n**: Element to trim the array.
 
+### `unnest`
+
+Transforms an array into rows.
+
+#### Arguments
+
+- **array**: Array expression to unnest.
+  Can be a constant, column, or function, and any combination of array 
operators.
+
+#### Example
+
+```
+> select unnest(make_array(1, 2, 3, 4, 5));
++------------------------------------------------------------------+
+| unnest(make_array(Int64(1),Int64(2),Int64(3),Int64(4),Int64(5))) |
++------------------------------------------------------------------+
+| 1                                                                |
+| 2                                                                |
+| 3                                                                |
+| 4                                                                |
+| 5                                                                |
++------------------------------------------------------------------+
+```
+

Review Comment:
   unnest also works for structs. Can you possibly add this example too?
   
   ```sql
   > 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.
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to