{"record":{"id":"9d6df7008fe27090","repo":"influxdata/influxdb","slug":"type-mismatch-expected-expected-but-got-actual","errorCode":null,"errorMessage":"Type mismatch, expected {expected:?} but got {actual:?}","messagePattern":"Type mismatch, expected (.+?) but got (.+?)","errorType":"error_code","errorClass":"ProjectionError","httpStatus":null,"severity":"error","filePath":"core/parquet_file/src/storage.rs","lineNumber":449,"sourceCode":"                // we don't care about the \"last modified\" field\n                last_modified: Default::default(),\n                size: file_size,\n                e_tag: None,\n                version: None,\n            },\n        }\n    }\n}\n\n/// Error during projecting parquet file data to an expected schema.\n#[derive(Debug, Error)]\npub enum ProjectionError {\n    /// Unknown field.\n    #[error(\"Unknown field: {0}\")]\n    UnknownField(String),\n\n    /// Field type mismatch\n    #[error(\"Type mismatch, expected {expected:?} but got {actual:?}\")]\n    FieldTypeMismatch {\n        /// Expected field.\n        expected: Field,\n\n        /// Actual field.\n        actual: Field,\n    },\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n    use arrow::{\n        array::{ArrayRef, Int64Array, StringArray},\n        datatypes::{DataType, Schema},\n        record_batch::RecordBatch,\n    };\n    use data_types::{","sourceCodeStart":431,"sourceCodeEnd":467,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/parquet_file/src/storage.rs#L431-L467","documentation":"ProjectionError::FieldTypeMismatch is raised when a field exists in both the parquet file schema and the expected schema but its arrow type differs (e.g. Utf8 vs Int64). It carries the expected and actual arrow Fields.","triggerScenarios":"Projecting a parquet file whose column type does not match the expected schema's column type for a same-named field.","commonSituations":"A column's type changed between schema versions; comparing files written by different writers or writer versions; case-insensitive name matching picking the wrong column type.","solutions":["Align the expected schema with the file's actual column types before projecting","Cast the file's column to the expected type during the read plan","Re-write or migrate the parquet file to the current schema"],"exampleFix":"// before\nlet batch = project(file, expected_schema)?;\n// after\nlet batch = if file_schema.field(name).data_type() != expected.data_type() {\n    cast_column(file, name, expected.data_type())?\n} else {\n    project(file, expected_schema)?\n};","handlingStrategy":"validation","validationCode":"for f in expected.fields.iter() {\n    if let Some(ff) = file_schema.field_with_name(f.name()).ok() {\n        if ff.data_type() != f.data_type() { return Err(format!(\"{}: {:?} vs {:?}\", f.name(), f.data_type(), ff.data_type())); }\n    }\n}","typeGuard":null,"tryCatchPattern":"match project(&file, &expected) {\n    Err(ProjectionError::FieldTypeMismatch { expected, actual }) => handle_type_mismatch(expected, actual),\n    Err(e) => return Err(e.into()),\n    Ok(b) => b,\n}","preventionTips":["Compare column types between file and expected schema before reading","Plan casts for known type drift between schema versions"],"tags":["parquet","schema","type-mismatch"],"backgroundTag":"type-mismatch","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"}