eldenmoon commented on code in PR #65594:
URL: https://github.com/apache/doris/pull/65594#discussion_r3584378874


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/CheckScoreUsage.java:
##########
@@ -66,10 +66,31 @@ 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),
+
+            // The pushdown rule leaves the supported score() expression on 
the project and scan.
+            // Reject score() in every other plan-owned expression container, 
including filters,
+            // order keys, windows, and join conjuncts.
+            any()
+                .when(this::hasUnoptimizedScore)
+                .then(plan -> {
+                    throw new AnalysisException(
+                            "score() function requires WHERE clause with MATCH 
or SEARCH function, "
+                            + "a projected score() alias, ORDER BY that alias, 
and LIMIT");
                 }).toRule(RuleType.CHECK_SCORE_USAGE)
         );
     }
 
+    private boolean hasUnoptimizedScore(Plan plan) {
+        if (plan instanceof LogicalOlapScan) {

Review Comment:
   Addressed in 95f805a1419. The validation is now a nested-specific whole-plan 
check in CheckScoreUsage: it recursively scans all plan expressions (including 
LogicalOlapScan virtual columns) and rejects any coexistence of score() and a 
NESTED search clause. The previous broad score exemption/optimization logic is 
unchanged for non-NESTED queries. Added tests for projected score, ORDER 
BY-only score, wrapped NESTED trees, and unchanged non-NESTED behavior.



##########
be/src/exprs/vsearch.cpp:
##########
@@ -300,8 +300,13 @@ Status VSearchExpr::evaluate_inverted_index(VExprContext* 
context, uint32_t segm
 
     VLOG_DEBUG << "VSearchExpr: bundle.iterators.size()=" << 
bundle.iterators.size();
 
-    const bool is_nested_query = _search_param.root.clause_type == "NESTED";
-    if (bundle.iterators.empty() && !is_nested_query) {
+    auto index_query_context = index_context->get_index_query_context();
+    const bool has_nested_query = 
search_clause_contains_nested(_search_param.root);
+    const bool is_top_level_nested_query = _search_param.root.clause_type == 
"NESTED";
+    const bool collects_score =
+            index_query_context != nullptr && 
index_query_context->collection_similarity != nullptr;
+    if (bundle.iterators.empty() && !is_top_level_nested_query &&

Review Comment:
   Addressed in 95f805a1419 by removing the BE changes entirely. This PR now 
blocks NESTED + score() in FE before execution, so it no longer introduces or 
depends on BE compound-predicate status propagation.



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