pola-rs/polars · error

All Dictionary types have `dict_id`

Error message

All Dictionary types have `dict_id`

What it means

serialize_field asserts (via expect) that every Dictionary dtype carries a dict_id when converting Arrow fields to IPC fields. The panic fires when a dictionary field's IPC metadata lacks a dictionary id — usually a schema produced outside the normal IPC write path.

Solutions

  1. Ensure ipc_field.dictionary_id is populated for dictionary-typed fields before serializing
  2. Construct the IpcField tree with the same shape and ordering as the Arrow schema
  3. Avoid hand-building IpcSchema/IpcField metadata for dictionary columns
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/polars-arrow/src/io/ipc/write/schema.rs:143 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/f0906e9e1f7bb2f1. Report an issue: GitHub.

Appendix: source

Thrown at crates/polars-arrow/src/io/ipc/write/schema.rs:143

    let type_ = serialize_type(field.dtype());
    let children = serialize_children(field.dtype(), ipc_field);

    let dictionary = if let ArrowDataType::Dictionary(index_type, inner, is_ordered) =
        field.dtype().to_storage()
    {
        if let ArrowDataType::Extension(ext) = inner.as_ref() {
            write_extension(
                ext.name.as_str(),
                ext.metadata.as_ref().map(|x| x.as_str()),
                &mut kv_vec,
            );
        }
        Some(serialize_dictionary(
            index_type,
            ipc_field
                .dictionary_id
                .expect("All Dictionary types have `dict_id`"),
            *is_ordered,
        ))
    } else {
        None
    };

    if let Some(metadata) = &field.metadata {
        write_metadata(metadata, &mut kv_vec);
    }

    let custom_metadata = if !kv_vec.is_empty() {
        Some(kv_vec)
    } else {
        None
    };

    polars_arrow_format::ipc::Field {
        name: Some(field.name.to_string()),

View on GitHub (pinned to fe841f959e)