Skip to content

Commit d22a586

Browse files
authored
Implement tree explain for InterleaveExec (#15219)
1 parent 9fd7e6f commit d22a586

File tree

2 files changed

+112
-4
lines changed

2 files changed

+112
-4
lines changed

datafusion/physical-plan/src/union.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,7 @@ impl DisplayAs for InterleaveExec {
391391
DisplayFormatType::Default | DisplayFormatType::Verbose => {
392392
write!(f, "InterleaveExec")
393393
}
394-
DisplayFormatType::TreeRender => {
395-
// TODO: collect info
396-
write!(f, "")
397-
}
394+
DisplayFormatType::TreeRender => Ok(()),
398395
}
399396
}
400397
}

datafusion/sqllogictest/test_files/explain_tree.slt

+111
Original file line numberDiff line numberDiff line change
@@ -1394,6 +1394,117 @@ drop table table4;
13941394
statement ok
13951395
drop table table5;
13961396

1397+
# Create table for InterleaveExec
1398+
statement ok
1399+
CREATE TABLE t1(
1400+
id INT,
1401+
name TEXT
1402+
) as VALUES
1403+
(1, 'Alex'),
1404+
(2, 'Bob'),
1405+
(3, 'Alice')
1406+
;
1407+
1408+
statement ok
1409+
CREATE TABLE t2(
1410+
id TINYINT,
1411+
name TEXT
1412+
) as VALUES
1413+
(1, 'Alex'),
1414+
(2, 'Bob'),
1415+
(3, 'John')
1416+
;
1417+
1418+
# Test explain tree for InterleaveExec
1419+
query TT
1420+
EXPLAIN
1421+
SELECT count(*) FROM (
1422+
SELECT distinct name FROM t1
1423+
UNION ALL
1424+
SELECT distinct name FROM t2
1425+
) GROUP BY name
1426+
----
1427+
physical_plan
1428+
01)┌───────────────────────────┐
1429+
02)│ ProjectionExec │
1430+
03)│ -------------------- │
1431+
04)│ count(*): │
1432+
05)│ count(Int64(1))@1 │
1433+
06)└─────────────┬─────────────┘
1434+
07)┌─────────────┴─────────────┐
1435+
08)│ AggregateExec │
1436+
09)│ -------------------- │
1437+
10)│ aggr: count(Int64(1)) │
1438+
11)│ │
1439+
12)│ group_by: │
1440+
13)│ name@0 as name │
1441+
14)│ │
1442+
15)│ mode: │
1443+
16)│ SinglePartitioned │
1444+
17)└─────────────┬─────────────┘
1445+
18)┌─────────────┴─────────────┐
1446+
19)│ InterleaveExec ├──────────────┐
1447+
20)└─────────────┬─────────────┘ │
1448+
21)┌─────────────┴─────────────┐┌─────────────┴─────────────┐
1449+
22)│ AggregateExec ││ AggregateExec │
1450+
23)│ -------------------- ││ -------------------- │
1451+
24)│ aggr ││ aggr │
1452+
25)│ ││ │
1453+
26)│ group_by: ││ group_by: │
1454+
27)│ name@0 as name ││ name@0 as name │
1455+
28)│ ││ │
1456+
29)│ mode: ││ mode: │
1457+
30)│ FinalPartitioned ││ FinalPartitioned │
1458+
31)└─────────────┬─────────────┘└─────────────┬─────────────┘
1459+
32)┌─────────────┴─────────────┐┌─────────────┴─────────────┐
1460+
33)│ CoalesceBatchesExec ││ CoalesceBatchesExec │
1461+
34)│ -------------------- ││ -------------------- │
1462+
35)│ target_batch_size: ││ target_batch_size: │
1463+
36)│ 8192 ││ 8192 │
1464+
37)└─────────────┬─────────────┘└─────────────┬─────────────┘
1465+
38)┌─────────────┴─────────────┐┌─────────────┴─────────────┐
1466+
39)│ RepartitionExec ││ RepartitionExec │
1467+
40)│ -------------------- ││ -------------------- │
1468+
41)│ output_partition_count: ││ output_partition_count: │
1469+
42)│ 4 ││ 4 │
1470+
43)│ ││ │
1471+
44)│ partitioning_scheme: ││ partitioning_scheme: │
1472+
45)│ Hash([name@0], 4) ││ Hash([name@0], 4) │
1473+
46)└─────────────┬─────────────┘└─────────────┬─────────────┘
1474+
47)┌─────────────┴─────────────┐┌─────────────┴─────────────┐
1475+
48)│ RepartitionExec ││ RepartitionExec │
1476+
49)│ -------------------- ││ -------------------- │
1477+
50)│ output_partition_count: ││ output_partition_count: │
1478+
51)│ 1 ││ 1 │
1479+
52)│ ││ │
1480+
53)│ partitioning_scheme: ││ partitioning_scheme: │
1481+
54)│ RoundRobinBatch(4) ││ RoundRobinBatch(4) │
1482+
55)└─────────────┬─────────────┘└─────────────┬─────────────┘
1483+
56)┌─────────────┴─────────────┐┌─────────────┴─────────────┐
1484+
57)│ AggregateExec ││ AggregateExec │
1485+
58)│ -------------------- ││ -------------------- │
1486+
59)│ aggr ││ aggr │
1487+
60)│ ││ │
1488+
61)│ group_by: ││ group_by: │
1489+
62)│ name@0 as name ││ name@0 as name │
1490+
63)│ ││ │
1491+
64)│ mode: Partial ││ mode: Partial │
1492+
65)└─────────────┬─────────────┘└─────────────┬─────────────┘
1493+
66)┌─────────────┴─────────────┐┌─────────────┴─────────────┐
1494+
67)│ DataSourceExec ││ DataSourceExec │
1495+
68)│ -------------------- ││ -------------------- │
1496+
69)│ bytes: 1320 ││ bytes: 1312 │
1497+
70)│ format: memory ││ format: memory │
1498+
71)│ rows: 1 ││ rows: 1 │
1499+
72)└───────────────────────────┘└───────────────────────────┘
1500+
1501+
# cleanup
1502+
statement ok
1503+
drop table t1;
1504+
1505+
statement ok
1506+
drop table t2;
1507+
13971508
# Test on StreamingTableExec
13981509
# prepare table
13991510
statement ok

0 commit comments

Comments
 (0)