-1

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 ...

Robert
  • 131
  • 1
  • 7
  • 1
    Are you absolutely sure that same code works with `0.22.8`? It gives the same error about `LazyCsvReader` being undeclared for me; you are missing the required `use` statements. – Herohtar Aug 10 '22 at 22:09
  • By the way, specifying the version as `"0.23.0"` is the same as `"^0.23.0"`, which means any version greater than `0.23.0` and less than `0.24.0` is fine, so that's why it's giving you `0.23.2` – Herohtar Aug 10 '22 at 22:10
  • @Herchtar ... Thanks for the hint about the use statement ... I have it in my code ... just did not copy everything ... updated the question with the correct/full source.. Also specifying the 0.23.1 version did not matter ... it still compiled / used the 0.23.2 version ...?! – Robert Aug 10 '22 at 22:13
  • 1
    Looking at the source for `LazyCsvReader`, the feature appears to be `"csv-file"` not `"lazy"`. – isaactfa Aug 10 '22 at 22:21
  • @isaactfa thanks for the hint. I found another work around too and will summarize both in the answer below. – Robert Aug 10 '22 at 22:34

1 Answers1

0

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"]}
Robert
  • 131
  • 1
  • 7