@@ -979,4 +979,63 @@ mod supported {
979979
980980 Ok ( ( ) )
981981 }
982+
983+ #[ rstest]
984+ #[ case:: standalone( standalone_context( ) ) ]
985+ #[ case:: remote( remote_context( ) ) ]
986+ #[ tokio:: test]
987+ async fn should_execute_explain_query_correctly (
988+ #[ future( awt) ]
989+ #[ case]
990+ ctx : SessionContext ,
991+ ) {
992+ let result = ctx
993+ . sql ( "EXPLAIN select count(*), id from (select unnest([1,2,3,4,5]) as id) group by id" )
994+ . await
995+ . unwrap ( )
996+ . collect ( )
997+ . await
998+ . unwrap ( ) ;
999+
1000+ let expected: Vec < & str > = vec ! [
1001+ "+------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+" ,
1002+ "| plan_type | plan |" ,
1003+ "+------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+" ,
1004+ "| logical_plan | Projection: count(Int64(1)) AS count(*), id |" ,
1005+ "| | Aggregate: groupBy=[[id]], aggr=[[count(Int64(1))]] |" ,
1006+ "| | Projection: __unnest_placeholder(make_array(Int64(1),Int64(2),Int64(3),Int64(4),Int64(5)),depth=1) AS UNNEST(make_array(Int64(1),Int64(2),Int64(3),Int64(4),Int64(5))) AS id |" ,
1007+ "| | Unnest: lists[__unnest_placeholder(make_array(Int64(1),Int64(2),Int64(3),Int64(4),Int64(5)))|depth=1] structs[] |" ,
1008+ "| | Projection: List([1, 2, 3, 4, 5]) AS __unnest_placeholder(make_array(Int64(1),Int64(2),Int64(3),Int64(4),Int64(5))) |" ,
1009+ "| | EmptyRelation: rows=1 |" ,
1010+ "| physical_plan | ProjectionExec: expr=[count(Int64(1))@1 as count(*), id@0 as id] |" ,
1011+ "| | AggregateExec: mode=FinalPartitioned, gby=[id@0 as id], aggr=[count(Int64(1))] |" ,
1012+ "| | CoalesceBatchesExec: target_batch_size=8192 |" ,
1013+ "| | RepartitionExec: partitioning=Hash([id@0], 16), input_partitions=1 |" ,
1014+ "| | AggregateExec: mode=Partial, gby=[id@0 as id], aggr=[count(Int64(1))] |" ,
1015+ "| | ProjectionExec: expr=[__unnest_placeholder(make_array(Int64(1),Int64(2),Int64(3),Int64(4),Int64(5)),depth=1)@0 as id] |" ,
1016+ "| | UnnestExec |" ,
1017+ "| | ProjectionExec: expr=[[1, 2, 3, 4, 5] as __unnest_placeholder(make_array(Int64(1),Int64(2),Int64(3),Int64(4),Int64(5)))] |" ,
1018+ "| | PlaceholderRowExec |" ,
1019+ "| | |" ,
1020+ "| distributed_plan | =========ResolvedStage[stage_id=1.0, partitions=1]========= |" ,
1021+ "| | ShuffleWriterExec: partitioning:Some(Hash([Column { name: \" id\" , index: 0 }], 16)) |" ,
1022+ "| | AggregateExec: mode=Partial, gby=[id@0 as id], aggr=[count(Int64(1))] |" ,
1023+ "| | ProjectionExec: expr=[__unnest_placeholder(make_array(Int64(1),Int64(2),Int64(3),Int64(4),Int64(5)),depth=1)@0 as id] |" ,
1024+ "| | UnnestExec |" ,
1025+ "| | ProjectionExec: expr=[[1, 2, 3, 4, 5] as __unnest_placeholder(make_array(Int64(1),Int64(2),Int64(3),Int64(4),Int64(5)))] |" ,
1026+ "| | PlaceholderRowExec |" ,
1027+ "| | |" ,
1028+ "| | =========UnResolvedStage[stage_id=2.0, children=1]========= |" ,
1029+ "| | Inputs{1: StageOutput { partition_locations: {}, complete: false }} |" ,
1030+ "| | ShuffleWriterExec: partitioning:None |" ,
1031+ "| | ProjectionExec: expr=[count(Int64(1))@1 as count(*), id@0 as id] |" ,
1032+ "| | AggregateExec: mode=FinalPartitioned, gby=[id@0 as id], aggr=[count(Int64(1))] |" ,
1033+ "| | CoalesceBatchesExec: target_batch_size=8192 |" ,
1034+ "| | UnresolvedShuffleExec: partitioning=Hash([Column { name: \" id\" , index: 0 }], 16) |" ,
1035+ "| | |" ,
1036+ "| | |" ,
1037+ "+------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+" ,
1038+ ] ;
1039+ assert_batches_eq ! ( expected, & result) ;
1040+ }
9821041}
0 commit comments