We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8a4bad4 commit 81781ffCopy full SHA for 81781ff
datafusion/physical-plan/src/joins/utils.rs
@@ -955,7 +955,12 @@ fn max_distinct_count(
955
let result = match num_rows {
956
Precision::Absent => Precision::Absent,
957
Precision::Inexact(count) => {
958
- Precision::Inexact(count - stats.null_count.get_value().unwrap_or(&0))
+ // To safeguard against inexact number of rows (e.g. 0) being smaller than
959
+ // an exact null count we need to do a checked subtraction.
960
+ match count.checked_sub(*stats.null_count.get_value().unwrap_or(&0)) {
961
+ None => Precision::Inexact(0),
962
+ Some(non_null_count) => Precision::Inexact(non_null_count),
963
+ }
964
}
965
Precision::Exact(count) => {
966
let count = count - stats.null_count.get_value().unwrap_or(&0);
0 commit comments