pola-rs/polars · error

not implemented

Error message

not implemented

What it means

When a schema is exported over the Arrow C Data Interface, every field dtype is rendered as a C format string by to_format (crates/polars-arrow/src/ffi/schema.rs). The format grammar has codes tiM/tiD/tin for YearMonth/DayTime/MonthDayNano intervals but none for polars' extra MonthDayMillis unit, and that arm (line 495) is unimplemented!(). Exporting a schema containing Interval(MonthDayMillis) — e.g. polars-python handing a DataFrame to pyarrow — panics inside schema construction.

Source

Thrown at crates/polars-arrow/src/ffi/schema.rs:495

        ArrowDataType::Date64 => "tdm".to_string(),
        ArrowDataType::Time32(TimeUnit::Second) => "tts".to_string(),
        ArrowDataType::Time32(TimeUnit::Millisecond) => "ttm".to_string(),
        ArrowDataType::Time32(_) => {
            unreachable!("Time32 is only supported for seconds and milliseconds")
        },
        ArrowDataType::Time64(TimeUnit::Microsecond) => "ttu".to_string(),
        ArrowDataType::Time64(TimeUnit::Nanosecond) => "ttn".to_string(),
        ArrowDataType::Time64(_) => {
            unreachable!("Time64 is only supported for micro and nanoseconds")
        },
        ArrowDataType::Duration(TimeUnit::Second) => "tDs".to_string(),
        ArrowDataType::Duration(TimeUnit::Millisecond) => "tDm".to_string(),
        ArrowDataType::Duration(TimeUnit::Microsecond) => "tDu".to_string(),
        ArrowDataType::Duration(TimeUnit::Nanosecond) => "tDn".to_string(),
        ArrowDataType::Interval(IntervalUnit::YearMonth) => "tiM".to_string(),
        ArrowDataType::Interval(IntervalUnit::DayTime) => "tiD".to_string(),
        ArrowDataType::Interval(IntervalUnit::MonthDayNano) => "tin".to_string(),
        ArrowDataType::Interval(IntervalUnit::MonthDayMillis) => unimplemented!(),
        ArrowDataType::Timestamp(unit, tz) => {
            let unit = match unit {
                TimeUnit::Second => "s",
                TimeUnit::Millisecond => "m",
                TimeUnit::Microsecond => "u",
                TimeUnit::Nanosecond => "n",
            };
            format!(
                "ts{}:{}",
                unit,
                tz.as_ref().map(|x| x.as_str()).unwrap_or("")
            )
        },
        ArrowDataType::Utf8View => "vu".to_string(),
        ArrowDataType::BinaryView => "vz".to_string(),
        ArrowDataType::Decimal(precision, scale) => format!("d:{precision},{scale}"),
        ArrowDataType::Decimal32(precision, scale) => format!("d:{precision},{scale},32"),
        ArrowDataType::Decimal64(precision, scale) => format!("d:{precision},{scale},64"),

View on GitHub (pinned to df599052da)

Solutions

  1. Cast the interval column to MonthDayNano (formats as 'tin') or Duration before crossing the FFI boundary
  2. Standardize on MonthDayNano; never construct MonthDayMillis intervals
  3. Walk the schema before export and reject unsupported intervals with an error naming the column
  4. Upstream: return an error instead of panicking, or encode MonthDayMillis as 'tin' plus metadata

Example fix

// before
let (arrow_schema, arrays) = to_ffi(&schema, &mut arrays)?; // panics on Interval(MonthDayMillis)

// after: normalize the unit before export
let df = df.with_column(col("iv").cast(DataType::Interval(IntervalUnit::MonthDayNano)))?;
let (arrow_schema, arrays) = to_ffi(&schema, &mut arrays)?;
Defensive patterns

Strategy: type-guard

Validate before calling

fn ffi_exportable(dtype: &ArrowDataType) -> bool {
    !matches!(dtype, ArrowDataType::Interval(IntervalUnit::MonthDayMillis) | ArrowDataType::Unknown)
}
for f in &schema.fields {
    polars_ensure!(ffi_exportable(f.dtype()), InvalidOperation: "column '{}' not exportable via C Data Interface", f.name);
}

Type guard

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

Try / catch

let res = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| to_ffi(&schema, &mut arrays)));
let ffi = res.map_err(|_| polars_err!(ComputeError: "FFI export panicked: unsupported dtype in schema"))?;

Prevention

When it happens

Trigger: ArrowSchema::new / to_ffi export of any field typed Interval(IntervalUnit::MonthDayMillis), typically during zero-copy C Data Interface transfer to pyarrow or another Arrow implementation.

Common situations: Round-tripping interval data produced by older polars versions or custom builders that chose MonthDayMillis; mixed-version clusters where one node emits the nonstandard unit.

Related errors


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