{"record":{"id":"75c444229d8bdafc","repo":"influxdata/influxdb","slug":"error-creating-record-batch-0","errorCode":null,"errorMessage":"Error creating record batch: {0}","messagePattern":"Error creating record batch: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"influxdb3_write/src/write_buffer/table_buffer.rs","lineNumber":32,"sourceCode":"use influxdb3_catalog::catalog::{TableDefinition, legacy};\nuse influxdb3_id::ColumnId;\nuse influxdb3_wal::{FieldData, Row};\nuse schema::{InfluxColumnType, InfluxFieldType, Schema, SchemaBuilder};\nuse std::collections::BTreeMap;\nuse std::collections::btree_map::Entry;\nuse std::mem::size_of;\nuse std::ops::Range;\nuse std::sync::Arc;\nuse thiserror::Error;\n\nuse crate::ChunkFilter;\n\n#[derive(Debug, Error)]\npub enum Error {\n    #[error(\"Field not found in table buffer: {0}\")]\n    FieldNotFound(String),\n\n    #[error(\"Error creating record batch: {0}\")]\n    RecordBatchError(#[from] arrow::error::ArrowError),\n\n    #[error(\"row range {start}..{end} is out of bounds for a chunk of {row_count} rows\")]\n    RowRangeOutOfBounds {\n        start: usize,\n        end: usize,\n        row_count: usize,\n    },\n}\n\npub(crate) type Result<T, E = Error> = std::result::Result<T, E>;\n\n#[derive(Default)]\npub struct TableBuffer {\n    chunk_time_to_chunks: BTreeMap<i64, ChunkTimeBuffer>,\n    snapshotting_chunks: Vec<SnapshotChunk>,\n}\n","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_write/src/write_buffer/table_buffer.rs#L14-L50","documentation":"This is a wrapping error: the table buffer wraps any arrow::error::ArrowError raised while constructing an Arrow RecordBatch from the buffered columns. It means the underlying Arrow builder failed — e.g. column length mismatch, schema/data-type mismatch, or an invalid conversion — not a problem with the buffer lookup itself.","triggerScenarios":"Calling any TableBuffer path that calls RecordBatch::try_new (or an equivalent builder) with columns that do not conform to the buffer's schema: mismatched array lengths, wrong Arrow DataType for a field, null-buffer inconsistencies, or an Arrow compute/conversion failure during batch assembly.","commonSituations":"A field written with an inconsistent type (e.g. mixed integer/float) after a schema change; arrays truncated or grown unevenly; upgrading the arrow-rs crate version introduces stricter validation in RecordBatch::try_new; corrupted buffered data after a failed flush.","solutions":["Read the inner ArrowError message (it is embedded in this error's Display) to see which column/constraint failed.","Verify all column arrays have exactly the same length as the row count and match the schema's DataTypes field-for-field.","Check for mixed-type writes to the same field (Line Protocol allows re-typing a field) and normalize types before buffering.","If it appeared after an arrow-rs version bump, review the changelog for new RecordBatch validation rules and update column construction accordingly."],"exampleFix":"// before\nlet batch = RecordBatch::try_new(schema, cols).map_err(Error::RecordBatchError)?;\n\n// after\nassert_eq!(cols.iter().map(|c| c.len()).collect::<std::collections::HashSet<_>>().len(), 1);\nlet batch = RecordBatch::try_new(schema, cols).map_err(|e| {\n    Error::RecordBatchError(arrow::error::ArrowError::InvalidArgumentError(format!(\n        \"batch build failed: {e}\")))\n})?;","handlingStrategy":"try-catch","validationCode":"// pre-validate columns against the schema before RecordBatch::try_new\nfor (field, col) in schema.fields().iter().zip(cols.iter()) {\n    assert_eq!(field.data_type(), col.data_type(), \"column {} type mismatch\", field.name());\n    assert_eq!(col.len(), expected_rows, \"column {} length mismatch\", field.name());\n}","typeGuard":"fn columns_match_schema(schema: &arrow::datatypes::Schema, cols: &[arrow::array::ArrayRef]) -> bool {\n    schema.fields().len() == cols.len()\n        && schema.fields().iter().zip(cols).all(|(f, c)| f.data_type() == c.data_type() && f.len() == c.len())\n}","tryCatchPattern":"match buffer.to_record_batch() {\n    Ok(batch) => process(batch),\n    Err(Error::RecordBatchError(inner)) => {\n        log::error(\"arrow failed building batch: {inner}\");\n        // inspect inner ArrowError variant to find the offending column\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Keep a single typed write path per field so Arrow DataTypes stay consistent across rows.","Assert equal array lengths across all columns before batch construction.","Pin and test against your arrow-rs version; re-run batch-building tests when upgrading Arrow."],"tags":["rust","arrow","record-batch","schema"],"backgroundTag":"schema-validation-failed","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"}