englefly commented on code in PR #19305:
URL: https://github.com/apache/doris/pull/19305#discussion_r1191880577
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/logical/ExtractAndNormalizeWindowExpression.java:
##########
@@ -96,35 +87,32 @@ private Set<Expression>
collectExpressionsToBePushedDown(List<NamedExpression> e
// bottomProjects includes:
// 1. expressions from function and WindowSpec's partitionKeys and
orderKeys
// 2. other slots of outputExpressions
- /*
- avg(c) / sum(a+1) over (order by avg(b)) group by a
- win(x/sum(z) over y)
- prj(x, y, a+1 as z)
- agg(avg(c) x, avg(b) y, a)
- proj(a b c)
- toBePushDown = {avg(c), a+1, avg(b)}
- */
+ //
+ // avg(c) / sum(a+1) over (order by avg(b)) group by a
+ // win(x/sum(z) over y)
+ // prj(x, y, a+1 as z)
+ // agg(avg(c) x, avg(b) y, a)
+ // proj(a b c)
+ // toBePushDown = {avg(c), a+1, avg(b)}
return expressions.stream()
.flatMap(expression -> {
if (expression.anyMatch(WindowExpression.class::isInstance)) {
- Set<Slot> inputSlots =
expression.getInputSlots().stream().collect(Collectors.toSet());
+ Set<Slot> inputSlots =
Sets.newHashSet(expression.getInputSlots());
Set<WindowExpression> collects =
expression.collect(WindowExpression.class::isInstance);
- Set<Slot> windowInputSlots = collects.stream().flatMap(
- win -> win.getInputSlots().stream()
- ).collect(Collectors.toSet());
- /*
- substr(
- ref_1.cp_type,
- max(
- cast(ref_1.`cp_catalog_page_number` as int)) over
(...)
- ),
- 1)
-
- in above case, ref_1.cp_type should be pushed down.
ref_1.cp_type is in
- substr.inputSlots, but not in windowExpression.inputSlots
-
- inputSlots= {ref_1.cp_type}
- */
+ Set<Slot> windowInputSlots = collects.stream()
+ .flatMap(win -> win.getInputSlots().stream())
+ .collect(Collectors.toSet());
+ // substr(
+ // ref_1.cp_type,
+ // max(
+ // cast(ref_1.`cp_catalog_page_number` as int)) over
(...)
+ // ),
+ // 1)
+ //
+ // in above case, ref_1.cp_type should be pushed down.
ref_1.cp_type is in
+ // substr.inputSlots, but not in
windowExpression.inputSlots
+ //
+ // inputSlots= {ref_1.cp_type}
Review Comment:
Could you add a ut or regression for this case?
--
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]