Skip to content

Commit

Permalink
Show labels only if requested
Browse files Browse the repository at this point in the history
  • Loading branch information
mamcx committed Dec 24, 2024
1 parent 81adebc commit 1ca3567
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
30 changes: 15 additions & 15 deletions crates/physical-plan/src/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1954,7 +1954,7 @@ mod tests {
"SELECT * FROM p",
expect![
r#"
Seq Scan on p:1
Seq Scan on p
Output: id, name"#
],
);
Expand All @@ -1968,7 +1968,7 @@ mod tests {
"SELECT * FROM p as b",
expect![
r#"
Seq Scan on p:1
Seq Scan on p
Output: id, name"#
],
);
Expand All @@ -1994,7 +1994,7 @@ mod tests {
"SELECT id FROM p",
expect![
r#"
Seq Scan on p:1
Seq Scan on p
Output: p.id"#
],
);
Expand All @@ -2005,8 +2005,8 @@ mod tests {
expect![
r#"
Nested Loop
-> Seq Scan on m:1
-> Seq Scan on p:2
-> Seq Scan on m
-> Seq Scan on p
Output: p.id, m.employee"#
],
);
Expand All @@ -2020,7 +2020,7 @@ mod tests {
&db,
"SELECT * FROM p WHERE id = 1",
expect![[r#"
Seq Scan on p:1
Seq Scan on p
Filter: (p.id = U64(1))
Output: id, name"#]],
);
Expand All @@ -2029,9 +2029,9 @@ mod tests {
&db,
"SELECT * FROM p WHERE id = 1 AND id =2 OR name = 'jhon'",
expect![[r#"
Seq Scan on p:1
Filter: (p.id = U64(1) AND p.id = U64(2) OR p.name = String("jhon"))
Output: id, name"#]],
Seq Scan on p
Filter: (p.id = U64(1) AND p.id = U64(2) OR p.name = String("jhon"))
Output: id, name"#]],
);
}

Expand All @@ -2043,7 +2043,7 @@ mod tests {
&db,
"SELECT m.* FROM m WHERE employee = 1",
expect![[r#"
Index Scan using Index id 0: (employee) on m:1
Index Scan using Index id 0: (employee) on m
Index Cond: (m.employee = U64(1))
Output: employee, manager"#]],
);
Expand All @@ -2058,8 +2058,8 @@ mod tests {
"SELECT p.* FROM m JOIN p",
expect![[r#"
Nested Loop
-> Seq Scan on m:1
-> Seq Scan on p:2
-> Seq Scan on m
-> Seq Scan on p
Output: id, name"#]],
);
}
Expand All @@ -2073,8 +2073,8 @@ mod tests {
"SELECT p.* FROM m JOIN p ON m.employee = p.id where m.employee = 1",
expect![[r#"
Hash Join: All
-> Seq Scan on m:1
-> Seq Scan on p:2
-> Seq Scan on m
-> Seq Scan on p
Inner Unique: false
Hash Cond: (m.employee = p.id)
Filter: (m.employee = U64(1))
Expand All @@ -2091,7 +2091,7 @@ mod tests {
"SELECT p.* FROM m JOIN p ON m.employee = p.id",
expect![[r#"
Index Join: Rhs
-> Seq Scan on m:1
-> Seq Scan on m
Inner Unique: true
Index Cond: (m.employee = p.id)
Output: employee, manager"#]],
Expand Down
15 changes: 12 additions & 3 deletions crates/physical-plan/src/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,15 +420,23 @@ impl<'a> fmt::Display for Explain<'a> {
write!(f, "{:ident$}{arrow}", "")?;
match line {
Line::TableScan { table, label, ident: _ } => {
write!(f, "Seq Scan on {}:{}", table, label.0)?;
if self.show_schema {
write!(f, "Seq Scan on {}:{}", table, label.0)?;
} else {
write!(f, "Seq Scan on {}", table)?;
}
}
Line::IxScan {
table_name,
index,
label,
ident: _,
} => {
write!(f, "Index Scan using {index} on {table_name}:{}", label.0)?;
if self.show_schema {
write!(f, "Index Scan using {index} on {table_name}:{}", label.0)?;
} else {
write!(f, "Index Scan using {index} on {table_name}")?;
}
}
Line::Filter { expr, ident: _ } => {
write!(
Expand Down Expand Up @@ -503,7 +511,8 @@ impl<'a> fmt::Display for Explain<'a> {
}

if self.show_timings {
write!(f, "Planning Time: {:?}", ctx.planning_time)?;
let end = if self.show_schema { "\n" } else { "" };
write!(f, "Planning Time: {:?}{end}", ctx.planning_time)?;
}

if self.show_schema {
Expand Down

0 comments on commit 1ca3567

Please sign in to comment.