Skip to content

Commit 767643a

Browse files
committed
chore(explain): Reduce redundant output
Signed-off-by: Alan Tang <[email protected]>
1 parent 249882f commit 767643a

File tree

2 files changed

+18
-32
lines changed

2 files changed

+18
-32
lines changed

datafusion/physical-plan/src/projection.rs

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -150,38 +150,24 @@ impl DisplayAs for ProjectionExec {
150150
t: DisplayFormatType,
151151
f: &mut std::fmt::Formatter,
152152
) -> std::fmt::Result {
153+
let expr: Vec<String> = self
154+
.expr
155+
.iter()
156+
.map(|(e, alias)| {
157+
let e = e.to_string();
158+
if &e != alias {
159+
format!("{e} as {alias}")
160+
} else {
161+
e
162+
}
163+
})
164+
.collect();
153165
match t {
154166
DisplayFormatType::Default | DisplayFormatType::Verbose => {
155-
let expr: Vec<String> = self
156-
.expr
157-
.iter()
158-
.map(|(e, alias)| {
159-
let e = e.to_string();
160-
if &e != alias {
161-
format!("{e} as {alias}")
162-
} else {
163-
e
164-
}
165-
})
166-
.collect();
167-
168167
write!(f, "ProjectionExec: expr=[{}]", expr.join(", "))
169168
}
170169
DisplayFormatType::TreeRender => {
171-
// TODO: collect info
172-
let expr: Vec<String> = self
173-
.expr
174-
.iter()
175-
.map(|(e, alias)| {
176-
let e = e.to_string();
177-
if &e != alias {
178-
format!("{e} as {alias}")
179-
} else {
180-
e
181-
}
182-
})
183-
.collect();
184-
write!(f, "ProjectionExec: expr=[{}]", expr.join(", "))
170+
write!(f, "expr=[{}]", expr.join(", "))
185171
}
186172
}
187173
}

datafusion/sqllogictest/test_files/explain_tree.slt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ physical_plan
531531
01)┌───────────────────────────┐
532532
02)│ ProjectionExec │
533533
03)│ -------------------- │
534-
04)│ ProjectionExec: expr: │
534+
04)│ expr:
535535
05)│ [int_col@0 as int_col, │
536536
06)│ bigint_col@1 as │
537537
07)│ bigint_col, CAST │
@@ -560,7 +560,7 @@ physical_plan
560560
01)┌───────────────────────────┐
561561
02)│ ProjectionExec │
562562
03)│ -------------------- │
563-
04)│ ProjectionExec: expr: │
563+
04)│ expr:
564564
05)│ [int_col@0 as int_col, │
565565
06)│ bigint_col@1 as │
566566
07)│ bigint_col, CAST │
@@ -589,7 +589,7 @@ physical_plan
589589
01)┌───────────────────────────┐
590590
02)│ ProjectionExec │
591591
03)│ -------------------- │
592-
04)│ ProjectionExec: expr: │
592+
04)│ expr:
593593
05)│ [int_col@0 as int_col, │
594594
06)│ bigint_col@1 as │
595595
07)│ bigint_col, CAST │
@@ -617,7 +617,7 @@ physical_plan
617617
01)┌───────────────────────────┐
618618
02)│ ProjectionExec │
619619
03)│ -------------------- │
620-
04)│ ProjectionExec: expr: │
620+
04)│ expr:
621621
05)│ [int_col@1 as int_col, │
622622
06)│ bigint_col@0 as │
623623
07)│ bigint_col, int_col │
@@ -646,7 +646,7 @@ physical_plan
646646
01)┌───────────────────────────┐
647647
02)│ ProjectionExec │
648648
03)│ -------------------- │
649-
04)│ ProjectionExec: expr: │
649+
04)│ expr:
650650
05)│ [int_col@0 as int_col, │
651651
06)│ bigint_col@1 as │
652652
07)│ bigint_col, CAST │

0 commit comments

Comments
 (0)