Skip to content

Apache DataFusion SQL Query Engine

Fix potential overflow when we print verbose physical plan (#17798)

Qi Zhubbb5cc79de3d
diff --git a/datafusion/core/src/physical_planner.rs b/datafusion/core/src/physical_planner.rs
index 4a8586b2f9..6b4d2592f6 100644
--- a/datafusion/core/src/physical_planner.rs
+++ b/datafusion/core/src/physical_planner.rs
@@ -2135,7 +2135,15 @@ impl DefaultPhysicalPlanner {
"Optimized physical plan:\n{}\n",
displayable(new_plan.as_ref()).indent(false)
);
- debug!("Detailed optimized physical plan:\n{new_plan:?}");
+
+ // Don't print new_plan directly, as that may overflow the stack.
+ // For example:
+ // thread 'tokio-runtime-worker' has overflowed its stack
+ // fatal runtime error: stack overflow, aborting
+ debug!(
+ "Detailed optimized physical plan:\n{}\n",
+ displayable(new_plan.as_ref()).indent(true)
+ );
Ok(new_plan)
}