rdtr commented on PR #59194: URL: https://github.com/apache/spark/pull/59194#issuecomment-6698313636
Thanks @dongjoon-hyun for the detailed review. I addressed all seven comments in https://github.com/apache/spark/pull/59194/commits/37b67159179da29179978bcf2249ef585aca4260. 1. Overflow: `LimitPushDown` now folds the sum only when both values are integer literals and the sum fits in an `Int`, through a new helper `LimitAndOffsetValues.add`. Otherwise it keeps the unevaluated `Add` as before. I ran your `UNION ALL` example on master with ANSI off and `ConstantFolding` excluded, and it already returned 3 rows there instead of failing with `No plan`. `EliminateLimits` merges the two `LocalLimit`s in the `Union` branch with `Least(...).eval()`, which evaluates the `Add`, and the plan has `LocalLimit -2147483648`. So the wrong result is pre-existing in that configuration too. I'll file a follow-up JIRA for the overflow and open a PR on top of this one. I also corrected the overflow sentence in the description. 2. Early evaluation: with the change above, a sum that overflows is not evaluated in `LimitPushDown`. Your `LIMIT 0` example fails with `ARITHMETIC_OVERFLOW` on the previous commit and returns no rows again now, like master. 3. `EliminateOffsets`: the `Offset` merge uses the same helper. `EliminateOffsetsSuite` "Combines Offset operators" now expects `Offset(5)`, and a new test checks that an overflowing sum stays an `Add`. 4. End-to-end test: added "SPARK-57125: LIMIT and OFFSET succeed when ConstantFolding is in excludedRules" next to the SPARK-59044 test. It runs your two queries and `SELECT * FROM (SELECT id FROM range(0, 10, 1, 1) OFFSET 1) LIMIT 3 OFFSET 2` for item 3. I used a single partition so that the rows returned without `ORDER BY` are deterministic. On master it fails with `No plan for LocalLimit (1 + 2)`, and with only the `EliminateOffsets` change reverted it fails with `No plan for Offset (2 + 1)`. 5. Description: the user-facing change section now says "Yes", with the before and after behavior, and notes that optimized plans can differ in the default configuration. I also changed the title, since the PR now covers `EliminateOffsets` too. 6. Backport: the change no longer calls `ConstantFolding.constantFolding`. The `Optimizer.scala` change applies cleanly to branch-4.0 and branch-4.1. On those branches only the `SQLQuerySuite` test conflicts, because the SPARK-59044 test next to it is not there. 7. The test now calls `LimitPushDown` directly, and "How was this patch tested?" mentions the `PushProjectionThroughLimitAndOffsetSuite` expectations. Could you take another look, and let me know if I am missing anything. -- 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]
