influxdata/influxdb · error · Error::InfluxqlRewrite
error in InfluxQL statement
Error message
error in InfluxQL statement: {0} What it means
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.
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.
Example fix
// before
{"q": "SELCT * FROM m"}
// after
{"q": "SELECT * FROM m"} Defensive patterns
Strategy: validation
Validate before calling
const stmt = q.trim().replace(/;$/, '');
if (!/^(SELECT|SHOW|CREATE|DROP)\b/i.test(stmt)) {
throw new Error(`possibly invalid InfluxQL statement: ${stmt}`);
} Try / catch
try {
await queryV1({ q });
} catch (e) {
if (/error in InfluxQL statement/.test(e.message)) {
console.error('InfluxQL rewrite failed:', e.message);
} else {
throw e;
}
} Prevention
- Lint InfluxQL statements before sending them.
- Test statements with a known-good InfluxDB 1.x parser.
- Avoid rare/unsupported clauses in generated queries.
When it happens
Trigger: 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.
Common situations: Typos in InfluxQL keywords; unsupported syntax (rare clauses not handled by the rewriter); queries produced programmatically with malformed tokens.
Understand the failure class
Background: "query failed", "%w: SQL error" — wrapped database query errors in Go libraries explained — this error's family across 3 libraries.
Related errors
- error in InfluxQL statement
- can only perform queries on a single database
- Database not found
- datafusion error
- must provide only one InfluxQl statement per query
AI-assisted analysis of influxdata/influxdb@06200ef96b (2026-09-19).
Data as JSON: /api/errors/86c860c7022238d1.
Report an issue: GitHub.
Appendix: source
Thrown at core/iox_v1_query_api/src/error.rs:52
#[error("Invalid UTF8: {message} {error}")]
Utf8 {
message: &'static str,
error: String,
},
/// Serde decode error
#[error("error decoding params from url: {0}")]
SerdeUrlDecoding(#[from] serde_urlencoded::de::Error),
// SerdeJsonError
#[error("error decoding query body: {0}")]
SerdeJson(#[from] serde_json::Error),
#[error("datafusion error: {0}")]
Datafusion(#[from] DataFusionError),
#[error("error in InfluxQL statement: {0}")]
InfluxqlRewrite(#[from] rewrite::Error),
#[error("must provide only one InfluxQl statement per query")]
InfluxqlSingleStatement,
#[error("must specify a 'db' parameter, or provide the database in the InfluxQL query")]
InfluxqlNoDatabase,
#[error(
"provided a database in both the parameters ({param_db}) and \
query string ({query_db}) that do not match, if providing a query \
that specifies the database, you can omit the 'database' parameter \
from your request"
)]
InfluxqlDatabaseMismatch { param_db: String, query_db: String },
#[error(
"provided a retention policy in both the parameters ({param_rp}) and \View on GitHub (pinned to 06200ef96b)