shrirangmhalgi opened a new pull request, #56277: URL: https://github.com/apache/spark/pull/56277
### What changes were proposed in this pull request? Add `earlyOperatorOptimizationRules` - a new optimizer extension point that runs in a `Once` batch between "Aggregate" and the main fixed-point "Operator Optimization" batch. Wired through `SparkSessionExtensions.injectEarlyOptimizerRule` and `BaseSessionStateBuilder`. The batch is a no-op when no rules are registered. ### Why are the changes needed? Custom rules injected via `injectOptimizerRule` run inside the fixed-point batch alongside built-in rules (FoldablePropagation, ConstantFolding, PushDownPredicates). A rule that needs to observe the original plan shape (e.g., cross-side join predicates before they are folded into single-side constants) is silently defeated when a built-in rule transforms the plan first within the same fixed-point iteration. None of the existing extension points cover this: - `extendedOperatorOptimizationRules` - same fixed-point batch - `postHocResolutionRules` - analyzer phase, too early - `earlyScanPushDownRules` - runs after optimization, scoped to scan pushdown - `preCBORules` - runs after operator optimization, too late ### Does this PR introduce _any_ user-facing change? Yes. New public API will be available: `SparkSessionExtensions.injectEarlyOptimizerRule(builder: RuleBuilder)`. ### How was this patch tested? - New test in `SparkSessionExtensionSuite` verifying the injected rule appears in optimizer batches. - All existing SparkSessionExtensionSuite tests pass. ### Was this patch authored or co-authored using generative AI tooling? Yes. -- 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]
