{"record":{"id":"e50610b37c900193","repo":"pola-rs/polars","slug":"not-yet-implemented-apply-cannot-be-used-with","errorCode":null,"errorMessage":"not yet implemented: `apply` cannot be used with `having` predicates","messagePattern":"not yet implemented: `apply` cannot be used with `having` predicates","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-lazy/src/frame/mod.rs","lineNumber":2088,"sourceCode":"            .collect::<Vec<_>>();\n\n        self.agg([all().as_expr().tail(n)]).explode_impl(\n            all() - by_name(keys.iter().cloned(), false, false),\n            ExplodeOptions {\n                empty_as_null: true,\n                keep_nulls: true,\n            },\n            true,\n        )\n    }\n\n    /// Apply a function over the groups as a new DataFrame.\n    ///\n    /// **It is not recommended that you use this as materializing the DataFrame is very\n    /// expensive.**\n    pub fn apply(self, f: PlanCallback<DataFrame, DataFrame>, schema: SchemaRef) -> LazyFrame {\n        if !self.predicates.is_empty() {\n            panic!(\"not yet implemented: `apply` cannot be used with `having` predicates\");\n        }\n\n        #[cfg(feature = \"dynamic_group_by\")]\n        let options = GroupbyOptions {\n            dynamic: self.dynamic_options,\n            rolling: self.rolling_options,\n            slice: None,\n        };\n\n        #[cfg(not(feature = \"dynamic_group_by\"))]\n        let options = GroupbyOptions { slice: None };\n\n        let lp = DslPlan::GroupBy {\n            input: Arc::new(self.logical_plan),\n            keys: self.keys,\n            predicates: vec![],\n            aggs: vec![],\n            apply: Some((f, schema)),","sourceCodeStart":2070,"sourceCodeEnd":2106,"githubUrl":"https://github.com/pola-rs/polars/blob/5d8ebabf11caea54a5c29178a64a058762f49766/crates/polars-lazy/src/frame/mod.rs#L2070-L2106","documentation":"LazyFrame::apply (map_groups) inspects the plan and refuses to run when the frame carries HAVING predicates: group-level apply cannot be combined with a having filter, so it panics with this not-yet-implemented message. Rewrite the query to filter after the apply/agg step instead.","triggerScenarios":"This panic/expect fires when execution reaches an unguarded state described by: \"not yet implemented: `apply` cannot be used with `having` predicates\". 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 (\"not yet implemented: `apply` cannot be used with `having` predicates\"). 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":["Do not combine `apply` with `having` predicates; filter before or after the apply instead.","Rewrite the query so the having condition is applied to the result of the apply step."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5d8ebabf11caea54a5c29178a64a058762f49766","analyzedAt":"2026-08-19T12:15:06.350Z","contentChangedAt":"2026-08-19T12:15:06.350Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}