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 JSON row deserializer has no mapping for Arrow's Interval(DayTime) dtype, so _deserialize calls unimplemented! with this message. DayTime interval values (a day/millisecond pair) have no natural JSON representation, and the library refuses to guess an encoding.
Solutions
- Change the schema to avoid DayTime intervals: cast the column to Duration (e.g. Duration(Milliseconds)) or i64 before JSON serialization.
- Convert the interval into two integer columns (days and millis) in the pre-JSON schema.
- Use Arrow IPC/Feather instead of JSON for such columns.
- If the dtype arrives from inference, force the expected schema at read time.
Example fix
// before
let batch = batch_with_interval_column(); // Interval(DayTime)
// after
let batch = batch.cast_columns(&[("col", DataType::Duration(TimeUnit::Milliseconds))])?; Defensive patterns
Strategy: validation
Validate before calling
fn has_day_time(schema: &ArrowSchema) -> bool {
schema.fields.iter().any(|f| f.dtype() == &ArrowDataType::Interval(arrow::datatypes::IntervalUnit::DayTime))
}
assert!(!has_day_time(&schema), "cast Interval(DayTime) to Duration/i64 before JSON"); Try / catch
if has_day_time(&schema) {
let schema = cast_day_time_columns(&schema, ArrowDataType::Duration(TimeUnit::Milliseconds));
}
let array = deserialize(&json, schema.clone(), false)?; Prevention
- Avoid Interval(DayTime) columns in schemas destined for JSON conversion; prefer Duration
- Pin the schema explicitly instead of relying on inference when sources emit intervals
- Test round-trips of interval/duration data through your serialization format early
When it happens
Trigger: Calling deserialize / deserialize_list / deserialize_struct with an ArrowDataType::Interval(IntervalUnit::DayTime) schema field, e.g. converting a record batch containing a DayTime interval column to/from JSON rows.
Common situations: Round-tripping Arrow/Polars data containing duration or interval columns through JSON lines; pipelines where a schema inference step produced DayTime intervals from source data (e.g. pandas date offsets).
Related errors
- read an Array from a non-Array data type
- Deserialization from JSON not implemented for
- FixedSizeListArray::arr_from_iter_with_dtype called with…
- MutableUtf8ValuesArray can only be initialized with…
- not implemented
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/456cdc89c12f729b.
Report an issue: GitHub.
Appendix: 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 fe841f959e)