Skip to content

Commit

Permalink
fix compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
irenjj committed Feb 17, 2025
1 parent 6ad7a62 commit d53d876
Show file tree
Hide file tree
Showing 12 changed files with 101 additions and 5 deletions.
20 changes: 16 additions & 4 deletions datafusion-examples/examples/planner_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

use datafusion::error::Result;
use datafusion::logical_expr::{LogicalPlan, PlanType};
use datafusion::physical_plan::displayable;
use datafusion::physical_plan::{displayable, DisplayFormatType};
use datafusion::physical_planner::DefaultPhysicalPlanner;
use datafusion::prelude::*;

Expand Down Expand Up @@ -78,7 +78,11 @@ async fn to_physical_plan_in_one_api_demo(
println!(
"Physical plan direct from logical plan:\n\n{}\n\n",
displayable(physical_plan.as_ref())
.to_stringified(false, PlanType::InitialPhysicalPlan)
.to_stringified(
false,
PlanType::InitialPhysicalPlan,
DisplayFormatType::Default
)
.plan
);

Expand Down Expand Up @@ -120,7 +124,11 @@ async fn to_physical_plan_step_by_step_demo(
println!(
"Final physical plan:\n\n{}\n\n",
displayable(physical_plan.as_ref())
.to_stringified(false, PlanType::InitialPhysicalPlan)
.to_stringified(
false,
PlanType::InitialPhysicalPlan,
DisplayFormatType::Default
)
.plan
);

Expand All @@ -135,7 +143,11 @@ async fn to_physical_plan_step_by_step_demo(
println!(
"Optimized physical plan:\n\n{}\n\n",
displayable(physical_plan.as_ref())
.to_stringified(false, PlanType::InitialPhysicalPlan)
.to_stringified(
false,
PlanType::InitialPhysicalPlan,
DisplayFormatType::Default
)
.plan
);

Expand Down
3 changes: 3 additions & 0 deletions datafusion/core/src/physical_planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2721,6 +2721,9 @@ mod tests {
DisplayFormatType::Default | DisplayFormatType::Verbose => {
write!(f, "NoOpExecutionPlan")
}
DisplayFormatType::TreeRender => {
write!(f, "") // TODO(renjj): add display info
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions datafusion/core/tests/custom_sources_cases/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ impl DisplayAs for CustomExecutionPlan {
DisplayFormatType::Default | DisplayFormatType::Verbose => {
write!(f, "CustomExecutionPlan: projection={:#?}", self.projection)
}
DisplayFormatType::TreeRender => {
write!(f, "") // TODO(renjj): add display info
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ impl DisplayAs for CustomPlan {
DisplayFormatType::Default | DisplayFormatType::Verbose => {
write!(f, "CustomPlan: batch_size={}", self.batches.len(),)
}
DisplayFormatType::TreeRender => {
write!(f, "") // TODO(renjj): add display info
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions datafusion/core/tests/custom_sources_cases/statistics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ impl DisplayAs for StatisticsValidation {
self.stats.num_rows,
)
}
DisplayFormatType::TreeRender => {
write!(f, "") // TODO(renjj): add display info
}
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions datafusion/core/tests/physical_optimizer/join_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,9 @@ impl DisplayAs for UnboundedExec {
self.batch_produce.is_none(),
)
}
DisplayFormatType::TreeRender => {
write!(f, "") // TODO(renjj): add display info
}
}
}
}
Expand Down Expand Up @@ -1020,6 +1023,9 @@ impl DisplayAs for StatisticsExec {
self.stats.num_rows,
)
}
DisplayFormatType::TreeRender => {
write!(f, "") // TODO(renjj): add display info
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions datafusion/core/tests/user_defined/user_defined_plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,9 @@ impl DisplayAs for TopKExec {
DisplayFormatType::Default | DisplayFormatType::Verbose => {
write!(f, "TopKExec: k={}", self.k)
}
DisplayFormatType::TreeRender => {
write!(f, "") // TODO(renjj): add display info
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions datafusion/physical-plan/src/aggregates/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1800,6 +1800,9 @@ mod tests {
DisplayFormatType::Default | DisplayFormatType::Verbose => {
write!(f, "TestYieldingExec")
}
DisplayFormatType::TreeRender => {
write!(f, "") // TODO(renjj): add display info
}
}
}
}
Expand Down
38 changes: 37 additions & 1 deletion datafusion/physical-plan/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,15 @@ impl<'a> DisplayableExecutionPlan<'a> {
}
impl fmt::Display for Wrapper<'_> {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
let mut visitor = IndentVisitor {
let mut visitor = TreeRenderVisitor {
t: self.format_type,
f,
indent: 0,
show_metrics: self.show_metrics,
show_statistics: self.show_statistics,
show_schema: self.show_schema,
height: 0,
weight: 0,
};
accept(self.plan, &mut visitor)
}
Expand Down Expand Up @@ -509,6 +511,40 @@ impl ExecutionPlanVisitor for GraphvizVisitor<'_, '_> {
}
}

struct TreeRenderVisitor<'a, 'b> {
/// How to format each node
t: DisplayFormatType,
/// Write to this formatter
f: &'a mut Formatter<'b>,
/// Indent size
indent: usize,
/// How to show metrics
show_metrics: ShowMetrics,
/// If statistics should be displayed
show_statistics: bool,
/// If schema should be displayed
show_schema: bool,
height: usize,
weight: usize,
}

impl ExecutionPlanVisitor for TreeRenderVisitor<'_, '_> {
type Error = fmt::Error;

fn pre_visit(&mut self, plan: &dyn ExecutionPlan) -> Result<bool, Self::Error> {

self.height += 1;
self.weight += 1;
todo!()
}

fn post_visit(&mut self, _plan: &dyn ExecutionPlan) -> Result<bool, Self::Error> {

self.weight -= 1;
Ok(true)
}
}

/// Trait for types which could have additional details when formatted in `Verbose` mode
pub trait DisplayAs {
/// Format according to `DisplayFormatType`, used when verbose representation looks
Expand Down
3 changes: 3 additions & 0 deletions datafusion/physical-plan/src/sorts/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1102,6 +1102,9 @@ mod tests {
DisplayFormatType::Default | DisplayFormatType::Verbose => {
write!(f, "UnboundableExec",).unwrap()
}
DisplayFormatType::TreeRender => {
write!(f, "").unwrap() // TODO(renjj): add display info
}
}
Ok(())
}
Expand Down
3 changes: 3 additions & 0 deletions datafusion/physical-plan/src/sorts/sort_preserving_merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1389,6 +1389,9 @@ mod tests {
DisplayFormatType::Default | DisplayFormatType::Verbose => {
write!(f, "CongestedExec",).unwrap()
}
DisplayFormatType::TreeRender => {
write!(f, "").unwrap() // TODO(renjj): add display info
}
}
Ok(())
}
Expand Down
18 changes: 18 additions & 0 deletions datafusion/physical-plan/src/test/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ impl DisplayAs for MockExec {
DisplayFormatType::Default | DisplayFormatType::Verbose => {
write!(f, "MockExec")
}
DisplayFormatType::TreeRender => {
write!(f, "") // TODO(renjj): add display info
}
}
}
}
Expand Down Expand Up @@ -337,6 +340,9 @@ impl DisplayAs for BarrierExec {
DisplayFormatType::Default | DisplayFormatType::Verbose => {
write!(f, "BarrierExec")
}
DisplayFormatType::TreeRender => {
write!(f, "") // TODO(renjj): add display info
}
}
}
}
Expand Down Expand Up @@ -449,6 +455,9 @@ impl DisplayAs for ErrorExec {
DisplayFormatType::Default | DisplayFormatType::Verbose => {
write!(f, "ErrorExec")
}
DisplayFormatType::TreeRender => {
write!(f, "") // TODO(renjj): add display info
}
}
}
}
Expand Down Expand Up @@ -535,6 +544,9 @@ impl DisplayAs for StatisticsExec {
self.stats.num_rows,
)
}
DisplayFormatType::TreeRender => {
write!(f, "") // TODO(renjj): add display info
}
}
}
}
Expand Down Expand Up @@ -630,6 +642,9 @@ impl DisplayAs for BlockingExec {
DisplayFormatType::Default | DisplayFormatType::Verbose => {
write!(f, "BlockingExec",)
}
DisplayFormatType::TreeRender => {
write!(f, "") // TODO(renjj): add display info
}
}
}
}
Expand Down Expand Up @@ -772,6 +787,9 @@ impl DisplayAs for PanicExec {
DisplayFormatType::Default | DisplayFormatType::Verbose => {
write!(f, "PanicExec",)
}
DisplayFormatType::TreeRender => {
write!(f, "") // TODO(renjj): add display info
}
}
}
}
Expand Down

0 comments on commit d53d876

Please sign in to comment.