gabotechs commented on code in PR #20799:
URL: https://github.com/apache/datafusion/pull/20799#discussion_r2903876183


##########
datafusion/physical-plan/src/joins/utils.rs:
##########
@@ -721,12 +721,13 @@ fn max_distinct_count(
                         Some(non_null_count) => 
Precision::Inexact(non_null_count),
                     }
                 }
-                Precision::Exact(count) => {
-                    let count = count - 
stats.null_count.get_value().unwrap_or(&0);
+                    Precision::Exact(count) => {
+                    let null_count = 
*stats.null_count.get_value().unwrap_or(&0);
+                    let non_null_count = 
count.checked_sub(null_count).unwrap_or(0);

Review Comment:
   👍 nice, even if this is a good safeguard, the fact that this can even happen 
makes me think that there is some further work to be done in the stats 
propagation mechanism.
   
   Ideally, this would not even be possible by construction, but that's a topic 
for another PR.



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