{"record":{"id":"89b1021d45dcb1c1","repo":"pola-rs/polars","slug":"adding-decimals-with-different-precisions-scales-i","errorCode":null,"errorMessage":"adding decimals with different precisions/scales is not supported here","messagePattern":"adding decimals with different precisions/scales is not supported here","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-core/src/datatypes/any_value.rs","lineNumber":1054,"sourceCode":"            (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\n    #[inline]\n    pub fn as_borrowed(&self) -> AnyValue<'_> {\n        match self {\n            AnyValue::BinaryOwned(data) => AnyValue::Binary(data),\n            AnyValue::StringOwned(data) => AnyValue::String(data.as_str()),\n            #[cfg(feature = \"dtype-datetime\")]\n            AnyValue::DatetimeOwned(v, tu, tz) => {\n                AnyValue::Datetime(*v, *tu, tz.as_ref().map(AsRef::as_ref))","sourceCodeStart":1036,"sourceCodeEnd":1072,"githubUrl":"https://github.com/pola-rs/polars/blob/68506541d2de983056c9eb244e1ea05fab377dfc/crates/polars-core/src/datatypes/any_value.rs#L1036-L1072","documentation":"AnyValue::add for Decimal values requires equal precision/scale on both operands; differing metadata hits this unimplemented! guard since AnyValue addition does not rescale decimals. Ensure operands share precision/scale (cast one side) before generic addition.","triggerScenarios":"This panic/expect fires when execution reaches an unguarded state described by: \"adding decimals with different precisions/scales 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 decimals with different precisions/scales 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":["Align precision and scale of both decimals before adding (e.g. via cast to a common decimal dtype).","Perform the arithmetic in floating point if exact decimal alignment is not required."],"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-14T00:17:10.932Z"}