influxdata/influxdb · error · ProjectionError

Type mismatch, expected

Error message

Type mismatch, expected {expected:?} but got {actual:?}

What it means

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.

Solutions

  1. Align the expected schema with the file's actual column types before projecting
  2. Cast the file's column to the expected type during the read plan
  3. Re-write or migrate the parquet file to the current schema

Example fix

// before
let batch = project(file, expected_schema)?;
// after
let batch = if file_schema.field(name).data_type() != expected.data_type() {
    cast_column(file, name, expected.data_type())?
} else {
    project(file, expected_schema)?
};
Defensive patterns

Strategy: validation

Validate before calling

for f in expected.fields.iter() {
    if let Some(ff) = file_schema.field_with_name(f.name()).ok() {
        if ff.data_type() != f.data_type() { return Err(format!("{}: {:?} vs {:?}", f.name(), f.data_type(), ff.data_type())); }
    }
}

Try / catch

match project(&file, &expected) {
    Err(ProjectionError::FieldTypeMismatch { expected, actual }) => handle_type_mismatch(expected, actual),
    Err(e) => return Err(e.into()),
    Ok(b) => b,
}

Prevention

When it happens

Trigger: Projecting a parquet file whose column type does not match the expected schema's column type for a same-named field.

Common situations: 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.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


AI-assisted analysis of influxdata/influxdb@06200ef96b (2026-09-19). Data as JSON: /api/errors/9d6df7008fe27090. Report an issue: GitHub.

Appendix: source

Thrown at core/parquet_file/src/storage.rs:449

                // we don't care about the "last modified" field
                last_modified: Default::default(),
                size: file_size,
                e_tag: None,
                version: None,
            },
        }
    }
}

/// Error during projecting parquet file data to an expected schema.
#[derive(Debug, Error)]
pub enum ProjectionError {
    /// Unknown field.
    #[error("Unknown field: {0}")]
    UnknownField(String),

    /// Field type mismatch
    #[error("Type mismatch, expected {expected:?} but got {actual:?}")]
    FieldTypeMismatch {
        /// Expected field.
        expected: Field,

        /// Actual field.
        actual: Field,
    },
}

#[cfg(test)]
mod tests {
    use super::*;
    use arrow::{
        array::{ArrayRef, Int64Array, StringArray},
        datatypes::{DataType, Schema},
        record_batch::RecordBatch,
    };
    use data_types::{

View on GitHub (pinned to 06200ef96b)