{"record":{"id":"86c860c7022238d1","repo":"influxdata/influxdb","slug":"error-in-influxql-statement-0","errorCode":null,"errorMessage":"error in InfluxQL statement: {0}","messagePattern":"error in InfluxQL statement: (.+?)","errorType":"http","errorClass":"Error::InfluxqlRewrite","httpStatus":null,"severity":"error","filePath":"core/iox_v1_query_api/src/error.rs","lineNumber":52,"sourceCode":"\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 },\n\n    #[error(\n        \"provided a retention policy in both the parameters ({param_rp}) and \\","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/iox_v1_query_api/src/error.rs#L34-L70","documentation":"This error wraps `rewrite::Error` produced while rewriting/validating an InfluxQL statement before execution. The v1 query API rewrites incoming InfluxQL (e.g. resolving databases, retention policies); a failure in that rewrite step is reported as an InfluxQL statement error. It signals the statement text could not be processed into an executable form.","triggerScenarios":"POST to the v1 /query endpoint with an InfluxQL statement that the rewrite crate fails to parse/rewrite, e.g. syntactically invalid InfluxQL or unsupported constructs requiring rewriting.","commonSituations":"Typos in InfluxQL keywords; unsupported syntax (rare clauses not handled by the rewriter); queries produced programmatically with malformed tokens.","solutions":["Read the wrapped rewrite::Error ({0}) for the exact parse/rewrite failure.","Validate the InfluxQL statement syntax against supported InfluxQL grammar.","Test the statement in a known-good client (e.g. InfluxDB 1.x CLI) to confirm validity.","Split complex queries into simpler statements to isolate the failing clause."],"exampleFix":"// before\n{\"q\": \"SELCT * FROM m\"}\n// after\n{\"q\": \"SELECT * FROM m\"}","handlingStrategy":"validation","validationCode":"const stmt = q.trim().replace(/;$/, '');\nif (!/^(SELECT|SHOW|CREATE|DROP)\\b/i.test(stmt)) {\n  throw new Error(`possibly invalid InfluxQL statement: ${stmt}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await queryV1({ q });\n} catch (e) {\n  if (/error in InfluxQL statement/.test(e.message)) {\n    console.error('InfluxQL rewrite failed:', e.message);\n  } else {\n    throw e;\n  }\n}","preventionTips":["Lint InfluxQL statements before sending them.","Test statements with a known-good InfluxDB 1.x parser.","Avoid rare/unsupported clauses in generated queries."],"tags":["influxql","query","parse-error","rewrite"],"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"}