pola-rs/polars · error
There is no natural representation of DayTime in JSON.
Error message
There is no natural representation of DayTime in JSON.
What it means
The polars-json deserializer refuses ArrowDataType::Interval(IntervalUnit::DayTime): there is no natural JSON text representation for a days+milliseconds interval, so schema-driven JSON/NDJSON parsing panics with unimplemented!().
Source
Thrown at crates/polars-json/src/json/deserialize.rs:439
check_err_idx(rows, err_idx, "null")?;
}
Ok(Box::new(NullArray::new(dtype, rows.len())))
},
ArrowDataType::Boolean => {
fill_generic_array_from::<_, _, BooleanArray>(deserialize_boolean_into, rows)
},
ArrowDataType::Int8 => {
fill_array_from::<_, _, PrimitiveArray<i8>>(deserialize_primitive_into, dtype, rows)
},
ArrowDataType::Int16 => {
fill_array_from::<_, _, PrimitiveArray<i16>>(deserialize_primitive_into, dtype, rows)
},
ArrowDataType::Int32 | ArrowDataType::Interval(IntervalUnit::YearMonth) => {
fill_array_from::<_, _, PrimitiveArray<i32>>(deserialize_primitive_into, dtype, rows)
},
ArrowDataType::Interval(IntervalUnit::DayTime) => {
unimplemented!("There is no natural representation of DayTime in JSON.")
},
ArrowDataType::Int64 | ArrowDataType::Duration(_) => {
fill_array_from::<_, _, PrimitiveArray<i64>>(deserialize_primitive_into, dtype, rows)
},
ArrowDataType::Date32 => {
deserialize_temporal_primitive::<i32, _>(rows, dtype, "date", utf8_to_naive_date_scalar)
},
ArrowDataType::Date64 => {
deserialize_temporal_primitive::<i64, _>(rows, dtype, "date", |s| {
utf8_to_naive_date_scalar(s)
.map(|d| d as i64 * temporal_conversions::MILLISECONDS_IN_DAY)
})
},
ArrowDataType::Time32(tu) => {
let tu = *tu;
deserialize_temporal_primitive::<i32, _>(rows, dtype, "time", |s| {
utf8_to_naive_time_scalar(s, tu).and_then(|v| i32::try_from(v).ok())
})View on GitHub (pinned to df599052da)
Solutions
- Remove the interval field from the JSON schema, or type it as Duration or String instead
- Convert the DayTime intervals to month-day-nanosecond intervals or ISO-8601 duration strings on the producing side, then parse
- Read the field as a struct {days, milliseconds} and reconstruct the interval afterwards
Example fix
# before
pl.read_ndjson("x.ndjson", schema={"iv": pl.Interval("day_time")}) # panics
# after
pl.read_ndjson("x.ndjson", schema={"iv": pl.String}) # parse, then convert Defensive patterns
Strategy: validation
Validate before calling
schema = {k: v for k, v in schema.items() if not (isinstance(v, pl.Interval))} Type guard
def json_safe_schema(schema: dict) -> bool:
return not any(isinstance(dt, pl.Interval) for dt in schema.values()) Prevention
- Never reuse Arrow/Parquet schemas verbatim for JSON readers; strip interval fields
- Model intervals as Duration or ISO-8601 strings for JSON interchange
When it happens
Trigger: Reading JSON/NDJSON with an explicit schema that contains an Interval(DayTime) dtype: pl.read_ndjson(..., schema={"iv": pl.Interval}) mapping to the DayTime arrow unit, or the Rust polars-json deserialize() with that dtype.
Common situations: Schemas imported from Arrow/Parquet metadata (where DayTime intervals exist) and reused verbatim for JSON ingestion; interop pipelines that assume interval parity across formats.
Related errors
- Deserialization from JSON not implemented for {adt:?}
- not implemented
- not implemented
- horizontal_flatten not supported for data type {:?}
- can not get dtype of Categorical AnyValue
AI-assisted analysis of pola-rs/polars@df599052da (2026-08-16).
Data as JSON: /api/errors/456cdc89c12f729b.
Report an issue: GitHub.