xzj7019 commented on code in PR #23935:
URL: https://github.com/apache/doris/pull/23935#discussion_r1316877390


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/PushdownFilterThroughWindow.java:
##########
@@ -81,88 +55,36 @@ public Rule build() {
         return logicalFilter(logicalWindow()).thenApply(ctx -> {
             LogicalFilter<LogicalWindow<Plan>> filter = ctx.root;
             LogicalWindow<Plan> window = filter.child();
-
-            // We have already done such optimization rule, so just ignore it.
-            if (window.child(0) instanceof LogicalPartitionTopN) {
-                return filter;
-            }
-
-            List<NamedExpression> windowExprs = window.getWindowExpressions();
-            if (windowExprs.size() != 1) {
-                return filter;
-            }
-            NamedExpression windowExpr = windowExprs.get(0);
-            if (windowExpr.children().size() != 1 || !(windowExpr.child(0) 
instanceof WindowExpression)) {
-                return filter;
-            }
-
-            // Check the filter conditions. Now, we currently only support 
simple conditions of the form
-            // 'column </ <=/ = constant'. We will extract some related 
conjuncts and do some check.
-            Set<Expression> conjuncts = filter.getConjuncts();
-            Set<Expression> relatedConjuncts = 
extractRelatedConjuncts(conjuncts, windowExpr.getExprId());
-
-            boolean hasPartitionLimit = false;
-            long partitionLimit = Long.MAX_VALUE;
-
-            for (Expression conjunct : relatedConjuncts) {
-                Preconditions.checkArgument(conjunct instanceof 
BinaryOperator);
-                BinaryOperator op = (BinaryOperator) conjunct;
-                Expression leftChild = op.children().get(0);
-                Expression rightChild = op.children().get(1);
-
-                Preconditions.checkArgument(leftChild instanceof SlotReference
-                        && rightChild instanceof IntegerLikeLiteral);
-
-                long limitVal = ((IntegerLikeLiteral) 
rightChild).getLongValue();
-                // Adjust the value for 'limitVal' based on the comparison 
operators.
-                if (conjunct instanceof LessThan) {
-                    limitVal--;
-                }
-                if (limitVal < 0) {
-                    return new 
LogicalEmptyRelation(ctx.statementContext.getNextRelationId(), 
filter.getOutput());
+            Set<Expression> commonPartitionKeys = 
window.getCommonPartitionKeyFromWindowExpressions();
+            Set<Expression> bottomConjuncts = Sets.newHashSet();
+            Set<Expression> upperConjuncts = Sets.newHashSet();
+            for (Expression expr : filter.getConjuncts()) {
+                boolean pushed = false;
+                for (Expression partitionKey : commonPartitionKeys) {
+                    if 
(partitionKey.getInputSlots().containsAll(expr.getInputSlots())) {

Review Comment:
   select * from (select c.*, rank() over(partition by c2+c3 order by c4) rn 
from c) abc where c2=1;
   Seems that c2=1 can't be pushed down. We can just support column currently.



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

Reply via email to