tlfua commented on code in PR #27783:
URL: https://github.com/apache/datafusion/pull/27783#discussion_r4721824871
##########
datafusion/optimizer/src/decorrelate.rs:
##########
@@ -837,6 +837,9 @@ impl PullUpCorrelatedExpr {
// `f_down` checked that the pulled up filters do not read an
// unnested column.
LogicalPlan::Unnest(_) => self.pass_through_pulled_up_cols(plan),
+ LogicalPlan::Join(_) | LogicalPlan::AsOfJoin(_) => {
Review Comment:
Thanks, applied in fac0f00ea along with your tests (error messages filled
in). I also added `NOT EXISTS` and an `EXISTS` in the projection (mark join)
over `sum`. These now keep the subquery correlated and fail with the
not-implemented error instead of returning wrong rows. Removing the
`regrouped_scalar_agg` check fails five of the new tests.
I also ran a 1152-query matrix (kind of derived table × join form × kind of
subquery) against DuckDB. Before the flag, all 64 wrong results had an
aggregate without `GROUP BY` under `EXISTS`, `NOT EXISTS`, `NOT IN`, or a mark
join. With the flag there are none. (`IN` happened to give correct rows with my
data; your `o.a - 4` case covers it.)
##########
datafusion/optimizer/src/decorrelate.rs:
##########
@@ -837,6 +837,9 @@ impl PullUpCorrelatedExpr {
// `f_down` checked that the pulled up filters do not read an
// unnested column.
LogicalPlan::Unnest(_) => self.pass_through_pulled_up_cols(plan),
+ LogicalPlan::Join(_) | LogicalPlan::AsOfJoin(_) => {
Review Comment:
Added in fac0f00ea. Removing `AsOfJoin` from the arm now fails 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]