pola-rs/polars · error

Avro maps are mapped to MapArrays

Error message

Avro maps are mapped to MapArrays

What it means

At this point in Avro-to-Arrow schema conversion, a map type is translated into an Arrow MapArray. The error fires when the conversion of an Avro map's value schema returns None or an unexpected variant, breaking the assumption that maps always map to MapArrays.

Solutions

  1. Inspect the Avro schema of the map's values and ensure it is a supported primitive or nested type
  2. Add an explicit match arm for the unsupported Avro value type instead of relying on a fallthrough
  3. Upgrade polars/avro-schema so newer Avro logical types are converted correctly
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/polars-arrow/src/io/avro/read/schema.rs:96 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18). Data as JSON: /api/errors/5bd79e7386535639. Report an issue: GitHub.

Appendix: source

Thrown at crates/polars-arrow/src/io/avro/read/schema.rs:96

            None => ArrowDataType::Int64,
        },
        AvroSchema::Float => ArrowDataType::Float32,
        AvroSchema::Double => ArrowDataType::Float64,
        AvroSchema::Bytes(logical) => match logical {
            Some(logical) => match logical {
                avro_schema::schema::BytesLogical::Decimal(precision, scale) => {
                    ArrowDataType::Decimal(*precision, *scale)
                },
            },
            None => ArrowDataType::Binary,
        },
        AvroSchema::String(_) => ArrowDataType::Utf8,
        AvroSchema::Array(item_schema) => ArrowDataType::List(Box::new(schema_to_field(
            item_schema,
            Some("item"), // default name for list items
            Metadata::default(),
        )?)),
        AvroSchema::Map(_) => todo!("Avro maps are mapped to MapArrays"),
        AvroSchema::Union(schemas) => {
            // If there are only two variants and one of them is null, set the other type as the field data type
            let has_nullable = schemas.iter().any(|x| x == &AvroSchema::Null);
            if has_nullable && schemas.len() == 2 {
                nullable = true;
                if let Some(schema) = schemas
                    .iter()
                    .find(|&schema| !matches!(schema, AvroSchema::Null))
                {
                    schema_to_field(schema, None, Metadata::default())?.dtype
                } else {
                    polars_bail!(nyi = "Can't read avro union {schema:?}");
                }
            } else {
                let fields = schemas
                    .iter()
                    .map(|s| schema_to_field(s, None, Metadata::default()))
                    .collect::<PolarsResult<Vec<Field>>>()?;

View on GitHub (pinned to fe841f959e)