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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/ProjectOtherJoinConditionForNestedLoopJoin.java:
##########
@@ -114,6 +114,13 @@ public Expression visit(Expression expression, 
ReplacerContext ctx) {
             if (input.isEmpty() || expression instanceof Slot) {
                 return expression;
             }
+            // A mixed expression like `t1.a + rand() > t2.b` has 
inputSlots={t1.a}; if we alias
+            // it into a child Project, rand()'s evaluation granularity 
changes from "per join
+            // pair" to "per row of that child", which silently changes 
results. Keep such
+            // expressions inline in otherJoinConjuncts.
+            if (expression.containsUniqueFunction()) {

Review Comment:
   This guard stops `PROJECT_OTHER_JOIN_CONDITION` from pushing the expression 
into a child project, but the same semantic change still happens later in 
`AddProjectForUniqueFunction.JoinRewrite`. The updated 
`regression-test/data/nereids_rules_p0/unique_function/add_project_for_unique_function.out`
 still shows `t1.id + t2.id + random(1, 100) between 10 and 20` becoming a 
`PhysicalProject[random(...) AS ...]` under the NLJ, so `random()` is evaluated 
once per left row instead of once per join pair. Please guard that later join 
rewrite too (or otherwise preserve per-pair evaluation), and add a regression 
that exercises the `BETWEEN` / duplicated-`UniqueFunction` path.`



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