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

Casting to UInt8 is panicking with 45.0 and 45.1 #20427

Closed
2 tasks done
deanm0000 opened this issue Dec 23, 2024 · 2 comments
Closed
2 tasks done

Casting to UInt8 is panicking with 45.0 and 45.1 #20427

deanm0000 opened this issue Dec 23, 2024 · 2 comments
Labels
A-panic Area: code that results in panic exceptions bug Something isn't working needs triage Awaiting prioritization by a maintainer rust Related to Rust Polars

Comments

@deanm0000
Copy link
Collaborator

Checks

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of Polars.

Reproducible example

fn main() {
    let mut file = std::fs::File::open("output.parquet").unwrap();
    
    let df2 = ParquetReader::new(&mut file).finish().unwrap();
    eprintln!("just read {}",df2);
    let df3=df2
    .lazy()
    .with_column(col("hour").cast(DataType::UInt8))
    .collect()
    .unwrap();
    eprintln!("df3 {}", df3);
}

output.zip

The file is here (it's zipped b/c github won't let me attach parquet outright.

Log output

`Result::unwrap()` on an `Err` value: ComputeError(ErrString("cannot create series from UInt8"))
stack backtrace:
   0:     0x5564b2065a0a - std::backtrace_rs::backtrace::libunwind::trace::h0ff85584d06a013a
                               at /rustc/426d1734238e3c5f52e935ba4f617f3a9f43b59d/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x5564b2065a0a - std::backtrace_rs::backtrace::trace_unsynchronized::h7b906af90163d53b
                               at /rustc/426d1734238e3c5f52e935ba4f617f3a9f43b59d/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x5564b2065a0a - std::sys::backtrace::_print_fmt::h3a3addb231d12028
                               at /rustc/426d1734238e3c5f52e935ba4f617f3a9f43b59d/library/std/src/sys/backtrace.rs:66:9
   3:     0x5564b2065a0a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hdda3075834857ed7
                               at /rustc/426d1734238e3c5f52e935ba4f617f3a9f43b59d/library/std/src/sys/backtrace.rs:39:26
   4:     0x5564b208fb53 - core::fmt::rt::Argument::fmt::hb9be4cc0137892f0
                               at /rustc/426d1734238e3c5f52e935ba4f617f3a9f43b59d/library/core/src/fmt/rt.rs:177:76
   5:     0x5564b208fb53 - core::fmt::write::h7845bb3abec6b5ce
                               at /rustc/426d1734238e3c5f52e935ba4f617f3a9f43b59d/library/core/src/fmt/mod.rs:1440:21
   6:     0x5564b2061e43 - std::io::Write::write_fmt::h689fab3154806ae1
                               at /rustc/426d1734238e3c5f52e935ba4f617f3a9f43b59d/library/std/src/io/mod.rs:1887:15
   7:     0x5564b2065852 - std::sys::backtrace::BacktraceLock::print::h385a792406f63c38
                               at /rustc/426d1734238e3c5f52e935ba4f617f3a9f43b59d/library/std/src/sys/backtrace.rs:42:9
   8:     0x5564b206695d - std::panicking::default_hook::{{closure}}::h9cfa0fe5d4f108c4
                               at /rustc/426d1734238e3c5f52e935ba4f617f3a9f43b59d/library/std/src/panicking.rs:284:22
   9:     0x5564b20667a2 - std::panicking::default_hook::h95dfb7a9bb6f3461
                               at /rustc/426d1734238e3c5f52e935ba4f617f3a9f43b59d/library/std/src/panicking.rs:311:9
  10:     0x5564b20670a7 - std::panicking::rust_panic_with_hook::h1e4476f399791006
                               at /rustc/426d1734238e3c5f52e935ba4f617f3a9f43b59d/library/std/src/panicking.rs:817:13
  11:     0x5564b2066e2a - std::panicking::begin_panic_handler::{{closure}}::hd8b76955e18606db
                               at /rustc/426d1734238e3c5f52e935ba4f617f3a9f43b59d/library/std/src/panicking.rs:690:13
  12:     0x5564b2065ee9 - std::sys::backtrace::__rust_end_short_backtrace::hc35e6bbd7a6cbefa
                               at /rustc/426d1734238e3c5f52e935ba4f617f3a9f43b59d/library/std/src/sys/backtrace.rs:168:18
  13:     0x5564b2066abd - rust_begin_unwind
                               at /rustc/426d1734238e3c5f52e935ba4f617f3a9f43b59d/library/std/src/panicking.rs:681:5
  14:     0x5564b208ca30 - core::panicking::panic_fmt::hf53ce36a54419534
                               at /rustc/426d1734238e3c5f52e935ba4f617f3a9f43b59d/library/core/src/panicking.rs:75:14
  15:     0x5564b208cf06 - core::result::unwrap_failed::h9bfe7206cd242621
                               at /rustc/426d1734238e3c5f52e935ba4f617f3a9f43b59d/library/core/src/result.rs:1704:5
  16:     0x5564ade7901c - core::result::Result<T,E>::unwrap::hb8b8ebcf93860c07
                               at /home/dean/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/result.rs:1109:23
  17:     0x5564ade7901c - rustpjm::main::h78dd3768bee439d3
                               at /home/dean/pyjs/az_funcs/rustpjm/src/main.rs:70:13
  18:     0x5564ade76c5b - core::ops::function::FnOnce::call_once::hb27657b7e8a1dcf7
                               at /home/dean/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
  19:     0x5564ade7d4fe - std::sys::backtrace::__rust_begin_short_backtrace::h5c1226037dbca7ee
                               at /home/dean/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/backtrace.rs:152:18
  20:     0x5564ade7a3b1 - std::rt::lang_start::{{closure}}::hef015b85f5f9d442
                               at /home/dean/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:195:18
  21:     0x5564b205ae27 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h3e9d4553c660a8c5
                               at /rustc/426d1734238e3c5f52e935ba4f617f3a9f43b59d/library/core/src/ops/function.rs:284:13
  22:     0x5564b205ae27 - std::panicking::try::do_call::h79a74a1dd875baaa
                               at /rustc/426d1734238e3c5f52e935ba4f617f3a9f43b59d/library/std/src/panicking.rs:573:40
  23:     0x5564b205ae27 - std::panicking::try::hd4f86af897d3d2ce
                               at /rustc/426d1734238e3c5f52e935ba4f617f3a9f43b59d/library/std/src/panicking.rs:536:19
  24:     0x5564b205ae27 - std::panic::catch_unwind::h0fddc4a5bb48c420
                               at /rustc/426d1734238e3c5f52e935ba4f617f3a9f43b59d/library/std/src/panic.rs:358:14
  25:     0x5564b205ae27 - std::rt::lang_start_internal::{{closure}}::ha131224f8916be44
                               at /rustc/426d1734238e3c5f52e935ba4f617f3a9f43b59d/library/std/src/rt.rs:174:48
  26:     0x5564b205ae27 - std::panicking::try::do_call::hbb8416d609bcff87
                               at /rustc/426d1734238e3c5f52e935ba4f617f3a9f43b59d/library/std/src/panicking.rs:573:40
  27:     0x5564b205ae27 - std::panicking::try::h7f91084e90dc8596
                               at /rustc/426d1734238e3c5f52e935ba4f617f3a9f43b59d/library/std/src/panicking.rs:536:19
  28:     0x5564b205ae27 - std::panic::catch_unwind::hadf6a57f902788b7
                               at /rustc/426d1734238e3c5f52e935ba4f617f3a9f43b59d/library/std/src/panic.rs:358:14
  29:     0x5564b205ae27 - std::rt::lang_start_internal::hc42dbdbcff5bac1f
                               at /rustc/426d1734238e3c5f52e935ba4f617f3a9f43b59d/library/std/src/rt.rs:174:20
  30:     0x5564ade7a38a - std::rt::lang_start::h095e226ad775f294
                               at /home/dean/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:194:17
  31:     0x5564ade791ae - main
  32:     0x7fb30f501d90 - __libc_start_call_main
                               at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
  33:     0x7fb30f501e40 - __libc_start_main_impl
                               at ./csu/../csu/libc-start.c:392:3
  34:     0x5564ade76b25 - _start
  35:                0x0 - <unknown>

Issue description

I can do this in python (1.17.1) without issue, it's just in rust that it doesn't work. I tried with both 0.45.0 and 0.45.1.

Expected behavior

It should cast successfully.

Installed versions

polars = { version = "0.45.0", features = ["json", "temporal", "timezones","dtype-datetime", "strings", "dtype-date","lazy","parquet"]}
polars-core = { version = "0.45.0" }

rustc --version
rustc 1.85.0-nightly (426d17342 2024-12-21)

@deanm0000 deanm0000 added bug Something isn't working rust Related to Rust Polars needs triage Awaiting prioritization by a maintainer labels Dec 23, 2024
@deanm0000
Copy link
Collaborator Author

deanm0000 commented Dec 23, 2024

I added

use jemallocator::Jemalloc;

#[global_allocator]
static GLOBAL: Jemalloc = Jemalloc;

and it made it work.

@alexander-beedie alexander-beedie added the A-panic Area: code that results in panic exceptions label Dec 23, 2024
@lukemanley
Copy link
Contributor

This works without panicking if you add feature "dtype-u8" to your list of features.

@orlp orlp closed this as not planned Won't fix, can't repro, duplicate, stale Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-panic Area: code that results in panic exceptions bug Something isn't working needs triage Awaiting prioritization by a maintainer rust Related to Rust Polars
Projects
None yet
Development

No branches or pull requests

4 participants