airborne12 commented on code in PR #69292:
URL: https://github.com/apache/doris/pull/69292#discussion_r4334861251


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/PushDownScoreTopNIntoOlapScan.java:
##########
@@ -98,7 +76,69 @@ public List<Rule> buildRules() {
                             LogicalFilter<LogicalOlapScan> filter = 
project.child();
                             LogicalOlapScan scan = filter.child();
                             return pushDown(topN, project, filter, scan);
-                        
}).toRule(RuleType.PUSH_DOWN_SCORE_TOPN_INTO_OLAP_SCAN));
+                        
}).toRule(RuleType.PUSH_DOWN_SCORE_TOPN_INTO_OLAP_SCAN),
+                
logicalProject(logicalFilter(logicalOlapScan()).when(this::hasScorePredicate))

Review Comment:
   Update: 2e999dbfe3 keeps this design but narrows its scope. 
`BindScoreToOlapScan`, which replaces `CheckScoreUsage`, checks and binds each 
SELECT that calls `score()` before subquery aliases are removed: it adds the 
hidden score column to the one scan of that SELECT and replaces its `score()` 
calls with it. The minimum score and TopN pushdowns remain separate, optional 
rules. MATCH/SEARCH predicates are no longer tagged across SELECTs: a scored 
SELECT must read one table, and one nested in a subquery, view, CTE or set 
operation still needs `ORDER BY score() LIMIT`. Your window query stays a 
positive case (`window_same_select`); a raw `score()` above a windowed subquery 
is now rejected with `score() can only be used in a SELECT that reads one table 
and has a MATCH or SEARCH predicate in its WHERE clause`.
   



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

Reply via email to