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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/stats/JoinEstimation.java:
##########
@@ -418,6 +495,20 @@ public static Statistics estimate(Statistics leftStats, 
Statistics rightStats, J
             updateNumNullsForOuterJoin(crossJoinStats, innerJoinStats, 
rightStats, leftStats, rowCount);
             updateJoinConditionColumnStatistics(crossJoinStats, join);
             return crossJoinStats.withRowCountAndEnforceValid(rowCount);
+        } else if (joinType == JoinType.ASOF_LEFT_OUTER_JOIN) {
+            double rowCount = Math.max(leftStats.getRowCount(), 1);
+            updateNumNullsForOuterJoin(crossJoinStats, innerJoinStats, 
leftStats, rightStats, rowCount);
+            updateJoinConditionColumnStatistics(crossJoinStats, join);
+            return crossJoinStats.withRowCountAndEnforceValid(rowCount);
+        } else if (joinType == JoinType.ASOF_RIGHT_OUTER_JOIN) {
+            double rowCount = Math.max(rightStats.getRowCount(), 1);
+            updateNumNullsForOuterJoin(crossJoinStats, innerJoinStats, 
leftStats, rightStats, rowCount);
+            updateJoinConditionColumnStatistics(crossJoinStats, join);

Review Comment:
   Bug: For `ASOF_RIGHT_OUTER_JOIN`, the arguments to 
`updateNumNullsForOuterJoin` are reversed.
   
   The existing `RIGHT_OUTER_JOIN` case (line 488) uses `rightStats, leftStats`:
   ```java
   updateNumNullsForOuterJoin(crossJoinStats, innerJoinStats, rightStats, 
leftStats, rowCount);
   ```
   
   But this `ASOF_RIGHT_OUTER_JOIN` case uses `leftStats, rightStats` — the 
same order as `LEFT_OUTER_JOIN`, which is incorrect. In a right outer join, the 
right (probe) side is preserved and the left (build) side gets NULL-padded, so 
the parameter order should match `RIGHT_OUTER_JOIN`.
   
   Suggested fix:
   ```java
   updateNumNullsForOuterJoin(crossJoinStats, innerJoinStats, rightStats, 
leftStats, rowCount);
   ```



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