diff --git a/datafusion-examples/examples/planner_api.rs b/datafusion-examples/examples/planner_api.rs
index 35cf766ba1af..6663f2269cc1 100644
--- a/datafusion-examples/examples/planner_api.rs
+++ b/datafusion-examples/examples/planner_api.rs
@@ -15,10 +15,10 @@
// specific language governing permissions and limitations
// under the License.
-use datafusion::error::Result;
use datafusion::physical_plan::displayable;
use datafusion::physical_planner::DefaultPhysicalPlanner;
use datafusion::prelude::*;
+use datafusion::{error::Result, physical_plan::ExecutionPlan};
use datafusion_expr::{LogicalPlan, PlanType};
/// This example demonstrates the process of converting logical plan
@@ -82,9 +82,35 @@ async fn to_physical_plan_in_one_api_demo(
.plan
);
+ let traversal = extract_node_ids_from_execution_plan_tree(physical_plan.as_ref());
+ let expected_traversal = vec![
+ Some(0),
+ Some(1),
+ Some(2),
+ Some(3),
+ Some(4),
+ Some(5),
+ Some(6),
+ Some(7),
+ Some(8),
+ Some(9),
+ ];
+ assert_eq!(expected_traversal, traversal);
Ok(())
}
+fn extract_node_ids_from_execution_plan_tree(
+ physical_plan: &dyn ExecutionPlan,
+) -> Vec