@@ -1196,130 +1196,3 @@ physical_plan
1196119602)--RepartitionExec: partitioning=RoundRobinBatch(2), input_partitions=1
1197119703)----SortExec: TopK(fetch=1), expr=[a@0 ASC NULLS LAST], preserve_partitioning=[false]
1198119804)------CsvExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/core/tests/data/window_2.csv]]}, projection=[a, b], has_header=true
1199-
1200-
1201- ####################
1202- # Test issue: TBD
1203- ####################
1204-
1205- # all results
1206- query II
1207- SELECT b, sum(a) FROM ordered_table GROUP BY b order by b desc;
1208- ----
1209- 3 25
1210- 2 25
1211- 1 0
1212- 0 0
1213-
1214- # limit only
1215- query II
1216- SELECT b, sum(a) FROM ordered_table GROUP BY b order by b desc LIMIT 3;
1217- ----
1218- 3 25
1219- 2 25
1220- 1 0
1221-
1222- # offset only
1223- query II
1224- SELECT b, sum(a) FROM ordered_table GROUP BY b order by b desc OFFSET 1;
1225- ----
1226- 2 25
1227- 1 0
1228- 0 0
1229-
1230- # offset + limit
1231- query II
1232- SELECT b, sum(a) FROM ordered_table GROUP BY b order by b desc OFFSET 1 LIMIT 2;
1233- ----
1234- 2 25
1235- 1 0
1236-
1237- # Applying offset & limit when multiple streams from groupby
1238- query TT
1239- EXPLAIN SELECT b, sum(a) FROM ordered_table GROUP BY b order by b desc OFFSET 1 LIMIT 2;
1240- ----
1241- logical_plan
1242- 01)Limit: skip=1, fetch=2
1243- 02)--Sort: ordered_table.b DESC NULLS FIRST, fetch=3
1244- 03)----Aggregate: groupBy=[[ordered_table.b]], aggr=[[sum(CAST(ordered_table.a AS Int64))]]
1245- 04)------TableScan: ordered_table projection=[a, b]
1246- physical_plan
1247- 01)GlobalLimitExec: skip=1, fetch=2
1248- 02)--SortPreservingMergeExec: [b@0 DESC], fetch=3
1249- 03)----SortExec: TopK(fetch=3), expr=[b@0 DESC], preserve_partitioning=[true]
1250- 04)------AggregateExec: mode=FinalPartitioned, gby=[b@0 as b], aggr=[sum(ordered_table.a)]
1251- 05)--------CoalesceBatchesExec: target_batch_size=8192
1252- 06)----------RepartitionExec: partitioning=Hash([b@0], 2), input_partitions=2
1253- 07)------------AggregateExec: mode=Partial, gby=[b@1 as b], aggr=[sum(ordered_table.a)]
1254- 08)--------------RepartitionExec: partitioning=RoundRobinBatch(2), input_partitions=1
1255- 09)----------------CsvExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/core/tests/data/window_2.csv]]}, projection=[a, b], has_header=true
1256-
1257- # Applying offset & limit when multiple streams from union
1258- query TT
1259- explain select * FROM (
1260- select c FROM ordered_table
1261- UNION ALL
1262- select d FROM ordered_table
1263- ) order by 1 desc LIMIT 10 OFFSET 4;
1264- ----
1265- logical_plan
1266- 01)Limit: skip=4, fetch=10
1267- 02)--Sort: ordered_table.c DESC NULLS FIRST, fetch=14
1268- 03)----Union
1269- 04)------Projection: CAST(ordered_table.c AS Int64) AS c
1270- 05)--------TableScan: ordered_table projection=[c]
1271- 06)------Projection: CAST(ordered_table.d AS Int64) AS c
1272- 07)--------TableScan: ordered_table projection=[d]
1273- physical_plan
1274- 01)GlobalLimitExec: skip=4, fetch=10
1275- 02)--SortPreservingMergeExec: [c@0 DESC], fetch=14
1276- 03)----UnionExec
1277- 04)------SortExec: TopK(fetch=14), expr=[c@0 DESC], preserve_partitioning=[true]
1278- 05)--------ProjectionExec: expr=[CAST(c@0 AS Int64) as c]
1279- 06)----------RepartitionExec: partitioning=RoundRobinBatch(2), input_partitions=1
1280- 07)------------CsvExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/core/tests/data/window_2.csv]]}, projection=[c], output_ordering=[c@0 ASC NULLS LAST], has_header=true
1281- 08)------SortExec: TopK(fetch=14), expr=[c@0 DESC], preserve_partitioning=[true]
1282- 09)--------ProjectionExec: expr=[CAST(d@0 AS Int64) as c]
1283- 10)----------RepartitionExec: partitioning=RoundRobinBatch(2), input_partitions=1
1284- 11)------------CsvExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/core/tests/data/window_2.csv]]}, projection=[d], has_header=true
1285-
1286- # ApplyingmLIMIT & OFFSET to subquery.
1287- query III
1288- select t1.b, c, c2 FROM (
1289- select b, c FROM ordered_table ORDER BY b desc, c desc OFFSET 1 LIMIT 4
1290- ) as t1 INNER JOIN (
1291- select b, c as c2 FROM ordered_table ORDER BY b desc, d desc OFFSET 1 LIMIT 4
1292- ) as t2
1293- ON t1.b = t2.b
1294- ORDER BY t1.b desc, c desc, c2 desc;
1295- ----
1296- 3 98 96
1297- 3 98 89
1298- 3 98 82
1299- 3 98 79
1300- 3 97 96
1301- 3 97 89
1302- 3 97 82
1303- 3 97 79
1304- 3 96 96
1305- 3 96 89
1306- 3 96 82
1307- 3 96 79
1308- 3 95 96
1309- 3 95 89
1310- 3 95 82
1311- 3 95 79
1312-
1313- # Apply OFFSET & LIMIT to both parent and child (subquery).
1314- query III
1315- select t1.b, c, c2 FROM (
1316- select b, c FROM ordered_table ORDER BY b desc, c desc OFFSET 1 LIMIT 4
1317- ) as t1 INNER JOIN (
1318- select b, c as c2 FROM ordered_table ORDER BY b desc, d desc OFFSET 1 LIMIT 4
1319- ) as t2
1320- ON t1.b = t2.b
1321- ORDER BY t1.b desc, c desc, c2 desc
1322- OFFSET 3 LIMIT 2;
1323- ----
1324- 3 99 82
1325- 3 99 79
0 commit comments