Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sundy-li committed Sep 6, 2024
1 parent 6cfdd19 commit 45b413b
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/query/sql/src/executor/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,10 @@ fn constant_table_scan_to_format_tree(
plan: &ConstantTableScan,
metadata: &Metadata,
) -> Result<FormatTreeNode<String>> {
if plan.num_rows == 0 {
return Ok(FormatTreeNode::new(plan.name().to_string()));
}

let mut children = Vec::with_capacity(plan.values.len() + 1);
children.push(FormatTreeNode::new(format!(
"output columns: [{}]",
Expand All @@ -850,7 +854,7 @@ fn constant_table_scan_to_format_tree(
children.push(FormatTreeNode::new(format!("column {}: [{}]", i, column)));
}
Ok(FormatTreeNode::with_children(
"ConstantTableScan".to_string(),
plan.name().to_string(),
children,
))
}
Expand Down
2 changes: 1 addition & 1 deletion src/query/sql/src/executor/physical_plan_display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ impl Display for ConstantTableScan {
})
.collect::<Vec<String>>();

write!(f, "ConstantTableScan: {}", columns.join(", "))
write!(f, "{}: {}", self.name(), columns.join(", "))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ impl ConstantTableScan {
pub fn output_schema(&self) -> Result<DataSchemaRef> {
Ok(self.output_schema.clone())
}

pub fn name(&self) -> &str {
if self.num_rows == 0 {
"EmptyResultScan"
} else {
"ConstantTableScan"
}
}
}

impl PhysicalPlanBuilder {
Expand Down
2 changes: 1 addition & 1 deletion src/query/sql/src/planner/optimizer/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub fn display_rel_op(rel_op: &RelOperator) -> String {
RelOperator::Window(_) => "WindowFunc".to_string(),
RelOperator::CteScan(_) => "CteScan".to_string(),
RelOperator::MaterializedCte(_) => "MaterializedCte".to_string(),
RelOperator::ConstantTableScan(_) => "ConstantTableScan".to_string(),
RelOperator::ConstantTableScan(s) => s.name().to_string(),
RelOperator::ExpressionScan(_) => "ExpressionScan".to_string(),
RelOperator::CacheScan(_) => "CacheScan".to_string(),
RelOperator::Udf(_) => "Udf".to_string(),
Expand Down
8 changes: 8 additions & 0 deletions src/query/sql/src/planner/plans/constant_table_scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ impl ConstantTableScan {
pub fn used_columns(&self) -> Result<ColumnSet> {
Ok(self.columns.clone())
}

pub fn name(&self) -> &str {
if self.num_rows == 0 {
"EmptyResultScan"
} else {
"ConstantTableScan"
}
}
}

impl PartialEq for ConstantTableScan {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ create table t2(a int, b int);
query T
explain select * from t1 where a = 1 and a = 2;
----
ConstantTableScan
├── output columns: [t1.a (#0), t1.b (#1)]
├── column 0: []
└── column 1: []
EmptyResultScan

query T
explain select * from t1 where (a = 1 and b > 2) or (a = 1 and b < 100) or (a = 1 and b > 2) or (a = 1 and b < 100);
Expand Down

0 comments on commit 45b413b

Please sign in to comment.