peter-toth opened a new pull request, #60447: URL: https://github.com/apache/spark/pull/60447
### What changes were proposed in this pull request? This is a follow-up of #60030. `BatchScanExec` takes its `Scan` again, as before #60030, and keeps the `PlannedScan` in a `TreeNodeTag` instead of a constructor field: - The node sets the tag when it first asks for its `Batch` or input partitions. `makeCopy`, `clone` and the tree transforms carry it over to the copies made after that, so they share the planned `Batch`, partitions and reader factory, as with the field. - A copy over another `Scan` plans its own, as with the field. - A copy the case-class `copy` makes plans its own too, because `copy` carries no tags. Nothing in Spark copies an executable `BatchScanExec` with `copy`. `doCanonicalize` does, and it hands the `PlannedScan` over to the canonical node, whose `equals` compares the planned `Batch`. - `DataSourceV2Strategy` passes `relation.scan` again. `PlannedScan` is package private and has no extractor. ### Why are the changes needed? #60030 replaced the `scan: Scan` parameter of `BatchScanExec` with `plannedScan: PlannedScan`, so that the copies of a node share what it planned. That changed the signature. Code that builds the node, or matches it with `case BatchScanExec(_, scan: MyScan, ...)`, no longer compiles. #60030 had to change eight test suites for that, and extensions that build or match the node would have to change the same way. The sharing does not need a constructor field. Recent fixes keep a decision of a node across its copies in a `TreeNodeTag`: - SPARK-59122 (#58419) keeps the plain-union decision of `UnionExec` in a tag. - SPARK-61574 (#60418) keeps the columnar decision of `FileSourceScanExec` in a tag. This PR follows the same pattern, so the signature of `BatchScanExec` stays as in the released versions. The SPARK-60752 backports to branch-4.3, branch-4.2, branch-4.1 and branch-4.0 keep the signature with a private field that `makeCopy` and `clone` hand over. Follow-ups will move them to the tag as well, so every branch has the same shape. ### Does this PR introduce _any_ user-facing change? No. Queries behave as with #60030. For code that builds or matches `BatchScanExec`, its second parameter is a `Scan` again, as in the released versions. ### How was this patch tested? - The SPARK-60752 test in `SparkPlanSuite` checks that, once the node has planned, `makeCopy`, `clone` and the canonical form share its `Batch` and partitions, and that a `makeCopy` over another `Scan` does not. - The SPARK-60752 tests of #60030 in `KeyGroupedPartitioningSuite` and the runtime filter suites pass unchanged. With the planning kept per node instead of in the tag, four of them fail. - The SPARK-60618 test that rebuilds a scan uses `copy` again to plan the replacement partitions. - The suites that matched the scan through `PlannedScan` match the `Scan` again. Also ran `GroupPartitionsExecSuite`, `SameResultSuite`, `SQLAppStatusListenerSuite`, `EnsureRequirementsSuite`, the `DynamicPartitionPruningV2*` suites, `DataSourceV2CatalystRuntimeFilterSuite`, `DataSourceV2SQLSuiteV2Filter`, `DSv2PlanMergingSuite`, `FileBasedDataSourceSuite`, `DataSourceV2OptionSuite`, `PruneFileSourcePartitionsSuite`, `OrcV2SchemaPruningSuite`, `AvroRowReaderSuite` and `AvroV2Suite`. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code with Claude Opus 5.5 -- 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]
