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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/TopnFilterPushDownVisitor.java:
##########
@@ -233,6 +231,9 @@ public Boolean visitPhysicalHashJoin(PhysicalHashJoin<? 
extends Plan, ? extends
                 if (ctx.probeExpr.equals(conj.child(1))) {
                     // push to left child. right child is blocking operator, 
do not need topn-filter

Review Comment:
   [P1] Guard the nullable right key before rewriting it to the left scan.
   
   For a LEFT OUTER JOIN, `canPushToJoinLeft` only checks 
`isLeftSideNullable()`, so an order key that is a null-to-value function of the 
right key is allowed. The hash branch then rewrites `array_position([0, 1], 
r.k)` to `l.k` and pushes the filter below the join. A reduced plan is:
   
   ```text
   TopN(order by array_position([0,1], r.k) ASC NULLS LAST)
     LEFT OUTER HASH JOIN (l.k = array_position([0,1], r.k))
       Scan l (keys 1,2)
       Scan r (key 0)
   ```
   
   The unmatched `l.k=2` row evaluates `array_position(NULL)=0` after the join, 
but the pushed `l.k` target can remove it using the bound from the matched row, 
changing the result. Keep the original probe expression's null-conversion 
contract when mapping a right key to the left child, or refuse this 
substitution for nullable-right expressions.



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