morrySnow commented on code in PR #22907: URL: https://github.com/apache/doris/pull/22907#discussion_r1299690150
########## fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AggScalarSubQueryToWindowFunction.java: ########## @@ -326,7 +324,17 @@ private Plan rewrite(LogicalFilter<? extends Plan> filter, LogicalApply<Plan, Pl // it's a simple case, but we may meet some complex cases in ut. // TODO: support compound predicate and multi apply node. - Expression windowFilterConjunct = apply.getSubCorrespondingConjunct().get(); + Map<Boolean, Set<Expression>> conjuncts = filter.getConjuncts().stream() + .collect(Collectors.groupingBy(conjunct -> Sets + .intersection(conjunct.getInputSlotExprIds(), agg.getOutputExprIdSet()) + .isEmpty(), Collectors.toSet())); Review Comment: if only need false part, use filter is better ########## fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/SubqueryToApply.java: ########## @@ -100,24 +99,21 @@ public List<Rule> buildRules() { applyPlan = subqueryToApply(subqueryExprs.stream() .collect(ImmutableList.toImmutableList()), tmpPlan, context.getSubqueryToMarkJoinSlot(), - context.getSubqueryCorrespondingConjunct(), ctx.cascadesContext, + ctx.cascadesContext, Optional.of(conjunct), false); tmpPlan = applyPlan; - if (!(subqueryExprs.size() == 1 - && subqueryExprs.stream().anyMatch(ScalarSubquery.class::isInstance))) { - newConjuncts.add(conjunct); - } + newConjuncts.add(conjunct); } - Set<Expression> conjects = new LinkedHashSet<>(); - conjects.addAll(newConjuncts.build()); - Plan newFilter = new LogicalFilter<>(conjects, applyPlan); - if (conjects.stream().flatMap(c -> c.children().stream()) + Set<Expression> conjuncts = new LinkedHashSet<>(); + conjuncts.addAll(newConjuncts.build()); Review Comment: declare `newConjuncts` as `ImmutableSet.Builder` -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org