jmcnamara / polars_excel_writer

A Polars extension to serialize dataframes to Excel xlsx files
Apache License 2.0
13 stars 4 forks source link

Bug: Version 0.3.0 on Crates.io - `the trait From<XlsxError> is not implemented for polars::prelude::PolarsError` #12

Closed adelg003 closed 8 months ago

adelg003 commented 9 months ago

Current behavior

Looks like cargo check / build is returning a trait related error when tying it use version 0.3.0 and 0.2.0 on Crates.io. https://crates.io/crates/polars_excel_writer/versions

Error:

$ cargo check
    Checking polars_excel_writer v0.3.0
error[E0277]: `?` couldn't convert the error to `polars::prelude::PolarsError`
   --> /home/adelg003/.cargo/registry/src/index.crates.io-6f17d22bba15001f/polars_excel_writer-0.3.0/src/xlsx_writer.rs:468:33
    |
468 |         self.workbook.save(path)?;
    |                                 ^ the trait `From<XlsxError>` is not implemented for `polars::prelude::PolarsError`
    |
    = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
    = help: the following other types implement trait `From<T>`:
              <polars::prelude::PolarsError as From<regex::error::Error>>
              <polars::prelude::PolarsError as From<std::io::Error>>
              <polars::prelude::PolarsError as From<polars::error::ArrowError>>
    = note: required for `Result<(), polars::prelude::PolarsError>` to implement `FromResidual<Result<Infallible, XlsxError>>`

Expected behavior

When installing polars_excel_writer from crates.io, the versions available should be free of the From<XlsxError> is not implemented for polars::prelude::PolarsError error.

Sample code to reproduce

Use the following version in the Cargo.toml:

polars_excel_writer = "0.3.0"

or

polars_excel_writer = "0.2.0"

Environment

- polars_excel_writer version: 0.3.0 and 0.2.0
- rustc version: rustc 1.74.0 (79e9716c9 2023-11-13)
- Excel version: N/A
- OS: Tested on Manjaro Linux and Mac (Intel version)

Any other information

Ironically, it looks like the current commit (31f09fb3560543a8cdd5bbbfe3eb7a2d3ffc5467) in the main branch does not have this issue.

Version with error from Crates.io:

polars_excel_writer = "0.3.0"

and

polars_excel_writer = "0.2.0"

(0.1.0 does not have this error)

Working version from github:

polars_excel_writer = { git = 'https://github.com/jmcnamara/polars_excel_writer' }

May make sense to update the version present in crates.io with what is current in the main branch and yank versions 0.2.0 and 0.3.0.

If more information is needed, please let me know.

jmcnamara commented 9 months ago

Thanks for the report.

I fixed the underlying issue in rust_xlsxwriter (https://github.com/jmcnamara/rust_xlsxwriter/commit/ef6cac015369e8121a4f464951f566ecb6aeb835) back in September and, as you spotted, I prepped polars_excel_writer but somehow forgot to release it.

I'll update to the latest versions and recheck and I'll push out a version tonight.

jmcnamara commented 9 months ago

I've pushed an updated version (v0.4.0) that is pegged to Polars v0.33.2 (same as rust_xlsxwriter). There may be some issues with the latest Polars and rust_xlsxwriter which I need to look into.

I'll leave this open until I do that but at least v0.4.0 should work for now. Let me know if you have any issues.

jmcnamara commented 8 months ago

I've released v0.50.0 which ties polars_excel_writer to the Polars v0.35.4 which is the version supported by rust_xlsxwriter. It fixes this issue.