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


##########
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:
   example here, not sure what happen in physical plan
   ```
   statement ok
   create table t1 as values
     ([1,2,3], 1),
     ([4,5,6], 2)
   ;
   
   statement ok
   create table t2 as values
     (10),
     (20)
   ;
   
   query ?II
   select * from t1 cross join t2;
   ----
   [1, 2, 3] 1 10
   [4, 5, 6] 2 10
   [1, 2, 3] 1 20
   [4, 5, 6] 2 20
   
   query TT
   explain select * from t1 cross join t2;
   ----
   logical_plan
   CrossJoin:
   --TableScan: t1 projection=[column1, column2]
   --TableScan: t2 projection=[column1]
   physical_plan
   ProjectionExec: expr=[column1@1 as column1, column2@2 as column2, column1@0 
as column1]
   --CrossJoinExec
   ----MemoryExec: partitions=1, partition_sizes=[1]
   ----MemoryExec: partitions=1, partition_sizes=[1]
   
   query II
   select * from unnest([1,2,3]) as b2, t2;
   ----
   1 10
   1 20
   2 10
   2 20
   3 10
   3 20
   
   query TT
   explain select * from unnest([1,2,3]) as b2, t2;
   ----
   logical_plan
   CrossJoin:
   --SubqueryAlias: b2
   ----Unnest: make_array(Int64(1),Int64(2),Int64(3))
   ------Projection: List([1, 2, 3]) AS make_array(Int64(1),Int64(2),Int64(3))
   --------EmptyRelation
   --TableScan: t2 projection=[column1]
   physical_plan
   CrossJoinExec
   --UnnestExec
   ----ProjectionExec: expr=[[1, 2, 3] as 
make_array(Int64(1),Int64(2),Int64(3))]
   ------PlaceholderRowExec
   --MemoryExec: partitions=1, partition_sizes=[1]
   ```



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