comphead commented on code in PR #26013:
URL: https://github.com/apache/datafusion/pull/26013#discussion_r4316877319
##########
datafusion/optimizer/src/decorrelate.rs:
##########
@@ -577,6 +581,17 @@ 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.
+ if self.can_extend_partition_by
+ &&
!self.collected_count_expr_map.contains_key(&*window.input)
Review Comment:
Thanks, confirmed. The root cause was in the Projection:
`proj_exprs_evaluation_result_on_empty_batch` only recorded expressions that
read an aggregate column, so `1 AS x` left the map empty and the entry was
dropped. It now also records expressions that read no column.
With that, the window query stays correlated, as on the merge base. The same
projection without the window returned `(5, NULL)` on `main` too. It now
returns `(5, 1)`. Both cases are in `subquery.slt`.
--
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]