{"record":{"id":"445433a6e9413ef8","repo":"influxdata/influxdb","slug":"error-while-planning-query-0","errorCode":null,"errorMessage":"error while planning query: {0}","messagePattern":"error while planning query: (.+?)","errorType":"exception","errorClass":"QueryExecutorError","httpStatus":null,"severity":"error","filePath":"influxdb3_internal_api/src/query_executor.rs","lineNumber":27,"sourceCode":"use influxdb3_catalog::catalog::Catalog;\nuse iox_query::query_log::QueryLogEntries;\nuse 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,","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_internal_api/src/query_executor.rs#L9-L45","documentation":"`QueryExecutorError::QueryPlanning` wraps a DataFusionError that occurred while building the DataFusion execution plan for a query. The message is \"error while planning query: {0}\" with the DataFusionError as the `#[source]`.","triggerScenarios":"Invalid SQL (syntax errors, unknown tables/columns, unsupported functions) submitted to the internal query executor; schema conflicts that prevent logical/physical plan construction.","commonSituations":"InfluxQL/SQL features unsupported by the DataFusion version in use; referencing a field/tag that doesn't exist; malformed time-range predicates; version upgrades changing accepted SQL.","solutions":["Read the wrapped DataFusionError in the source chain for the root cause","Validate the SQL syntax and referenced table/column names","Simplify the query (remove unsupported functions) and re-run","Check compatibility of the query with the deployed InfluxDB 3 DataFusion version"],"exampleFix":"// before\nSELECT MEAN(temperature) FROM weather GROUP BY BY(host)  // unsupported clause\n// after\nSELECT host, MEAN(temperature) FROM weather GROUP BY host","handlingStrategy":"try-catch","validationCode":"// validate table/column references before planning\nif !schema.fields.contains(field_name) {\n    return Err(anyhow!(\"unknown field: {field_name}\"));\n}","typeGuard":null,"tryCatchPattern":"// rust\nmatch executor.query(db, sql).await {\n    Err(QueryExecutorError::QueryPlanning(e)) => {\n        eprintln!(\"SQL planning failed: {e}; check syntax and identifiers\")\n    }\n    other => other?,\n}","preventionTips":["Test SQL against a local instance before deployment","Verify table and column names against current schema","Review DataFusion release notes after version upgrades for SQL changes"],"tags":["query","datafusion","planning","sql"],"backgroundTag":"sql-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"}