alamb commented on code in PR #27771:
URL: https://github.com/apache/datafusion/pull/27771#discussion_r4727996904
##########
datafusion/core/tests/physical_optimizer/join_selection.rs:
##########
@@ -2264,3 +2269,103 @@ async fn
test_join_selection_skips_real_dynamic_filter_pushdown() -> Result<()>
Ok(())
}
+
+/// A session whose physical optimizer runs [`JoinSelection`] right after
+/// [`EnsureRequirements`] instead of before it.
+fn session_with_join_selection_after_enforcement() -> SessionContext {
+ let mut rules = PhysicalOptimizer::new().rules;
+ let position = |rules: &[Arc<dyn PhysicalOptimizerRule + Send + Sync>],
Review Comment:
would this be better as a method on PhysicalOptimizer? this is fine, it just
feels weird to be mucking round with the internal stte
##########
datafusion/core/tests/physical_optimizer/join_selection.rs:
##########
@@ -2264,3 +2269,103 @@ async fn
test_join_selection_skips_real_dynamic_filter_pushdown() -> Result<()>
Ok(())
}
+
+/// A session whose physical optimizer runs [`JoinSelection`] right after
+/// [`EnsureRequirements`] instead of before it.
Review Comment:
maybe we can add rationale here (we want to ensure that `JoinSelection` does
not make invalid plans that require `EnsureRequirements` to repair)
##########
datafusion/physical-optimizer/src/join_selection.rs:
##########
@@ -340,13 +346,90 @@ fn statistical_join_selection_subrule(
None
};
- Ok(if let Some(transformed) = transformed {
- Transformed::yes(transformed)
- } else {
- Transformed::no(plan)
+ Ok(match transformed {
+ Some(transformed) => match keep_satisfied_requirements(&plan,
transformed)? {
+ Some(transformed) => Transformed::yes(transformed),
+ None => Transformed::no(plan),
+ },
+ None => Transformed::no(plan),
})
}
+/// Makes `new`, which replaces the join `old` over the same inputs, keep the
+/// order and distribution requirements that `old`'s inputs satisfy, because
+/// nothing restores them once `EnsureRequirements` has run.
+///
+/// A swap can make an input with several partitions the build side, which
Review Comment:
I don't quite follow this paragraph -- is it trying to say that this returns
`None` if it is not possible to build a valid join ?
--
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]