Skip to content

Commit 17750ef

Browse files
committed
feat: implement tree rendering for SortPreservingMergeExec
Signed-off-by: Alan Tang <[email protected]>
1 parent 2455aab commit 17750ef

File tree

2 files changed

+33
-26
lines changed

2 files changed

+33
-26
lines changed

datafusion/physical-plan/src/sorts/sort_preserving_merge.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,15 @@ impl DisplayAs for SortPreservingMergeExec {
186186
Ok(())
187187
}
188188
DisplayFormatType::TreeRender => {
189-
// TODO: collect info
190-
write!(f, "")
189+
for (i, e) in self.expr().iter().enumerate() {
190+
let e = e.to_string();
191+
writeln!(f, "expr{i}={e}")?;
192+
}
193+
if let Some(fetch) = self.fetch {
194+
writeln!(f, "fetch={fetch}")?;
195+
};
196+
197+
Ok(())
191198
}
192199
}
193200
}

datafusion/sqllogictest/test_files/explain_tree.slt

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,15 +1353,15 @@ ORDER BY "date", "time";
13531353
physical_plan
13541354
01)┌───────────────────────────┐
13551355
02)│ SortPreservingMergeExec │
1356-
03)└─────────────┬─────────────┘
1357-
04)┌─────────────┴─────────────┐
1358-
05)│ CoalesceBatchesExec
1359-
06)└─────────────┬─────────────┘
1360-
07)┌─────────────┴─────────────┐
1361-
08)│ FilterExec
1362-
09)│ -------------------- │
1363-
10)│ predicate: │
1364-
11)│ ticker@1 = A
1356+
03)│ -------------------- │
1357+
04)│ expr0: │
1358+
05)│ date@0 ASC NULLS LAST
1359+
06)│ │
1360+
07)│ expr1: │
1361+
08)│ time@2 ASC NULLS LAST
1362+
09)└─────────────┬─────────────┘
1363+
10)┌─────────────┴─────────────┐
1364+
11)│ CoalesceBatchesExec
13651365
12)└─────────────┬─────────────┘
13661366
13)┌─────────────┴─────────────┐
13671367
14)│ RepartitionExec │
@@ -1389,9 +1389,9 @@ ORDER BY "time"
13891389
physical_plan
13901390
01)┌───────────────────────────┐
13911391
02)│ SortPreservingMergeExec │
1392-
03)└─────────────┬─────────────┘
1393-
04)┌─────────────┴─────────────┐
1394-
05)│ CoalesceBatchesExec
1392+
03)│ -------------------- │
1393+
04)│ expr0: │
1394+
05)│ time@2 ASC NULLS LAST
13951395
06)└─────────────┬─────────────┘
13961396
07)┌─────────────┴─────────────┐
13971397
08)│ FilterExec │
@@ -1425,9 +1425,9 @@ ORDER BY "date"
14251425
physical_plan
14261426
01)┌───────────────────────────┐
14271427
02)│ SortPreservingMergeExec │
1428-
03)└─────────────┬─────────────┘
1429-
04)┌─────────────┴─────────────┐
1430-
05)│ CoalesceBatchesExec
1428+
03)│ -------------------- │
1429+
04)│ expr0: │
1430+
05)│ date@0 ASC NULLS LAST
14311431
06)└─────────────┬─────────────┘
14321432
07)┌─────────────┴─────────────┐
14331433
08)│ FilterExec │
@@ -1537,15 +1537,15 @@ ORDER BY "ticker", "time";
15371537
physical_plan
15381538
01)┌───────────────────────────┐
15391539
02)│ SortPreservingMergeExec │
1540-
03)└─────────────┬─────────────┘
1541-
04)┌─────────────┴─────────────┐
1542-
05)│ CoalesceBatchesExec
1543-
06)└─────────────┬─────────────┘
1544-
07)┌─────────────┴─────────────┐
1545-
08)│ FilterExec
1546-
09)│ -------------------- │
1547-
10)│ predicate: │
1548-
11)│ date@0 = 2006-01-02
1540+
03)│ -------------------- │
1541+
04)│ expr0: │
1542+
05)│ ticker@1 ASC NULLS LAST
1543+
06)│ │
1544+
07)│ expr1: │
1545+
08)│ time@2 ASC NULLS LAST
1546+
09)└─────────────┬─────────────┘
1547+
10)┌─────────────┴─────────────┐
1548+
11)│ CoalesceBatchesExec
15491549
12)└─────────────┬─────────────┘
15501550
13)┌─────────────┴─────────────┐
15511551
14)│ RepartitionExec │

0 commit comments

Comments
 (0)