{"record":{"id":"4c8a9c8c5fb1cf1a","repo":"influxdata/influxdb","slug":"datafusion-error-0","errorCode":null,"errorMessage":"datafusion error: {0}","messagePattern":"datafusion error: (.+?)","errorType":"http","errorClass":"Error::Datafusion","httpStatus":null,"severity":"error","filePath":"core/iox_v1_query_api/src/error.rs","lineNumber":49,"sourceCode":"\n    #[error(\"error decoding multipart file upload: {0}\")]\n    MultipartFile(String),\n\n    #[error(\"Invalid UTF8: {message} {error}\")]\n    Utf8 {\n        message: &'static str,\n        error: String,\n    },\n\n    /// Serde decode error\n    #[error(\"error decoding params from url: {0}\")]\n    SerdeUrlDecoding(#[from] serde_urlencoded::de::Error),\n\n    // SerdeJsonError\n    #[error(\"error decoding query body: {0}\")]\n    SerdeJson(#[from] serde_json::Error),\n\n    #[error(\"datafusion error: {0}\")]\n    Datafusion(#[from] DataFusionError),\n\n    #[error(\"error in InfluxQL statement: {0}\")]\n    InfluxqlRewrite(#[from] rewrite::Error),\n\n    #[error(\"must provide only one InfluxQl statement per query\")]\n    InfluxqlSingleStatement,\n\n    #[error(\"must specify a 'db' parameter, or provide the database in the InfluxQL query\")]\n    InfluxqlNoDatabase,\n\n    #[error(\n        \"provided a database in both the parameters ({param_db}) and \\\n        query string ({query_db}) that do not match, if providing a query \\\n        that specifies the database, you can omit the 'database' parameter \\\n        from your request\"\n    )]\n    InfluxqlDatabaseMismatch { param_db: String, query_db: String },","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/iox_v1_query_api/src/error.rs#L31-L67","documentation":"This error wraps a DataFusionError raised while executing an InfluxQL query in the IOx v1 query API. The v1 endpoint translates InfluxQL into DataFusion plans; any failure during planning or execution surfaces here with the `#[from]` conversion. It indicates the query itself (or the underlying data/schema it touches) failed inside DataFusion.","triggerScenarios":"POST/GET to the v1 /query endpoint where the InfluxQL statement is parsed and planned successfully enough to reach DataFusion, but DataFusion's planner or executor rejects it (e.g. invalid function reference, missing table/schema, type error during execution).","commonSituations":"Querying a measurement (table) that does not exist in the namespace; using InfluxQL functions DataFusion cannot plan; schema mismatches after migration; malformed SHOW queries hitting DataFusion directly.","solutions":["Inspect the wrapped DataFusionError message ({0}) to find the exact failing plan/execution step.","Verify the measurement/table names in the query exist in the target database (SHOW MEASUREMENTS).","Simplify the InfluxQL statement to isolate which clause DataFusion rejects.","Check for unsupported InfluxQL features and rewrite the query using supported syntax."],"exampleFix":"// before\nSELECT mean(temperature) FROM sensor_data GROUP BY invalid_fn(time, 5m)\n// after\nSELECT mean(temperature) FROM sensor_data GROUP BY time(5m)","handlingStrategy":"try-catch","validationCode":"const tables = await listMeasurements(db);\nconst referenced = /FROM\\s+[\"'`]?([\\w.]+)/gi.exec(q);\nif (referenced && !tables.includes(referenced[1].split('.').pop())) {\n  throw new Error(`measurement ${referenced[1]} does not exist in ${db}`);\n}","typeGuard":"function isDatafusionError(e) {\n  return typeof e === 'object' && e !== null && 'message' in e && String(e.message).includes('datafusion error');\n}","tryCatchPattern":"try {\n  await queryV1({ db, q });\n} catch (e) {\n  if (/datafusion error/.test(e.message)) {\n    logDatafusionFailure(e.cause ?? e.message);\n  } else {\n    throw e;\n  }\n}","preventionTips":["Validate measurement/table names exist before querying.","Keep queries within the supported InfluxQL feature set.","Run new queries against a staging database first."],"tags":["query","datafusion","influxql","database"],"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"}