sarutak commented on PR #60296:
URL: https://github.com/apache/spark/pull/60296#issuecomment-6975474517

   Thank you, @dongjoon-hyun. I merged `master`, which now has #60325, and 
resolved the conflict in `SubquerySuite`, where both PRs add tests at the end. 
Of the five new golden queries with an expression that fails over no rows, the 
three whose outer rows all have matching rows now return results instead of 
failing while the query is optimized. The other two compute the value over no 
rows for `a1 = 1`, which has no matching rows (one of them although its `WHERE` 
removes that row), and still fail with `DIVIDE_BY_ZERO`, now at runtime. I 
regenerated the golden file, updated the comments in its input file, and added 
a test that these two fail at runtime, also with `ConvertToLocalRelation`, and 
return the results of before with the legacy conf. The test uses 
`checkFailsAtRuntime` of the #60325 test, which I moved to the suite unchanged.
   
   I also found two things to fix in this PR:
   - The `LimitPushDown` change of [25] kept a `LIMIT` above a `Project` with 
any correlated scalar subquery, over a join or, for a `LIMIT 1`, over a 
group-only aggregate. That made plans worse than on `master` and 4.3.0 for 
subqueries that this PR does not change: for a single `MAX`, a `LIMIT 1` over a 
`DISTINCT` no longer replaced the `DISTINCT`; for a subquery without an 
aggregate, which becomes a left single join, a `LIMIT` over a left join below 
no longer reached its left side; and subqueries that decorrelation already 
gives domain joins, e.g. over a lower `COUNT`, no longer got the `LIMIT` into 
the copy of the outer input that their domain joins compute. Now 
`PullupCorrelatedPredicates` sets a new field `DomainJoin.keepLimitAbove` on 
the domain joins of a subquery that this PR moves to `DecorrelateInnerQuery`, 
and `LimitPushDown` keeps a `LIMIT` above only a `Project` with such a 
subquery. For the other subqueries this keeps the plans of `master` and 4.3.0, 
where, as you noted 
 in [25], the `LIMIT` can reach their domain joins too; I could not reproduce a 
wrong result there, so I would like to look at it separately rather than make 
their plans worse than 4.3.0. `LimitPushdownSuite`, 
`PullupCorrelatedPredicatesSuite` and `SubquerySuite` check both sides.
   - `try_sum` of integers or ANSI intervals and `try_avg` of ANSI intervals in 
the outer input give `NULL` on an overflow that depends on the order, so they 
now keep the previous handling, like a `SUM` of decimals without ANSI mode.
   
   I also fixed the description, which left out `SUM` and `AVG` of ANSI 
intervals, and the Scaladoc of `mayMoveIntoOuterInput`. Since `branch-4.4` has 
been cut and has #60325, the description now lists `master`, `branch-4.x` and 
`branch-4.4` as the targets, which keeps the conf version 4.4.0 and the 
migration guide entry under 4.3 to 4.4; if it should not go to `branch-4.4`, I 
will change them to 4.5.0. This PR still has to wait for #60366; once it is 
merged, I will merge `master` again and add a test with a Python UDF such as 
`inv(MAX(b.v))`.
   


-- 
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]

Reply via email to