gruuya commented on code in PR #9007:
URL: https://github.com/apache/arrow-datafusion/pull/9007#discussion_r1467552549


##########
datafusion/physical-plan/src/joins/utils.rs:
##########
@@ -955,7 +955,12 @@ fn max_distinct_count(
             let result = match num_rows {
                 Precision::Absent => Precision::Absent,
                 Precision::Inexact(count) => {
-                    Precision::Inexact(count - 
stats.null_count.get_value().unwrap_or(&0))
+                    // To safeguard against inexact number of rows (e.g. 0) 
being smaller than
+                    // an exact null count we need to do a checked subtraction.
+                    match 
count.checked_sub(*stats.null_count.get_value().unwrap_or(&0)) {
+                        None => Precision::Inexact(0),

Review Comment:
   This made more sense than `Precision::Absent`.
   
   Also, I'm not sure whether this can happen below as well, i.e. an inexact 
null count being larger than an exact row count.



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

Reply via email to