github-actions[bot] commented on code in PR #62754:
URL: https://github.com/apache/doris/pull/62754#discussion_r3129807075
##########
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 is still too local to preserve join-pair semantics.
`ProjectOtherJoinConditionForNestedLoopJoin` now stops aliasing the whole mixed
subtree here, but later `AddProjectForUniqueFunction.JoinRewrite` still scans
`otherJoinConjuncts` and hoists repeated `UniqueFunction`s into the left child
project. The updated `add_project_for_unique_function.out` already shows that
for `t1.id + t2.id + random() between 10 and 20`: `$_random_7_$` is
materialized on the left side, so the same random draw is reused for every
right row of a given left row. That is still different from evaluating the ON
predicate once per join pair.
Can we also block the later join-side materialization for unique functions
that live inside mixed-side `otherJoinConjuncts` (or recurse here and only skip
aliasing the exact unique-function subtree)? Otherwise this PR still leaves
wrong-results cases in NLJ.
--
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]