pola-rs/polars · error

not implemented

Error message

not implemented

What it means

serialize_type maps ArrowDataType to the IPC flatbuffer type when writing Feather V2/Arrow IPC files. The Arrow IPC spec defines only YearMonth, DayTime and MonthDayNano interval units; polars' extra MonthDayMillis unit has no wire representation, and its arm (crates/polars-arrow/src/io/ipc/write/schema.rs:279) is unimplemented!(). Writing a dataset containing Interval(MonthDayMillis) panics during schema serialization, before any data is flushed.

Source

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

        })),
        Time32(unit) => ipc::Type::Time(Box::new(ipc::Time {
            unit: serialize_time_unit(unit),
            bit_width: 32,
        })),
        Time64(unit) => ipc::Type::Time(Box::new(ipc::Time {
            unit: serialize_time_unit(unit),
            bit_width: 64,
        })),
        Timestamp(unit, tz) => ipc::Type::Timestamp(Box::new(ipc::Timestamp {
            unit: serialize_time_unit(unit),
            timezone: tz.as_ref().map(|x| x.to_string()),
        })),
        Interval(unit) => ipc::Type::Interval(Box::new(ipc::Interval {
            unit: match unit {
                IntervalUnit::YearMonth => ipc::IntervalUnit::YearMonth,
                IntervalUnit::DayTime => ipc::IntervalUnit::DayTime,
                IntervalUnit::MonthDayNano => ipc::IntervalUnit::MonthDayNano,
                IntervalUnit::MonthDayMillis => unimplemented!(),
            },
        })),
        List(_) => ipc::Type::List(Box::new(ipc::List {})),
        LargeList(_) => ipc::Type::LargeList(Box::new(ipc::LargeList {})),
        FixedSizeList(_, size) => ipc::Type::FixedSizeList(Box::new(ipc::FixedSizeList {
            list_size: *size as i32,
        })),
        Union(u) => ipc::Type::Union(Box::new(ipc::Union {
            mode: match u.mode {
                UnionMode::Dense => ipc::UnionMode::Dense,
                UnionMode::Sparse => ipc::UnionMode::Sparse,
            },
            type_ids: u.ids.clone(),
        })),
        Map(_, keys_sorted) => ipc::Type::Map(Box::new(ipc::Map {
            keys_sorted: *keys_sorted,
        })),
        Struct(_) => ipc::Type::Struct(Box::new(ipc::Struct {})),

View on GitHub (pinned to df599052da)

Solutions

  1. Cast the interval column to MonthDayNano before writing
  2. Cast to Duration or Utf8 if nanosecond intervals are unwanted
  3. Guard the schema on the write path and report the offending column name
  4. Upstream: reject with a PolarsResult error instead of panicking

Example fix

// before
write_file(&mut df, path, WriteOptions { compression: Some(CompressionCodec::Zstd) })?; // panics in serialize_type

// after
let df = df.with_column(col("iv").cast(DataType::Interval(IntervalUnit::MonthDayNano)))?;
write_file(&mut df, path, WriteOptions { compression: Some(CompressionCodec::Zstd) })?;
Defensive patterns

Strategy: type-guard

Validate before calling

for (name, dtype) in df.schema().iter() {
    polars_ensure!(
        !matches!(dtype, ArrowDataType::Interval(IntervalUnit::MonthDayMillis)),
        ComputeError: "column '{}' is Interval(MonthDayMillis); cast to MonthDayNano before IPC write", name
    );
}

Type guard

fn ipc_writable_intervals(dtype: &ArrowDataType) -> bool {
    !matches!(dtype, ArrowDataType::Interval(IntervalUnit::MonthDayMillis))
}

Prevention

When it happens

Trigger: An IPC/Feather write (the WriteOptions path) of a column typed Interval(IntervalUnit::MonthDayMillis), regardless of compression settings.

Common situations: Persisting interval columns produced by legacy polars versions or interop that mapped to MonthDayMillis; re-saving cached/intermediate files after a version bump.

Related errors


AI-assisted analysis of pola-rs/polars@df599052da (2026-08-16). Data as JSON: /api/errors/a77ba448096b340a. Report an issue: GitHub.