kumarUjjawal commented on code in PR #26013:
URL: https://github.com/apache/datafusion/pull/26013#discussion_r4332369753


##########
datafusion/optimizer/src/decorrelate.rs:
##########
@@ -664,6 +674,16 @@ impl TreeNodeRewriter for PullUpCorrelatedExpr {
                         .iter()
                         .all(|expr| partitions_by_all(expr, 
&local_correlated_cols))
                 {
+                    // `inner.y = outer.k` keeps the rows of one `y` value for
+                    // each outer row, so partitioning by `y` as well gives 
each
+                    // window function the same rows. A window over an
+                    // aggregate with count bug handling stops the pull up in
+                    // `pass_through_pulled_up_cols`.
+                    if self.can_extend_partition_by {

Review Comment:
   `DISTINCT` or a `Filter` between the aggregate and window still drops the 
count-bug state, so this guard misses it. I reproduced `(5, NULL)` instead of 
`(5, 1)` on `b6debc1c6`; the merge base rejects the query as unsupported. Could 
we preserve that state, or stop decorrelation, and add regression tests for 
both cases?



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