pola-rs / pyo3-polars

Plugins/extension for Polars
MIT License
258 stars 41 forks source link

Compilation error with Categorical dtype #113

Open niklasmueboe opened 2 weeks ago

niklasmueboe commented 2 weeks ago

Using pyo3-polars 0.17 with the dtype-categorical feature for polars seems to lead to compilation errors. Using pyo3-polars 0.15 works fine.

error[E0004]: non-exhaustive patterns: &DataType::Categorical(_, _) and &DataType::Enum(_, _) not covered --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pyo3-polars-0.17.0/src/types.rs:359:15 359 match &self.0 { ^^^^^^^ patterns &DataType::Categorical(_, _) and &DataType::Enum(_, _) not covered
  note: `DataType` defined here
     --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/polars-core-0.43.1/src/datatypes/dtype.rs:44:1
      |
  44  | pub enum DataType {
      | ^^^^^^^^^^^^^^^^^
  ...
  88  |     Categorical(Option<Arc<RevMapping>>, CategoricalOrdering),
      |     ----------- not covered
  89  |     #[cfg(feature = "dtype-categorical")]
  90  |     Enum(Option<Arc<RevMapping>>, CategoricalOrdering),
      |     ---- not covered
      = note: the matched value is of type `&DataType`
  help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
      |
  494 ~             },
  495 +             &DataType::Categorical(_, _) | &DataType::Enum(_, _) => todo!()
Shoeboxam commented 1 week ago

Have you tried adding the "dtype-categorical" feature? Things should ideally compile as-is, but it's possible to nudge it along.

niklasmueboe commented 1 week ago

Then I get

 error[E0432]: unresolved import `polars_core::datatypes::create_enum_data_type`
   --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pyo3-polars-0.17.0/src/types.rs:6:5
    |
  6 | use polars_core::datatypes::create_enum_data_type;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^---------------------
    |     |                       |
    |     |                       help: a similar name exists in the module: `create_enum_dtype`
    |     no `create_enum_data_type` in `datatypes`
Shoeboxam commented 1 week ago

Try pinning to Polars 0.43.0, and enabling the "futures" feature in polars?

They seem to have forgotten to update the pyo3 polars crate to support polars 0.43.1.

Distortedlogic commented 1 week ago

0.43.0 complains no feature futures for polars for me. I had to downgrade to 0.42.0 for poalrs and 0.16.1 for pyo3-polars :/ note this error occured for me from within maturin, not rust analyzer