github-actions[bot] commented on code in PR #65594:
URL: https://github.com/apache/doris/pull/65594#discussion_r3580105516
##########
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:
`PushDownVirtualColumnsIntoOlapScan` runs just before this score validation
and can hide a repeated score wrapper inside `LogicalOlapScan.virtualColumns`
when virtual-slot CSE is enabled. For example, two predicates using `score() +
1` are eligible for extraction because `Score` is non-deterministic but not
`VolatileExpression`; after the rewrite the filter/project no longer expose
`Score`, `PushDownScoreTopNIntoOlapScan` cannot build the supported score TopN
shape, and this branch returns `false` before looking at the scan virtual
columns. The remaining raw `score()` is then translated as an ordinary scan
virtual-column expression without score order keys/limit, so unsupported score
predicates can execute using the scalar fallback zeros instead of being
rejected. Please make the exemption inspect scan virtual columns and only allow
the exact optimized score state, or block `Score` in the generic virtual-column
CSE rule before this check runs.
--
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]