{"record":{"id":"f4c6e9d7290e1ca2","repo":"influxdata/influxdb","slug":"arrow-csv-printing-error","errorCode":null,"errorMessage":"Arrow csv printing error: {}","messagePattern":"Arrow csv printing error: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"core/influxdb_iox_client/src/format.rs","lineNumber":26,"sourceCode":"    self, csv::WriterBuilder, error::ArrowError, json::ArrayWriter, record_batch::RecordBatch,\n};\n\n/// Output formatting for InfluxQL.\npub mod influxql;\n\n/// Error type for results formatting\n#[derive(Debug, Error)]\npub enum Error {\n    /// Unknown formatting type\n    #[error(\"Unknown format type: {}. Expected one of 'pretty', 'csv' or 'json'\", .0)]\n    Invalid(String),\n\n    /// Error pretty printing\n    #[error(\"Arrow pretty printing error: {}\", .0)]\n    PrettyArrow(ArrowError),\n\n    /// Error during CSV conversion\n    #[error(\"Arrow csv printing error: {}\", .0)]\n    CsvArrow(ArrowError),\n\n    /// Error during JSON conversion\n    #[error(\"Arrow json printing error: {}\", .0)]\n    JsonArrow(ArrowError),\n\n    /// Error converting CSV output to utf-8\n    #[error(\"Error converting CSV output to UTF-8: {}\", .0)]\n    CsvUtf8(std::string::FromUtf8Error),\n\n    /// Error converting JSON output to utf-8\n    #[error(\"Error converting JSON output to UTF-8: {}\", .0)]\n    JsonUtf8(std::string::FromUtf8Error),\n}\ntype Result<T, E = Error> = std::result::Result<T, E>;\n\n#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]\n/// Requested output format for the query endpoint","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/influxdb_iox_client/src/format.rs#L8-L44","documentation":"This error is returned when converting query results to CSV fails inside the arrow CSV writer (`arrow::csv::writer`). The underlying ArrowError is wrapped verbatim and shown after 'Arrow csv printing error: '. It indicates the RecordBatches could not be serialized to CSV by arrow.","triggerScenarios":"Calling the client's format function with Format::Csv on batches containing column types the arrow CSV writer cannot serialize (e.g. nested list/struct types).","commonSituations":"Exporting query results with nested or dictionary columns to CSV; arrow version differences in supported CSV writer types.","solutions":["Read the wrapped ArrowError detail for the offending column/type.","Cast unsupported nested columns to strings before CSV export.","Use JSON output format instead, which supports nested types.","Ensure arrow crate versions are consistent between your code and the client."],"exampleFix":"// before\nlet csv = result.format(format::Format::Csv)?;\n// after\nlet csv = match result.format(format::Format::Csv) {\n    Ok(c) => c,\n    Err(format::Error::CsvArrow(e)) => {\n        eprintln!(\"csv failed ({e}); using json\");\n        result.format(format::Format::Json)?\n    }\n};","handlingStrategy":"try-catch","validationCode":"// Rust: reject nested types the arrow CSV writer cannot serialize\nfn csv_writable(schema: &SchemaRef) -> bool {\n    schema.fields().iter().all(|f| {\n        !matches!(f.data_type(), DataType::List(_) | DataType::Struct(_) | DataType::Dictionary(_, _))\n    })\n}","typeGuard":"fn is_csv_arrow_err(e: &format::Error) -> Option<&ArrowError> {\n    match e { format::Error::CsvArrow(a) => Some(a), _ => None }\n}","tryCatchPattern":"match result.format(format::Format::Csv) {\n    Ok(c) => use_csv(c),\n    Err(format::Error::CsvArrow(e)) => eprintln!(\"csv write failed: {e}\"),\n    Err(e) => eprintln!(\"other format error: {e}\"),\n}","preventionTips":["Flatten or stringify nested columns before CSV export","Check arrow's supported CSV writer datatypes for your version","Offer JSON as a fallback export format"],"tags":["arrow","csv","formatting"],"backgroundTag":"unsupported-dtype","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"}