Skip to content

Commit

Permalink
feature(explain): add a simple explain join to display the join orders
Browse files Browse the repository at this point in the history
  • Loading branch information
sundy-li committed Mar 22, 2023
1 parent 025cac0 commit 051ca96
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/query/service/src/interpreters/interpreter_explain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,7 @@ impl ExplainInterpreter {
plan: &PhysicalPlan,
metadata: &MetadataRef,
) -> Result<Vec<DataBlock>> {
let prof = ProfSpanSetRef::default();
let result = plan.format_join(metadata, &prof)?.format_pretty()?;
let result = plan.format_join(metadata)?.format_pretty()?;
let line_split_result: Vec<&str> = result.lines().collect();
let formatted_plan = StringType::from_data(line_split_result);
Ok(vec![DataBlock::new_from_columns(vec![formatted_plan])])
Expand Down
12 changes: 4 additions & 8 deletions src/query/sql/src/executor/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ impl PhysicalPlan {
to_format_tree(self, &metadata, &prof_span_set)
}

pub fn format_join(
&self,
metadata: &MetadataRef,
prof_span_set: &ProfSpanSetRef,
) -> Result<FormatTreeNode<String>> {
pub fn format_join(&self, metadata: &MetadataRef) -> Result<FormatTreeNode<String>> {
match self {
PhysicalPlan::TableScan(plan) => {
if plan.table_index == DUMMY_TABLE_INDEX {
Expand All @@ -82,8 +78,8 @@ impl PhysicalPlan {
))
}
PhysicalPlan::HashJoin(plan) => {
let build_child = plan.build.format_join(metadata, prof_span_set)?;
let probe_child = plan.probe.format_join(metadata, prof_span_set)?;
let build_child = plan.build.format_join(metadata)?;
let probe_child = plan.probe.format_join(metadata)?;

let children = vec![
FormatTreeNode::with_children("Build".to_string(), vec![build_child]),
Expand All @@ -98,7 +94,7 @@ impl PhysicalPlan {
other => {
let children = other
.children()
.map(|child| child.format_join(metadata, prof_span_set))
.map(|child| child.format_join(metadata))
.collect::<Result<Vec<FormatTreeNode<String>>>>()?;

if children.len() == 1 {
Expand Down

0 comments on commit 051ca96

Please sign in to comment.