Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.

Commit bd40a10

Browse files
authored
feat: display logical plan after heuristic (#141)
It might be helpful to see what the plan looks like after the heuristics phase. It might help us to identify things that are not handled in the system and help us make design decisions forward on implementing rules. Signed-off-by: Yuchen Liang <[email protected]>
1 parent 4a8da7e commit bd40a10

File tree

2 files changed

+20
-0
lines changed
  • optd-datafusion-bridge/src
  • optd-sqlplannertest/src

2 files changed

+20
-0
lines changed

optd-datafusion-bridge/src/lib.rs

+10
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,16 @@ impl OptdQueryPlanner {
233233

234234
if optimizer.is_heuristic_enabled() {
235235
optd_rel = optimizer.heuristic_optimize(optd_rel);
236+
if let Some(explains) = &mut explains {
237+
explains.push(StringifiedPlan::new(
238+
PlanType::OptimizedLogicalPlan {
239+
optimizer_name: "optd-heuristic".to_string(),
240+
},
241+
PlanNode::from_rel_node(optd_rel.clone())
242+
.unwrap()
243+
.explain_to_string(None),
244+
))
245+
}
236246
}
237247

238248
let (group_id, optimized_rel, meta) = optimizer.cascades_optimize(optd_rel)?;

optd-sqlplannertest/src/lib.rs

+10
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,16 @@ impl DatafusionDBMS {
163163
.map(|x| &x[1])
164164
.unwrap()
165165
)?;
166+
} else if subtask == "logical_optd_heuristic" {
167+
writeln!(
168+
r,
169+
"{}",
170+
result
171+
.iter()
172+
.find(|x| x[0] == "logical_plan after optd-heuristic")
173+
.map(|x| &x[1])
174+
.unwrap()
175+
)?;
166176
} else if subtask == "logical_optd" {
167177
writeln!(
168178
r,

0 commit comments

Comments
 (0)