influxdata/influxdb · error

min ( ) > max ( )

Error message

min ({min:?}) > max ({max:?})

What it means

overlap() panics when any (min, max) pair in the value_ranges slice has min > max. The function builds an interleaved array of min/max values and requires each range be well-ordered, since an inverted range would corrupt the overlap check.

Solutions

  1. Validate each (min, max) pair before passing it to overlap and swap/repair inverted ranges
  2. Fix the statistics-producing code that emitted min > max
  3. For tests, construct ranges with min <= max explicitly

Example fix

// before
overlap(&[(ScalarValue::Int64(Some(10)), ScalarValue::Int64(Some(5)))])?;
// after
let (min, max) = (ScalarValue::Int64(Some(5)), ScalarValue::Int64(Some(10)));
overlap(&[(min, max)])?;
Defensive patterns

Strategy: validation

Validate before calling

for (min, max) in ranges { if min > max { /* repair or reject */ } }

Type guard

fn is_well_ordered(r: &(ScalarValue, ScalarValue)) -> bool { r.0 <= r.1 }

Try / catch

// pre-sort each pair: let (min, max) = if min > max { (max, min) } else { (min, max) };

Prevention

When it happens

Trigger: Calling overlap (e.g. via overlap_all) with a range whose min ScalarValue is greater than its max — typically from corrupted or wrongly merged column statistics.

Common situations: Statistics union/merge code that swapped min and max; stats collected from differently sorted inputs; tests feeding hand-written ranges in the wrong order.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of influxdata/influxdb@06200ef96b (2026-09-19). Data as JSON: /api/errors/81466d639714ba07. Report an issue: GitHub.

Appendix: source

Thrown at core/iox_query/src/statistics/stats_utils.rs:49

/// Return min max of a ColumnStatistics with precise values
pub fn column_statistics_min_max(
    column_statistics: ColumnStatistics,
) -> Option<(ScalarValue, ScalarValue)> {
    match (column_statistics.min_value, column_statistics.max_value) {
        (Precision::Exact(min), Precision::Exact(max)) => Some((min, max)),
        // the statistics values are absent or imprecise
        _ => None,
    }
}

/// Return true if at least 2 min_max ranges in the given array overlap
pub fn overlap(value_ranges: &[(ScalarValue, ScalarValue)]) -> Result<bool, DataFusionError> {
    // interleave min and max into one iterator
    let value_ranges_iter = value_ranges.iter().flat_map(|(min, max)| {
        // panics if min > max
        if min > max {
            panic!("min ({min:?}) > max ({max:?})");
        }
        vec![min.clone(), max.clone()]
    });

    let value_ranges = ScalarValue::iter_to_array(value_ranges_iter)?;

    // rank it
    let ranks = rank(&*value_ranges, None)?;

    // check overlap by checking if the max is rank right behind its corresponding min
    //  . non-overlap example: values of min-max pairs [3, 5,   9, 12,   1, 1,   6, 8]
    //     ranks:  [3, 4,   7, 8,  2, 2,  5, 6] : max (even index) = its correspnding min (odd index) for same min max OR min + 1
    //  . overlap example:  [3, 5,   9, 12,   1, 1,   4, 6] : pair [3, 5] interleaves with pair [4, 6]
    //     ranks:  [3, 5,   7, 8,  2, 2,  4, 6]
    for i in (0..ranks.len()).step_by(2) {
        if !((ranks[i] == ranks[i + 1]) || (ranks[i + 1] == ranks[i] + 1)) {
            return Ok(true);
        }

View on GitHub (pinned to 06200ef96b)