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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/PushdownFilterThroughSort.java:
##########
@@ -19,24 +19,36 @@
 
 import org.apache.doris.nereids.rules.Rule;
 import org.apache.doris.nereids.rules.RuleType;
+import org.apache.doris.nereids.trees.expressions.Slot;
 import org.apache.doris.nereids.trees.plans.Plan;
 import org.apache.doris.nereids.trees.plans.logical.LogicalFilter;
 import org.apache.doris.nereids.trees.plans.logical.LogicalSort;
+import org.apache.doris.nereids.util.ExpressionUtils;
+
+import java.util.Set;
 
 /**
  * Push down filter through sort.
  * input:
  * filter -> sort
  * output:
- * sort -> filter
+ * [sort] -> filter
  * The filter can be directly push down to the sort.
+ * Note when the sort key is equal to Literal, the sort can be eliminated
  */
 public class PushdownFilterThroughSort extends OneRewriteRuleFactory {
     @Override
     public Rule build() {
         return logicalFilter(logicalSort()).then(filter -> {
             LogicalSort<Plan> sort = filter.child();
+            if (checkSlotsConstant(sort.getInputSlots(), filter)) {
+                return new LogicalFilter<>(filter.getConjuncts(), 
sort.child());

Review Comment:
   could we expand this rule to other sceario, such as group by constants, and 
uncorelate subuquery?



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