{"record":{"id":"0f4fcfe022755f0d","repo":"influxdata/influxdb","slug":"unable-to-compose-record-batches-from-databases-0","errorCode":null,"errorMessage":"unable to compose record batches from databases: {0}","messagePattern":"unable to compose record batches from databases: (.+?)","errorType":"exception","errorClass":"QueryExecutorError","httpStatus":null,"severity":"error","filePath":"influxdb3_internal_api/src/query_executor.rs","lineNumber":31,"sourceCode":"use iox_query_influxql::show_retention_policies::InfluxQlShowRetentionPolicies;\nuse iox_query_params::StatementParams;\nuse schema::INFLUXQL_MEASUREMENT_COLUMN_NAME;\nuse std::fmt::Debug;\nuse std::sync::Arc;\nuse trace::ctx::SpanContext;\nuse trace::span::{Span, SpanExt};\nuse trace_http::ctx::RequestLogContext;\nuse tracker::InstrumentedAsyncOwnedSemaphorePermit;\n\n#[derive(Debug, thiserror::Error)]\npub enum QueryExecutorError {\n    #[error(\"database not found: {db_name}\")]\n    DatabaseNotFound { db_name: String },\n    #[error(\"error while planning query: {0}\")]\n    QueryPlanning(#[source] DataFusionError),\n    #[error(\"error while executing plan: {0}\")]\n    ExecuteStream(#[source] DataFusionError),\n    #[error(\"unable to compose record batches from databases: {0}\")]\n    DatabasesToRecordBatch(#[source] ArrowError),\n    #[error(\"unable to compose record batches from retention policies: {0}\")]\n    RetentionPoliciesToRecordBatch(#[source] ArrowError),\n    #[error(\"invokded a method that is not implemented: {0}\")]\n    MethodNotImplemented(&'static str),\n    #[error(transparent)]\n    Anyhow(#[from] anyhow::Error),\n}\n\n#[async_trait]\npub trait QueryExecutor: QueryDatabase + Debug + Send + Sync + 'static {\n    async fn get_db_namespace(\n        &self,\n        database_name: &str,\n        span_ctx: &Option<SpanContext>,\n    ) -> Result<Arc<dyn QueryNamespace>, QueryExecutorError> {\n        self.namespace(\n            database_name,","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_internal_api/src/query_executor.rs#L13-L49","documentation":"This QueryExecutorError::DatabasesToRecordBatch variant wraps an ArrowError raised while converting queried database data into Arrow RecordBatches. The executor built result batches across databases and Arrow rejected the operation (schema merge, construction, or concat failure).","triggerScenarios":"Executing a query spanning multiple databases whose resulting schemas cannot be unified into record batches; mismatched column types or field nullability when composing batches.","commonSituations":"Databases with drifted schemas for the same table name (a column changed type between databases); querying across databases after a migration changed field types; empty vs non-empty batch schema conflicts.","solutions":["Check that queried databases have compatible table schemas (same column names and Arrow types)","Run queries against a single database to identify which one's schema breaks composition","Fix schema drift by migrating the offending table's column types","Log the wrapped ArrowError to identify the exact field/type conflict"],"exampleFix":"// before\n// SELECT * FROM db1.meas, db2.meas — type mismatch on 'value'\n// after\n// align schemas first:\n// ALTER TABLE db2.meas ALTER COLUMN value SET DATA TYPE FLOAT64;","handlingStrategy":"try-catch","validationCode":"// verify schema compatibility before cross-database composition\nlet schemas = dbs.iter().map(|db| get_table_schema(db, table)).collect::<Result<Vec<_>,_>>()?;\nlet first = &schemas[0];\nfor s in &schemas[1..] {\n    assert_eq!(s.fields(), first.fields(), \"schema drift across databases\");\n}","typeGuard":"fn is_batch_compose_err(e: &QueryExecutorError) -> Option<&ArrowError> {\n    if let QueryExecutorError::DatabasesToRecordBatch(ae) = e { Some(ae) } else { None }\n}","tryCatchPattern":"match executor.databases_to_record_batch(&dbs) {\n    Ok(batches) => batches,\n    Err(QueryExecutorError::DatabasesToRecordBatch(ae)) => {\n        log::error!(\"arrow batch composition failed: {ae}\");\n        Err(QueryExecutorError::DatabasesToRecordBatch(ae))\n    }\n    Err(e) => Err(e),\n}","preventionTips":["Keep table schemas identical across databases that are queried together","Run schema-drift checks after migrations","Compose single-database results when schemas may differ","Surface ArrowError details in logs"],"tags":["rust","arrow","schema","record-batch"],"backgroundTag":"database-query-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"}