{"record":{"id":"e318d3beb39692df","repo":"influxdata/influxdb","slug":"missing-influxql-metadata","errorCode":null,"errorMessage":"Missing InfluxQL metadata","messagePattern":"Missing InfluxQL metadata","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"core/influxdb_iox_client/src/format/influxql.rs","lineNumber":20,"sourceCode":"use arrow::datatypes::DataType;\nuse arrow::error::ArrowError;\nuse arrow::record_batch::RecordBatch;\nuse arrow::util::display::ArrayFormatter;\nuse comfy_table::{Cell, Table};\nuse generated_types::influxdata::iox::querier::v1::InfluxQlMetadata;\nuse std::io::Write;\nuse std::iter;\nuse thiserror::Error;\n\n/// Error type for results formatting\n#[derive(Debug, Error)]\npub enum Error {\n    /// Arrow error.\n    #[error(\"Arrow error: {}\", .0)]\n    Arrow(ArrowError),\n\n    /// [`InfluxQlMetadata`] not found in Arrow schema metadata.\n    #[error(\"Missing InfluxQL metadata\")]\n    MissingMetadata,\n\n    /// Error deserializing [`InfluxQlMetadata`] from Arrow schema metadata.\n    #[error(\"Invalid InfluxQL metadata: {0}\")]\n    InvalidMetadata(#[from] serde_json::Error),\n\n    /// Error writing formatted output.\n    #[error(\"Error writing output: {0}\")]\n    Write(#[from] std::io::Error),\n}\ntype Result<T, E = Error> = std::result::Result<T, E>;\n\n/// Options for controlling how table borders are rendered.\n#[derive(Debug, Default, Clone, Copy)]\npub enum TableBorders {\n    /// Use ASCII characters.\n    #[default]\n    Ascii,","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/influxdb_iox_client/src/format/influxql.rs#L2-L38","documentation":"Error::MissingMetadata is thrown when the Arrow schema of a query result does not contain the InfluxQlMetadata key in its metadata map. The InfluxQL formatter relies on this metadata to know measurement names, tag keys, and field keys so it can render results as line protocol; without it, formatting cannot proceed.","triggerScenarios":"Calling format::influxql::Formatter::format (or new) on RecordBatches whose SchemaRef.metadata lacks the InfluxQlMetadata key — typically batches obtained from a non-InfluxQL endpoint, from the flight/sql path, or hand-constructed batches.","commonSituations":"Pointing the client at a server that does not annotate InfluxQL results (wrong endpoint, e.g., SQL query API instead of the InfluxQL query API); constructing test batches manually without inserting the metadata; using an older IOx server that predates the metadata annotation.","solutions":["Ensure the query is sent to the InfluxQL query endpoint so the server annotates the Arrow schema with InfluxQlMetadata","Check the returned schema metadata keys (batch.schema().metadata()) to confirm the InfluxQlMetadata entry is present","If constructing batches in tests, serialize an InfluxQlMetadata as JSON and insert it under the expected metadata key before formatting","Upgrade the InfluxDB IOx server/client pair so both agree on the metadata convention"],"exampleFix":"// before\nlet batches = client.query_sql(\"SELECT * FROM cpu\").await?;\nlet out = influxql_formatter.format(&batches)?; // MissingMetadata\n// after\nlet batches = client.query_influxql(\"SELECT * FROM cpu\").await?;\nassert!(batches[0].schema().metadata().contains_key(\"iox::influxql::v1\"));\nlet out = influxql_formatter.format(&batches)?;","handlingStrategy":"validation","validationCode":"const IOX_INFLUXQL_KEY: &str = \"iox::influxql::v1\";\nfn has_influxql_metadata(batches: &[RecordBatch]) -> bool {\n    batches.first()\n        .map(|b| b.schema().metadata().contains_key(IOX_INFLUXQL_KEY))\n        .unwrap_or(false)\n}","typeGuard":"fn is_missing_metadata(e: &influxql_format::Error) -> bool {\n    matches!(e, influxql_format::Error::MissingMetadata)\n}","tryCatchPattern":null,"preventionTips":["Use the InfluxQL query endpoint, not the SQL one, when formatting as InfluxQL","Check schema metadata keys before selecting the influxql formatter","Keep client and IOx server versions in sync"],"tags":["arrow","metadata","influxql"],"backgroundTag":"missing-required-config-field","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"}