{"record":{"id":"d8b45ee7da26ac50","repo":"pola-rs/polars","slug":"adding-durations-with-different-units-is-not-suppo","errorCode":null,"errorMessage":"adding durations with different units is not supported here","messagePattern":"adding durations with different units is not supported here","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-core/src/datatypes/any_value.rs","lineNumber":1046,"sourceCode":"    }\n\n    #[must_use]\n    pub fn add(&self, rhs: &AnyValue) -> AnyValue<'static> {\n        use AnyValue::*;\n        match (self, rhs) {\n            (Null, r) => r.clone().into_static(),\n            (l, Null) => l.clone().into_static(),\n            (Int32(l), Int32(r)) => Int32(l + r),\n            (Int64(l), Int64(r)) => Int64(l + r),\n            (UInt32(l), UInt32(r)) => UInt32(l + r),\n            (UInt64(l), UInt64(r)) => UInt64(l + r),\n            (Float16(l), Float16(r)) => Float16(*l + *r),\n            (Float32(l), Float32(r)) => Float32(l + r),\n            (Float64(l), Float64(r)) => Float64(l + r),\n            #[cfg(feature = \"dtype-duration\")]\n            (Duration(l, lu), Duration(r, ru)) => {\n                if lu != ru {\n                    unimplemented!(\"adding durations with different units is not supported here\");\n                }\n\n                Duration(l + r, *lu)\n            },\n            #[cfg(feature = \"dtype-decimal\")]\n            (Decimal(l, lp, ls), Decimal(r, rp, rs)) => {\n                if (lp, ls) != (rp, rs) {\n                    unimplemented!(\n                        \"adding decimals with different precisions/scales is not supported here\"\n                    );\n                }\n\n                Decimal(l + r, *lp, *ls)\n            },\n            _ => unimplemented!(),\n        }\n    }\n","sourceCodeStart":1028,"sourceCodeEnd":1064,"githubUrl":"https://github.com/pola-rs/polars/blob/68506541d2de983056c9eb244e1ea05fab377dfc/crates/polars-core/src/datatypes/any_value.rs#L1028-L1064","documentation":"AnyValue::add supports Duration + Duration only when both share the same TimeUnit; mismatched units hit the unimplemented! guard because AnyValue carries no unit-normalization logic. Fire it by adding duration values of different units (e.g. ms + ns) through generic any-value arithmetic; normalize units upstream.","triggerScenarios":"This panic/expect fires when execution reaches an unguarded state described by: \"adding durations with different units is not supported here\". Typical triggers: unsupported dtype or feature-gated code path reached at runtime, invalid user input or environment variable value, calling API methods in the wrong order or on mismatched types, or data (lengths, offsets, ranges) violating the function's preconditions.","commonSituations":"Encountered when input data or configuration does not meet the preconditions of the throwing code path (\"adding durations with different units is not supported here\"). Common cases: missing Cargo feature flags, mismatched dtypes/lengths between arrays or series, out-of-range temporal values, malformed environment variables, or operations on unsupported/complex nested types.","solutions":["Cast both durations to the same time unit before adding.","Convert one operand explicitly (e.g. ms -> us) so the units match."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"68506541d2de983056c9eb244e1ea05fab377dfc","analyzedAt":"2026-08-19T12:15:06.350Z","contentChangedAt":"2026-08-19T12:15:06.350Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}