Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type error when converting results to polars #48

Open
ms-2k opened this issue Jul 4, 2024 · 1 comment · May be fixed by #49
Open

Type error when converting results to polars #48

ms-2k opened this issue Jul 4, 2024 · 1 comment · May be fixed by #49

Comments

@ms-2k
Copy link

ms-2k commented Jul 4, 2024

Hi, I have encountered an issue while building a project using the latest version available on cargo, 0.9.0, with the polars feature enabled. The error is as follows:

error[E0308]: mismatched types
 40 |         .infer_schema_len(Some(5))
    |                           ---- ^ expected `NonZero<usize>`, found integer
    |                           |
    |                           arguments to this enum variant are incorrect
    |
    = note: expected struct `NonZero<usize>`

The issue appears to be in line 40 of the file polars.rs. My build environment was the rust:slim-bookworm docker image on ARM64 using rust version 1.79.0-aarch64-unknown-linux-gnu.

A potential solution I suggest is as follows, starting from line 39:

let df = JsonReader::new(reader)
    .with_json_format(JsonFormat::Json)
    .infer_schema_len(Some(NonZeroUsize::new(5).unwrap()))
    .finish()?;

The modification above resolves the issue on my end.

@tobisinghania
Copy link

tobisinghania commented Jul 21, 2024

This error only pops up when using the latest polars-rs version 0.41.3, specifically because of this PR pola-rs/polars#16770

The unwrap in the proposal for the fix is not needed btw, since NonZeroUsize::new returns an option already:

let df = JsonReader::new(reader)
    .with_json_format(JsonFormat::Json)
    .infer_schema_len(NonZeroUsize::new(5))
    .finish()?;

@tobisinghania tobisinghania linked a pull request Jul 21, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants