jonahgao commented on code in PR #9355:
URL: https://github.com/apache/arrow-datafusion/pull/9355#discussion_r1505483093


##########
datafusion/sqllogictest/test_files/unnest.slt:
##########
@@ -121,5 +183,49 @@ select unnest(array_remove(column1, 12)) from unnest_table;
 5
 6
 
+
+## Unnest in from clause with alias
+query I
+select * from unnest([1,2]) as t;
+----
+1
+2
+
+query I
+select a from unnest([1,2]) as t(a);
+----
+1
+2
+
+
+## Unnest in from clause with offset is not supported
+query error DataFusion error: This feature is not implemented: UNNEST table 
factor with offset is not supported yet
+select * from unnest([1,2]) with offset;
+
+query error DataFusion error: This feature is not implemented: UNNEST table 
factor with offset is not supported yet
+select * from unnest([1,2]) with offset offset_alias;
+
+
+## More complex cases
+query I
+select * from unnest([1,2,(select sum(column3) from unnest_table)]);
+----
+1
+2
+6
+
+query II??I rowsort
+select * from unnest([1]), unnest([2, 3]), unnest_table;

Review Comment:
   I found that the result of this query is the same as with DuckDB, except for 
the order of the rows. Did I overlook something else?
   
   In DataFusion:
   ```sh
   DataFusion CLI v36.0.0
   ❯ create table t1 as values([1,2,3]), ([10, 20]);
   0 rows in set. Query took 0.010 seconds.
   
   ❯ select * from unnest([1,2,3]), unnest([4,5]) as b2, t1;
   
+----------------------------------------+-------------------------------+-----------+
   | make_array(Int64(1),Int64(2),Int64(3)) | make_array(Int64(4),Int64(5)) | 
column1   |
   
+----------------------------------------+-------------------------------+-----------+
   | 1                                      | 4                             | 
[1, 2, 3] |
   | 1                                      | 4                             | 
[10, 20]  |
   | 1                                      | 5                             | 
[1, 2, 3] |
   | 1                                      | 5                             | 
[10, 20]  |
   | 2                                      | 4                             | 
[1, 2, 3] |
   | 2                                      | 4                             | 
[10, 20]  |
   | 2                                      | 5                             | 
[1, 2, 3] |
   | 2                                      | 5                             | 
[10, 20]  |
   | 3                                      | 4                             | 
[1, 2, 3] |
   | 3                                      | 4                             | 
[10, 20]  |
   | 3                                      | 5                             | 
[1, 2, 3] |
   | 3                                      | 5                             | 
[10, 20]  |
   
+----------------------------------------+-------------------------------+-----------+
   12 rows in set. Query took 0.014 seconds.
   ```
   And in DuckDB:
   ```sh
   v0.9.3-dev3269 8de2d291d8
   
   D create table t1 as values([1,2,3]), ([10, 20]);
   D select * from unnest([1,2,3]), unnest([4,5]) as b2, t1;
   ┌──────────────────────────┬───────────────────────┬───────────┐
   │ main.list_value(1, 2, 3) │ main.list_value(4, 5) │   col0    │
   │          int32           │         int32         │  int32[]  │
   ├──────────────────────────┼───────────────────────┼───────────┤
   │                        1 │                     4 │ [1, 2, 3] │
   │                        2 │                     4 │ [1, 2, 3] │
   │                        3 │                     4 │ [1, 2, 3] │
   │                        1 │                     5 │ [1, 2, 3] │
   │                        2 │                     5 │ [1, 2, 3] │
   │                        3 │                     5 │ [1, 2, 3] │
   │                        1 │                     4 │ [10, 20]  │
   │                        2 │                     4 │ [10, 20]  │
   │                        3 │                     4 │ [10, 20]  │
   │                        1 │                     5 │ [10, 20]  │
   │                        2 │                     5 │ [10, 20]  │
   │                        3 │                     5 │ [10, 20]  │
   ├──────────────────────────┴───────────────────────┴───────────┤
   │ 12 rows                                            3 columns │
   └──────────────────────────────────────────────────────────────┘
   ```



-- 
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]

Reply via email to