{"record":{"id":"f07c4e94def6f70e","repo":"influxdata/influxdb","slug":"error-while-executing-plan-0","errorCode":null,"errorMessage":"error while executing plan: {0}","messagePattern":"error while executing plan: (.+?)","errorType":"exception","errorClass":"QueryExecutorError","httpStatus":null,"severity":"error","filePath":"influxdb3_internal_api/src/query_executor.rs","lineNumber":29,"sourceCode":"use iox_query::{QueryDatabase, QueryNamespace};\nuse iox_query_influxql::show_databases::{InfluxQlShowDatabases, generate_metadata};\nuse 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> {","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_internal_api/src/query_executor.rs#L11-L47","documentation":"This error is a variant of QueryExecutorError in influxdb3's internal query executor. It wraps a DataFusion error raised while streaming results of an already-planned query. It fires after planning succeeded but the physical plan failed during execution (e.g. reading a table, evaluating expressions, or streaming batches).","triggerScenarios":"Calling the query executor's execute/stream method on a plan whose DataFusion execution fails mid-stream: partition/file open errors, schema mismatch at execution time, unsupported execution path, or an internal DataFusion panic converted to an error.","commonSituations":"Querying a database whose underlying Parquet/segment files are corrupted or missing; a DataFusion version upgrade changing plan behavior; querying with expressions valid at plan time but failing on actual data (e.g. casting invalid UTF-8 or overflow).","solutions":["Log the wrapped DataFusionError source (inspect err.source()) to get the underlying execution failure","Verify the queried database and table data files are intact and readable by the server","Re-run the query with a simpler form to isolate which expression/operator fails","Pin or upgrade DataFusion/influxdb3 to a version where the execution bug is fixed"],"exampleFix":"// before\nlet batches = executor.execute(&plan).await?; // opaque failure\n// after\nlet batches = executor.execute(&plan).await.map_err(|e| {\n    eprintln!(\"execute failed: {e}; source: {:?}\", std::error::Error::source(&e));\n    e\n})?;","handlingStrategy":"try-catch","validationCode":"// before executing\nif !catalog.database_exists(db_name) {\n    return Err(format!(\"database {db_name} does not exist\"));\n}","typeGuard":"fn is_execute_stream_err(e: &QueryExecutorError) -> Option<&DataFusionError> {\n    if let QueryExecutorError::ExecuteStream(df) = e { Some(df) } else { None }\n}","tryCatchPattern":"match executor.execute(&plan).await {\n    Ok(stream) => stream,\n    Err(QueryExecutorError::ExecuteStream(df)) => {\n        log::error!(\"plan execution failed: {df}\");\n        return Err(QueryExecutorError::ExecuteStream(df));\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Validate database and table names against the catalog before querying","Keep data files healthy and monitor for segment/Parquet corruption","Test queries after DataFusion version upgrades","Log error chains (source()) to speed diagnosis"],"tags":["rust","datafusion","query-execution","streaming"],"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"}