zhuqi-lucas commented on code in PR #26461:
URL: https://github.com/apache/datafusion/pull/26461#discussion_r4390035358
##########
datafusion/core/src/physical_planner.rs:
##########
@@ -3596,6 +3608,69 @@ fn tuple_err<T, R>(value: (Result<T>, Result<R>)) ->
Result<(T, R)> {
}
}
+/// A physical optimizer rule and the plan it produced.
+type PlanAfterRule<'a> = (
+ &'a Arc<dyn PhysicalOptimizerRule + Send + Sync>,
+ Arc<dyn ExecutionPlan>,
+);
+
+/// Adds context to an error from the final [`check_plan_tree_sanity`].
+///
+/// `EnsureRequirements` makes the order and distribution requirements hold,
+/// and every rule after it must keep them. When they do not hold for
+/// `final_plan`, the context names the rule that broke this contract: either
+/// `EnsureRequirements` itself, or the rule after which the requirements
+/// stopped holding.
+fn sanity_check_error(
+ error: DataFusionError,
+ final_plan: &Arc<dyn ExecutionPlan>,
+ input_plan: &Arc<dyn ExecutionPlan>,
+ plan_after_rule: &[PlanAfterRule],
+) -> DataFusionError {
+ const SANITY_CHECK: &str = "SanityCheckPlan";
+ if input_requirements_hold(final_plan) {
+ // The error is about unbounded inputs or another invariant.
+ return DataFusionError::Context(SANITY_CHECK.to_string(),
Box::new(error));
+ }
+
+ let ensure_requirements = EnsureRequirements::new();
+ let enforced = plan_after_rule
+ .iter()
+ .rposition(|(rule, _)| rule.name() == ensure_requirements.name());
Review Comment:
Once #26757 lands, this search could start at the enforcement phase boundary
instead of matching `EnsureRequirements` by name.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]