{"record":{"id":"b9b05a12a2439403","repo":"influxdata/influxdb","slug":"no-record-batches-to-convert","errorCode":null,"errorMessage":"no record batches to convert","messagePattern":"no record batches to convert","errorType":"error_code","errorClass":"CodecError","httpStatus":null,"severity":"error","filePath":"core/parquet_file/src/serialize.rs","lineNumber":56,"sourceCode":"use crate::{\n    metadata::{IoxMetadata, METADATA_KEY},\n    storage::ParquetUploadInput,\n    writer::TrackedMemoryArrowWriter,\n};\n\n/// Parquet row group write size\npub const ROW_GROUP_WRITE_SIZE: usize = 1024 * 1024;\n\n/// ensure read and write work well together\nconst _: () = assert!(ROW_GROUP_WRITE_SIZE.is_multiple_of(BATCH_SIZE));\n\n/// [`RecordBatch`] to Parquet serialisation errors.\n///\n/// [`RecordBatch`]: arrow::record_batch::RecordBatch\n#[derive(Debug, Error)]\npub enum CodecError {\n    /// The result stream contained no batches.\n    #[error(\"no record batches to convert\")]\n    NoRecordBatches,\n\n    /// The result stream contained at least one [`RecordBatch`] and all\n    /// instances yielded by the stream contained 0 rows.\n    ///\n    /// This would result in an empty file being uploaded to object store.\n    ///\n    /// [`RecordBatch`]: arrow::record_batch::RecordBatch\n    #[error(\"no rows to serialise\")]\n    NoRows,\n\n    /// A DataFusion error during the plan execution.\n    ///\n    /// Of note: a ResourcesExhaused error likely means the buffer\n    /// used for parquet data became too large.\n    #[error(transparent)]\n    DataFusion(Box<DataFusionError>),\n","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/parquet_file/src/serialize.rs#L38-L74","documentation":"CodecError::NoRecordBatches, raised during RecordBatch-to-Parquet serialisation when the result stream yielded zero batches. The library refuses to write a Parquet file because there is nothing to encode, and a subsequent upload would be meaningless. Doc comment: 'The result stream contained no batches.'","triggerScenarios":"Executing a query plan whose stream completes without ever yielding a RecordBatch and then passing that stream to the Parquet serialisation/upload path.","commonSituations":"Queries with filters matching no data combined with upstream logic that skips empty batches entirely; a plan that short-circuits (EmptyRelation) so the stream is empty from the start; wiring bugs where the wrong stream is fed to the writer.","solutions":["Check why the DataFusion plan produced no batches (inspect the logical/physical plan and predicates)","Handle the empty-input case in the caller before invoking serialisation, e.g. skip writing or write an explicit empty sentinel","Fix stream wiring so the correct batch stream is passed to the Parquet writer","If empty results are legitimate, avoid the parquet upload path for them"],"exampleFix":"// before\nlet batches: Vec<RecordBatch> = stream.try_collect().await?;\nwrite_parquet(batches.into_iter())?;\n// after\nlet batches: Vec<RecordBatch> = stream.try_collect().await?;\nif batches.is_empty() {\n    return Ok(None); // skip writing an empty file\n}\nwrite_parquet(batches.into_iter())?;","handlingStrategy":"try-catch","validationCode":"let batches: Vec<RecordBatch> = stream.try_collect().await?;\nif batches.is_empty() {\n    return Ok(None); // nothing to serialise\n}","typeGuard":null,"tryCatchPattern":"match res {\n    Err(CodecError::NoRecordBatches) => info!(\"query produced no batches; skipping parquet write\"),\n    other => other?,\n}","preventionTips":["Always materialise or count the stream before invoking serialisation","Log empty query results so silent no-data plans are noticed","Assert the correct stream is wired to the writer in pipeline tests"],"tags":["parquet","empty-input","record-batch","serialization"],"backgroundTag":"empty-result-set","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"}