pola-rs/polars · error

activate 'product' feature

Error message

activate 'product' feature

What it means

Series::product is only compiled when the 'product' feature is enabled; without it the method body immediately panics with a directive to activate the feature. The multiplication-reduction implementation is feature-gated in polars-core.

Solutions

  1. Add the 'product' feature to your polars dependency: polars = { version = "...", features = ["product"] }
  2. Replace product() with an equivalent fold/multiplication over the column values if you cannot change features
  3. Enable the broader 'lazy' or 'default' feature sets that include 'product'

Example fix

// before
polars = { version = "0.40", default-features = false }
// after
polars = { version = "0.40", default-features = false, features = ["product"] }
Defensive patterns

Strategy: validation

Validate before calling

#[cfg(not(feature = "product"))]
compile_error!("polars 'product' feature required");

Try / catch

// gate at runtime
let prod = if cfg!(feature = "product") { Some(s.product()) } else { None };

Prevention

When it happens

Trigger: Calling series.product() (or APIs that reduce via product) on a polars build compiled without the 'product' cargo feature.

Common situations: Using a minimal-feature polars build (e.g. from a workspace that trimmed default features) and then calling cumulative/aggregate product operations.

Related errors


AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18). Data as JSON: /api/errors/3e82b8d7404a26c6. Report an issue: GitHub.

Appendix: source

Thrown at crates/polars-core/src/series/mod.rs:914

                UInt64 => Ok(self.u64().unwrap().prod_reduce()),
                #[cfg(feature = "dtype-i128")]
                Int128 => Ok(self.i128().unwrap().prod_reduce()),
                #[cfg(feature = "dtype-u128")]
                UInt128 => Ok(self.u128().unwrap().prod_reduce()),
                #[cfg(feature = "dtype-f16")]
                Float16 => Ok(self.f16().unwrap().prod_reduce()),
                Float32 => Ok(self.f32().unwrap().prod_reduce()),
                Float64 => Ok(self.f64().unwrap().prod_reduce()),
                #[cfg(feature = "dtype-decimal")]
                Decimal(..) => Ok(self.decimal().unwrap().prod_reduce()),
                dt => {
                    polars_bail!(InvalidOperation: "`product` operation not supported for dtype `{dt}`")
                },
            }
        }
        #[cfg(not(feature = "product"))]
        {
            panic!("activate 'product' feature")
        }
    }

    /// Cast throws an error if conversion had overflows
    pub fn strict_cast(&self, dtype: &DataType) -> PolarsResult<Series> {
        self.cast_with_options(dtype, CastOptions::Strict)
    }

    #[cfg(feature = "dtype-decimal")]
    pub fn into_decimal(self, precision: usize, scale: usize) -> PolarsResult<Series> {
        match self.dtype() {
            DataType::Int128 => Ok(self
                .i128()
                .unwrap()
                .clone()
                .into_decimal(precision, scale)?
                .into_series()),
            DataType::Decimal(cur_prec, cur_scale)

View on GitHub (pinned to fe841f959e)