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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/CheckScoreUsage.java:
##########
@@ -66,10 +67,32 @@ public List<Rule> buildRules() {
                             "score() function cannot be used in aggregate 
functions. "
                             + "score() requires WHERE clause with MATCH 
function, "
                             + "ORDER BY and LIMIT for optimization");
+                }).toRule(RuleType.CHECK_SCORE_USAGE),
+
+            any()
+                .when(this::hasNestedSearchAndScore)
+                .then(plan -> {
+                    throw new AnalysisException(
+                            "score() is not supported with a NESTED search 
clause");
                 }).toRule(RuleType.CHECK_SCORE_USAGE)
         );
     }
 
+    private boolean hasNestedSearchAndScore(Plan plan) {

Review Comment:
   This check is currently query-subtree scoped rather than branch/scenario 
scoped, so it can combine unrelated children. For example:
   
   ```text
   LogicalUnion
     Filter(search('NESTED(v, host:apple)')) -> Scan(t)
     TopN(order by s)
       Project(id, score() AS s)
         Filter(search('title:apple')) -> Scan(t)
   ```
   
   The first branch has no `score()`, and the second branch has no NESTED 
search, but `hasNestedSearchAndScore(union)` returns true because 
`containsNestedSearch` and `containsScoreFunction` recurse over all children 
independently. Since this top-down batch checks the union/join ancestor before 
the child score branch is rewritten, valid mixed-branch queries can now fail 
with `score() is not supported with a NESTED search clause`. Please scope the 
prohibition to the same branch/scan path, or otherwise avoid aggregating NESTED 
and `score()` from independent UNION/JOIN children, and add a mixed-branch 
regression.
   



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