Skip to content

Commit fbf7737

Browse files
alambclaude
andauthored
docs(minor): Explain the role of EnsureRequirements in the physical optimizer pipeline (#26479)
## Which issue does this PR close? - Related to #26351 (split out so it can be reviewed and merged independently) ## Rationale for this change While reviewing #26351 @jayzhan211 @2010YOUY01 and I have observed that `EnsureRequirements` is special among the physical optimizer rules, but that isn't documented on the rule itself ## What changes are included in this PR? Documentation only, in `datafusion/physical-optimizer/src/ensure_requirements/mod.rs`: ## What is the testing strategy for this PR? CI ## Are there any user-facing changes? No, only rustdoc text. Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 862843f commit fbf7737

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

  • datafusion/physical-optimizer/src/ensure_requirements

‎datafusion/physical-optimizer/src/ensure_requirements/mod.rs‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@
1818
//! [`EnsureRequirements`] optimizer rule that enforces distribution and
1919
//! sorting requirements together so that the two never invalidate each other.
2020
//!
21-
//! This rule replaces the separate `EnforceDistribution` + `EnforceSorting`
22-
//! rules with a unified approach inspired by Apache Spark's `EnsureRequirements`
23-
//! and Presto/Trino's `AddExchanges`.
21+
//! # Placement in the Optimizer Pipeline
22+
//!
23+
//! Unlike most optimizer rules, this rule modifies an unexecutable physical
24+
//! plan that does not satisfy distribution and ordering requirements into an
25+
//! *executable* one. A pipeline that omits this rule may produce a plan that
26+
//! is not runnable or that returns incorrect results. See the [Physical
27+
//! Optimizer](crate::optimizer) for details.
2428
//!
2529
//! # Motivation
2630
//!
@@ -161,10 +165,10 @@ use datafusion_physical_plan::ExecutionPlan;
161165

162166
/// Optimizer rule that enforces both distribution and sorting requirements.
163167
///
164-
/// This rule combines the functionality of `EnforceDistribution` and
165-
/// `EnforceSorting` into a coordinated sequence where distribution is
166-
/// always settled before sorting for each operator, preventing the
167-
/// non-idempotent interactions between the two separate rules.
168+
/// This rule inserts the repartitioning and sorting operators needed to
169+
/// satisfy the requirements that operators declare via
170+
/// [`ExecutionPlan::input_distribution_requirements`] and
171+
/// [`ExecutionPlan::required_input_ordering`].
168172
///
169173
/// See [module level documentation](self) for more details.
170174
#[derive(Default, Debug)]

0 commit comments

Comments
 (0)