Search code examples
rustrust-cargorust-polars

Rust Polars feature select in Cargo.toml not working


I have a strange behavior. Apparently I must have messed up something:

My toml file:

[package]
name = "test"
version = "0.1.0"
edition = "2021"

[dependencies]
# Version 0.22.7 ==> works
polars = {version = "0.22.8", features = ["lazy"]}

# Version 0.23.0 ==> Does Not Work ... and it will load the 0.23.2 version?!
#polars = {version = "0.23.0", features = ["lazy"]}

Main main.cs:

use polars::prelude::*;

pub fn main() {
    let path = "C:\\temp\\rusty.csv";
    let days = LazyCsvReader::new(path.into())
        .has_header(false)
        .finish()
        .unwrap()
        .collect();
}

Error:

error[E0433]: failed to resolve: use of undeclared type `LazyCsvReader`
  --> src\main.rs:25:16
   |
25 |     let days = LazyCsvReader::new(path.into())
   |                ^^^^^^^^^^^^^ use of undeclared type `LazyCsvReader`

Any ideas ...?

Digging further I can see that part of the feature-tree is missing in version 0.23.2 of polars:

│   ├── polars feature "csv-file"
│   │   ├── polars v0.22.8 (*)
│   │   ├── polars feature "polars-io"
│   │   │   └── polars v0.22.8 (*)
│   │   ├── polars feature "polars-lazy"
│   │   │   └── polars v0.22.8 (*)
│   │   ├── polars-io feature "csv-file" (*)
│   │   └── polars-lazy feature "csv-file"
│   │       ├── polars-lazy v0.22.7 (*)
│   │       └── polars-io feature "csv-file" (*)

==> a BUG?

Version 0.23.1 of polars is feature complete ... does not have this problem

now my workaround question is: How do I force a specific version to be part of my project?

This:

polars = {version = "0.23.1", features = ["lazy"]}

did not work ...


Solution

  • Thanks to @isaactfa we have this workaround/solution:

    polars = {version = "0.23.2", features = ["lazy", "csv-file"]}
    

    My understanding is that the "csv-file" feature is a dependency feature of "lazy" and thus should have been loaded with just the "lazy" flag.

    The other workaround is to really force polars' version to "<= 0.23.1"

    polars = {version = "<= 0.23.1", features = ["lazy"]}