Skip to content

Commit

Permalink
feat: display logical plan after heuristic (#141)
Browse files Browse the repository at this point in the history
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 <yuchenl3@andrew.cmu.edu>
  • Loading branch information
yliang412 authored Mar 27, 2024
1 parent 4a8da7e commit bd40a10
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions optd-datafusion-bridge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,16 @@ impl OptdQueryPlanner {

if optimizer.is_heuristic_enabled() {
optd_rel = optimizer.heuristic_optimize(optd_rel);
if let Some(explains) = &mut explains {
explains.push(StringifiedPlan::new(
PlanType::OptimizedLogicalPlan {
optimizer_name: "optd-heuristic".to_string(),
},
PlanNode::from_rel_node(optd_rel.clone())
.unwrap()
.explain_to_string(None),
))
}
}

let (group_id, optimized_rel, meta) = optimizer.cascades_optimize(optd_rel)?;
Expand Down
10 changes: 10 additions & 0 deletions optd-sqlplannertest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,16 @@ impl DatafusionDBMS {
.map(|x| &x[1])
.unwrap()
)?;
} else if subtask == "logical_optd_heuristic" {
writeln!(
r,
"{}",
result
.iter()
.find(|x| x[0] == "logical_plan after optd-heuristic")
.map(|x| &x[1])
.unwrap()
)?;
} else if subtask == "logical_optd" {
writeln!(
r,
Expand Down

0 comments on commit bd40a10

Please sign in to comment.