ulysses-you commented on PR #59522: URL: https://github.com/apache/spark/pull/59522#issuecomment-6793553408
Thank you @rekbun and @peter-toth . I don't particularly like this approach, and the reason is structural rather than a matter of implementation detail. V1 already shows where this ends: `FileSourceScanExec` packs files inside the scan and reports `UnknownPartitioning(0)`, and `spark.sql.files.*` has remained a leaf-local size heuristic that is only usable where nothing reads the layout; it never grew distribution-preserving coalescing, the behavior Spark implements for shuffle reads by re-planning at stage boundaries and restating the layout as `CoalescedHashPartitioning` or a fewer-partition `RangePartitioning`. This PR repeats the same placement: it packs inside the leaf and decides the groups in `BatchScanExec.inputRDD` at execution, so the scan must give up its keyed partitioning and ordering and report `Unknown(0)`, and the group count exists only as the runtime RDD's partition count, never as a `Partitioning` value during planning; because the grouping is next-fit over adjacent inputs, it also ignores key bou ndaries and can split one key's splits across partitions. The result is that no operator consuming partitioning or ordering can sit above a packed scan, so the rule has to prove a whole-plan property, its applicable set shrinks as layout-aware operators spread, and distribution-preserving coalescing, which needs a re-planning point, an expressible coarsened partitioning, and shared boundaries across co-partitioned scans, has nothing to hook into. Adding a coalesced partitioning type or making the grouping key-aware would not fix this on its own, because the missing piece is a plan-time producer of the group count, and that requires moving the decision out of `inputRDD` into a node or a stage boundary. The other direction is to extend `GroupPartitionsExec` with size-based packing, but that would blur what GPE is for. GPE exists to replace a shuffle: `EnsureRequirements` inserts it on a keyed side so that the keyed layout, rather than an exchange, establishes co-partitioning, and everything about the node, from `plannedPartitioning` and the keyed layout checks to replication and padding, is there to keep the partition-to-key mapping valid. Size packing starts from the opposite premise: it is only legal where nobody reads the keyed layout, so the same node would sometimes report a keyed partitioning and sometimes `Unknown(n)`, with the same name, metrics and neighbors but different guarantees, and the existing consumers are written against the keyed meaning; merging distinct keys breaks that invariant as well. Keeping the keyed contract does require the merged groups to be key-group-aware and shared across the two sides, but that is a well-scoped extension the node can grow into s tep by step, which is exactly what the current design cannot offer. So this route trades a clearer contract for a mode switch and forces every consumer to reason about which mode it is looking at, but it keeps the door open for the coalescing semantics, while the current design closes it. -- 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]
