{"record":{"id":"85890217a97d1933","repo":"influxdata/influxdb","slug":"should-not-be-absent","errorCode":null,"errorMessage":"should not be absent","messagePattern":"should not be absent","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/iox_query/src/statistics/partition_statistics/fetch.rs","lineNumber":26,"sourceCode":"///\n/// Fetch is the total num of rows fetched, after the skip is applied.\n///\n/// This logic is extracted from [`Statistics::with_fetch`]. Refer to\n/// <https://docs.rs/datafusion-common/47.0.0/src/datafusion_common/stats.rs.html#391-397>.\npub(super) fn apply_fetch(\n    stats: Arc<Statistics>,\n    fetch: Option<usize>,\n    skip: usize,\n) -> Arc<Statistics> {\n    let fetch_applied = match (stats.num_rows, fetch, skip) {\n        (num_rows, None, 0) => num_rows,\n        (Precision::Absent, None, _) => Precision::Absent,\n\n        // absent, but can estimate\n        (Precision::Absent, Some(fetch), _) => Precision::Inexact(fetch),\n\n        // if we are skipping more rows than we have => then 0 output row.\n        (num_rows, _, skip) if skip >= *num_rows.get_value().expect(\"should not be absent\") => {\n            Precision::Exact(0)\n        }\n\n        // have exact, return exact\n        (Precision::Exact(num_rows), fetch, skip) => {\n            let num_rows_remaining = num_rows.saturating_sub(skip);\n            let fetched = std::cmp::min(num_rows_remaining, fetch.unwrap_or(num_rows_remaining));\n            Precision::Exact(fetched)\n        }\n\n        // have inexact, return inexact\n        (Precision::Inexact(num_rows), fetch, skip) => {\n            let num_rows_remaining = num_rows.saturating_sub(skip);\n            let fetched = std::cmp::min(num_rows_remaining, fetch.unwrap_or(num_rows_remaining));\n            Precision::Inexact(fetched)\n        }\n    };\n","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/iox_query/src/statistics/partition_statistics/fetch.rs#L8-L44","documentation":"A panic from `.expect(\"should not be absent\")` in apply_fetch (partition statistics fetch logic). The match arm computing the skip-over-num_rows comparison assumes num_rows carries an exact value, but the pattern matched a Precision that wraps a value that cannot be extracted. It indicates the row-count Precision was in an unexpected state when a Limit/Fetch was applied.","triggerScenarios":"Applying a fetch/skip to partition statistics where the matched num_rows pattern holds a Precision variant whose get_value() returns None — i.e. an Absent or malformed Precision reaching that arm.","commonSituations":"Upstream statistics collection returned Absent for num_rows but a different match arm than expected was taken; partial refactors of the Precision enum; custom TableStatistics providers returning unusual Precision combinations.","solutions":["Ensure upstream statistics always produce a num_rows Precision that wraps a value when a fetch is applied","Update the match guards so Absent num_rows is handled before the skip >= num_rows arm","File a bug with the plan/statistics if this occurs on stock executors"],"exampleFix":"// before\n(num_rows, _, skip) if skip >= *num_rows.get_value().expect(\"should not be absent\") => Precision::Exact(0),\n// after\n(num_rows, _, skip) if num_rows.get_value().map_or(false, |n| skip >= *n) => Precision::Exact(0),","handlingStrategy":"try-catch","validationCode":"assert!(matches!(stats.num_rows, Precision::Exact(_) | Precision::Inexact(_)), \"num_rows must carry a value before applying fetch\");","typeGuard":"fn has_value(p: &Precision<usize>) -> bool { p.get_value().is_some() }","tryCatchPattern":"// pre-check: if num_rows.get_value().is_none() skip the fetch-optimization path","preventionTips":["Only apply fetch optimization when num_rows has a value","Keep Precision match arms exhaustive","Unit-test Limit pushdown against Absent statistics"],"tags":["rust","panic","statistics","limit"],"backgroundTag":"internal-invariant-violation","analyzedSha":"06200ef96ba82c5f6727e5038a83af8e722c6875","analyzedAt":"2026-09-19T12:55:30.003Z","contentChangedAt":"2026-09-19T12:55:30.003Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}