cloud-fan opened a new pull request, #55876: URL: https://github.com/apache/spark/pull/55876
### What changes were proposed in this pull request? Follow-up to https://github.com/apache/spark/pull/55519. `PartitioningPreservingUnaryExecNode.projectKeyedPartitionings` uses `kps.head.expressions.length` as the arity for the per-position projection and then indexes `kp.expressions(i)` for every input KP. If a child exposes a `PartitioningCollection` containing KPs of different arities — which can happen when upstream nodes have already narrowed some KPs but not others — indexing `kp.expressions(i)` for `i >= kp.expressions.length` throws `IndexOutOfBoundsException`. Filter the input KPs to those whose arity matches the head before the per-position loop. This restores the function's "shared partitionKeys" invariant on the surviving KPs. ### Why are the changes needed? Without the filter, plans that put a `ProjectExec` (or any other `PartitioningPreservingUnaryExecNode`) above a `PartitioningCollection` with mixed-arity KPs fail with `IndexOutOfBoundsException` during planning. ### Does this PR introduce _any_ user-facing change? No (bug fix; planner only). ### How was this patch tested? New unit test `SPARK-46367: projectKeyedPartitionings tolerates mixed-arity KPs in child output` in `ProjectedOrderingAndPartitioningSuite` that constructs a mixed-arity `PartitioningCollection` child and verifies `ProjectExec.outputPartitioning` does not throw. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Sonnet 4.6 -- 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]
