{"record":{"id":"c538dab15cf4075d","repo":"pola-rs/polars","slug":"activate-feature-dtype-duration","errorCode":null,"errorMessage":"activate feature dtype-duration","messagePattern":"activate feature dtype-duration","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-core/src/series/mod.rs","lineNumber":1005,"sourceCode":"                .clone()\n                .into_datetime(timeunit, tz)\n                .into_series(),\n            DataType::Datetime(_, _) => self\n                .datetime()\n                .unwrap()\n                .physical()\n                .clone()\n                .into_datetime(timeunit, tz)\n                .into_series(),\n            dt => panic!(\"into_datetime not implemented for {dt:?}\"),\n        }\n    }\n\n    #[allow(unused_variables)]\n    pub fn into_duration(self, timeunit: TimeUnit) -> Series {\n        #[cfg(not(feature = \"dtype-duration\"))]\n        {\n            panic!(\"activate feature dtype-duration\")\n        }\n        #[cfg(feature = \"dtype-duration\")]\n        match self.dtype() {\n            DataType::Int64 => self\n                .i64()\n                .unwrap()\n                .clone()\n                .into_duration(timeunit)\n                .into_series(),\n            DataType::Duration(_) => self\n                .duration()\n                .unwrap()\n                .physical()\n                .clone()\n                .into_duration(timeunit)\n                .into_series(),\n            dt => panic!(\"into_duration not implemented for {dt:?}\"),\n        }","sourceCodeStart":987,"sourceCodeEnd":1023,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-core/src/series/mod.rs#L987-L1023","documentation":"This panic comes from Series::into_duration, a compile-time-gated API. Polars' Duration dtype is only compiled in when the `dtype-duration` cargo feature is enabled; without it, the function body is replaced by an unconditional panic. It means you called into_duration (directly or via a cast to Duration) on a build that cannot represent Duration.","triggerScenarios":"Calling Series::into_duration (e.g. via DataFrame::cast / finish_cast to DataType::Duration) on a polars-core build without the `dtype-duration` feature.","commonSituations":"Users add polars as a dependency with default features or a reduced feature set, then a downstream API (casting an Int64/other column to Duration, e.g. parsing timestamps) hits the disabled code path; also happens after upgrading polars where features were renamed or pruned.","solutions":["Enable the feature in Cargo.toml: polars = { version = \"...\", features = [\"dtype-duration\"] }","If you do not actually need Duration, cast to a supported dtype (e.g. keep Int64 or cast to Datetime) instead","Run `cargo tree -e features` / check `cargo features` to confirm `dtype-duration` is actually enabled in the unified feature graph (another crate may be disabling default features)","Check that you are not using a polars fork/pinned version where the feature name differs"],"exampleFix":"// before\npolars = { version = \"0.46\", features = [\"lazy\"] }\n// after\npolars = { version = \"0.46\", features = [\"lazy\", \"dtype-duration\"] }","handlingStrategy":"validation","validationCode":"fn dtype_duration_supported() -> bool {\n    // compile-time probe; swap for your own cfg when building on polars\n    cfg!(feature = \"dtype-duration\")\n}\nif !dtype_duration_supported() {\n    eprintln!(\"casting to Duration requires the polars 'dtype-duration' feature\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always enable dtype-duration when your schema includes Duration columns","Pin a features list in a workspace-level Cargo.toml so all crates share it","CI: assert `cargo tree -e features | grep dtype-duration` for builds that cast to Duration"],"tags":["rust","feature-flags","polars","dtype"],"backgroundTag":"feature-not-enabled","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}