okumin commented on code in PR #6505:
URL: https://github.com/apache/hive/pull/6505#discussion_r4675066143


##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/stats/annotation/StatsRulesProcFactory.java:
##########
@@ -2249,14 +2276,15 @@ private long calculateUnmatchedRowsForOuter(HiveConf 
conf, long inputRowCount,
           distinctVal = StatsUtils.addWithExpDecay(distinctVals);
         }
       }
-      // If we have a greater number of unmatched values than number of 
distinct values,
-      // we just return the number of rows in the input as we can assume there 
are no
-      // matches
-      if (distinctUnmatched >= distinctVal) {
+      // distinctVal <= 0 covers unknown (<0) and verified-zero (==0) cases; 
the latter means
+      // no key value matches anything, so every input row is unmatched in an 
outer join.
+      // distinctUnmatched < 0 (unknown) is treated conservatively the same 
way.
+      // If unmatched >= distinctVal, all rows can be assumed unmatched.
+      if (distinctVal <= 0 || distinctUnmatched < 0 || distinctUnmatched >= 
distinctVal) {

Review Comment:
   ```suggestion
         if (distinctUnmatched < 0 || distinctUnmatched >= distinctVal) {
   ```
   
   When `distinctUnmatched >= distinctVal` is evaluated, given that the minimum 
`distinctUnmatched` is 0, `distinctUnmatched >= distinctVal` covers 
`distinctVal <= 0`.



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