github-actions[bot] commented on code in PR #69292:
URL: https://github.com/apache/doris/pull/69292#discussion_r4321752024


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/CheckScoreUsage.java:
##########
@@ -54,18 +60,22 @@ public List<Rule> buildRules() {
                     return hasScore && !isOptimized;
                 })
                 .then(project -> {
-                    throw new AnalysisException(
-                            "score() function requires WHERE clause with MATCH 
function, "
-                            + "ORDER BY and LIMIT for optimization");
+                    throw new AnalysisException(SCORE_CONTEXT_ERROR);
+                }).toRule(RuleType.CHECK_SCORE_USAGE),
+
+            // A score() filter on a scan was bound by 
PushDownScoreTopNIntoOlapScan. One left here
+            // filters another operator, e.g. an inner join, and would 
evaluate the scalar placeholder
+            // as zero.
+            logicalFilter(any())

Review Comment:
   [P2] Reject score filters before window predicate pushdown
   
   An outer `WHERE score() > 0.5` on a windowed MATCH subquery produces this 
reduced input:
   ```text
   Filter(score() > 0.5)
     Window(row_number() OVER (ORDER BY id) AS rn)
       Filter(c1 MATCH 'apple')
         OlapScan
   ```
   This guard runs after `PUSH_DOWN_FILTERS`. 
`PushDownFilterThroughWindow.canPushDown` accepts the predicate's empty 
input-slot set: Score's `isDeterministic=false` does not make it a 
`VolatileExpression` or `NoneMovableFunction`. `MergeFilters` then joins it 
with MATCH, and the new standalone scan rule binds/removes it before this check 
sees it. The query is therefore accepted with filtering below the window, 
rather than rejected as an unsupported score context. With matching ids 1 and 2 
where only id 2 exceeds the threshold (as in the ANN regression fixture), the 
surviving row gets `rn=1` instead of retaining its post-window `rn=2`. Prevent 
raw Score from crossing window/partition-TopN operators, or validate its 
context before predicate pushdown, and cover an outer score filter on a 
windowed subquery.



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