adriangb commented on code in PR #23948:
URL: https://github.com/apache/datafusion/pull/23948#discussion_r3688383772


##########
datafusion/core/tests/physical_optimizer/ensure_requirements.rs:
##########
@@ -1252,3 +1267,112 @@ fn test_idempotent_union_projection_sort() {
 
     assert_idempotent(plan);
 }
+
+/// A `CollectLeft` `HashJoinExec` requires `Distribution::SinglePartition` on 
its build
+/// (left) child, so `EnsureRequirements` puts a `CoalescePartitionsExec` on 
top of a
+/// multi-partition build side. Its sort-parallelization phase must not take 
that coalesce
+/// back out again.
+///
+/// The phase descends into a node when *any* of its children is linked to a
+/// `CoalescePartitionsExec` below (`update_coalesce_ctx_children`), so a 
connected probe
+/// side is enough to reach the join, and the removal itself used to look only 
at
+/// `children[0]` without consulting the join's own distribution requirement. 
The result was
+/// a build side left multi-partition with nothing to re-enforce distribution 
afterwards,
+/// which `SanityCheckPlan` then rejected with "does not satisfy distribution 
requirements:
+/// SinglePartition".
+#[test]
+fn test_collect_left_join_keeps_build_side_coalesce() {

Review Comment:
   Yep — confirmed, and your hypothesis was exactly right. Phase 2a drops the 
probe-side coalesce in the mock shape, so the join never gets marked as 
connected and the walk never descends into it.
   
   Rebuilt in 8fb3d30744: the tests now construct the pre-phase-3a shape 
directly (probe-side coalesce intact) and drive parallelize_sorts via 
transform_up, then check with SanityCheckPlan. Both fail with the reported 
SinglePartition error when the fix is reverted.



-- 
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]

Reply via email to