{"record":{"id":"825e048fb67bde5a","repo":"influxdata/influxdb","slug":"key-column-name-of-current-batch-has-no-data","errorCode":null,"errorMessage":"Key column, {name}, of current batch has no data","messagePattern":"Key column, (.+?), of current batch has no data","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/iox_query/src/provider/deduplicate/algo.rs","lineNumber":144,"sourceCode":"                        options: skey.options,\n                    }\n                })\n                .collect::<Vec<_>>();\n\n            // Build sorted columns for current batch\n            // Schema of both batches are the same\n            let batch_key_columns = self\n                .sort_keys\n                .iter()\n                .map(|skey| {\n                    // figure out the index of the key columns\n                    let name = get_col_name(skey.expr.as_ref());\n                    let index = schema.index_of(name).unwrap();\n\n                    // Key column of current batch of this index\n                    let array = batch.column(index);\n                    if array.is_empty() {\n                        panic!(\"Key column, {name}, of current batch has no data\");\n                    }\n                    DedupSortColumn {\n                        array,\n                        options: skey.options,\n                    }\n                })\n                .collect::<Vec<_>>();\n\n            // Zip the 2 key sets of columns for comparison\n            let zipped = last_batch_key_columns.iter().zip(batch_key_columns.iter());\n\n            // Compare sort keys of the first row of the given batch the the last_batch\n            // Note that the batches are sorted and all rows of last_batch have the same sort keys so\n            // only need to compare last row of the last_batch with the first row of the current batch\n            let mut same = true;\n            for (l, r) in zipped {\n                let last_idx = l.array.len() - 1;\n                let c = arrow::array::make_comparator(l.array, r.array, l.options)?;","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/iox_query/src/provider/deduplicate/algo.rs#L126-L162","documentation":"During deduplication, each incoming batch's sort-key column is extracted for comparison; if the key column array in the current batch is empty (zero rows), the algorithm cannot compare against the last batch and panics naming the column.","triggerScenarios":"Calling deduplicate where any batch in the input has zero rows for a declared sort-key column, even though other columns may have data.","commonSituations":"Projection or dictionary-wrapping upstream producing empty key arrays; malformed batches constructed in tests; schema/batch mismatch after a column was dropped from data but not from the sort key spec.","solutions":["Drop zero-row batches from the input before deduplicate.","Verify the sort key expressions match actual populated columns in every batch.","Check upstream projections that may have emptied the key column and fix the projection list.","In fork maintenance, convert this panic into a descriptive DataFusionError."],"exampleFix":"// before\nlet result = deduplicate(&all_batches, &sort_key)?;\n// after\nassert!(all_batches.iter().all(|b| b.num_rows() > 0), \"empty batch in dedup input\");\nlet result = deduplicate(&all_batches, &sort_key)?;","handlingStrategy":"validation","validationCode":"for b in &batches {\n    for name in key_column_names {\n        let idx = b.schema().index_of(name).unwrap();\n        assert!(b.column(idx).len() > 0, \"key column {name} empty in batch\");\n    }\n}","typeGuard":null,"tryCatchPattern":"// panic-based: pre-check each batch's key columns are non-empty\nassert!(batches.iter().all(|b| key_cols_non_empty(b)));\ndeduplicate(&batches, &sort_key)?;","preventionTips":["Verify sort-key expressions match populated columns in every batch.","Drop empty batches before deduplication.","Check projections include the sort key columns with data."],"tags":["query","deduplicate","panic","record-batch"],"backgroundTag":"empty-required-field","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"}