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

assertion left == right failed: implementation error on join #17446

Closed
2 tasks done
postatum opened this issue Jul 5, 2024 · 0 comments · Fixed by #17461
Closed
2 tasks done

assertion left == right failed: implementation error on join #17446

postatum opened this issue Jul 5, 2024 · 0 comments · Fixed by #17461
Assignees
Labels
accepted Ready for implementation bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars

Comments

@postatum
Copy link

postatum commented Jul 5, 2024

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

import polars as pl

dfa = pl.DataFrame({"replace_unique_id": [x for x in range(493)]})

dfb = dfa.clone()
dfb = dfb.with_columns(ds_start_date_right=pl.lit(None).cast(pl.Date))
dfb = pl.concat([dfb, dfb])

dfa.join(dfb, how="left", on=pl.col("replace_unique_id"))

Log output

join parallel: true
thread 'polars-7' panicked at crates/polars-ops/src/chunked_array/gather/chunked.rs:84:5:
assertion `left == right` failed: implementation error
  left: 1
 right: 2
stack backtrace:
   0:        0x115d075cc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf25a01452f1fddf1
   1:        0x1136f0bab - core::fmt::write::hc82d7397b637aa93
   2:        0x115cd8682 - std::io::Write::write_fmt::heccfafe0b2524d56
   3:        0x115d0ba11 - std::sys_common::backtrace::print::h3db69b6a35452bd2
   4:        0x115d0b1bc - std::panicking::default_hook::{{closure}}::h35892a1505b0b817
   5:        0x115d0d0aa - std::panicking::rust_panic_with_hook::h4b8ea642504a70b7
   6:        0x115d0bd24 - std::panicking::begin_panic_handler::{{closure}}::hbdccd4dc793c41a9
   7:        0x115d0bc79 - std::sys_common::backtrace::__rust_end_short_backtrace::h0b6dae306eeeae27
   8:        0x115d0bc66 - _rust_begin_unwind
   9:        0x115e8cb15 - core::panicking::panic_fmt::h0cc9a58d53e0de29
  10:        0x115e8cd9c - core::panicking::assert_failed_inner::he1c0eb4a65e511ae
  11:        0x115fed2ce - core::panicking::assert_failed::hf3357f52261446fc
  12:        0x114c783fb - polars_ops::chunked_array::gather::chunked::prepare_series::heb40e0d74014d510
  13:        0x114c7c240 - <polars_core::series::Series as polars_ops::chunked_array::gather::chunked::TakeChunked>::take_opt_chunked_unchecked::hf7b69aedeb78878e
  14:        0x113b79364 - rayon::iter::plumbing::bridge_producer_consumer::helper::h71f0e135aebee664
  15:        0x113b78df6 - rayon_core::thread_pool::ThreadPool::install::{{closure}}::h7e88e3dfbc982c73
  16:        0x11491ac7f - rayon_core::join::join_context::call_b::{{closure}}::h6e25bc4d64d28a29
  17:        0x11491a913 - <rayon_core::job::StackJob<L,F,R> as rayon_core::job::Job>::execute::h818d8bb30020c4e3
  18:        0x1161aaea0 - rayon_core::registry::WorkerThread::wait_until_cold::hdeb3a3b664061bac
  19:        0x115ab5c0f - std::sys_common::backtrace::__rust_begin_short_backtrace::hf7110fee9ffc5df7
  20:        0x115ab5a2f - core::ops::function::FnOnce::call_once{{vtable.shim}}::h8b243ed76220a206
  21:        0x115d1031b - std::sys::pal::unix::thread::Thread::new::thread_start::h4b0dcaf42b548e73
  22:     0x7ff80180818b - __pthread_start
Traceback (most recent call last):
  File "/Users/user1/projects/proj1/test.py", line 16, in <module>
    dfa.join(dfb, how="left", on=pl.col("replace_unique_id"))
  File "/Users/user1/.virtualenvs/env1/lib/python3.10/site-packages/polars/dataframe/frame.py", line 6403, in join
    self.lazy()
  File "/Users/user1/.virtualenvs/env1/lib/python3.10/site-packages/polars/lazyframe/frame.py", line 1816, in collect
    return wrap_df(ldf.collect(callback))
pyo3_runtime.PanicException: assertion `left == right` failed: implementation error
  left: 1
 right: 2

Issue description

When performing a join on two dataframes a PanicException is thrown. This example works fine on version 0.20.25.

Considering the example, one thing I noticed is that column "ds_start_date_right" of "dfb" returns different number of chunks as series vs physical series. Re-chunking dataframes before the join resolves the issue.

Expected behavior

Join does not error.

Installed versions

--------Version info---------
Polars:               1.0.0
Index type:           UInt32
Platform:             macOS-14.5-x86_64-i386-64bit
Python:               3.10.12 (main, Mar  4 2024, 12:35:22) [Clang 15.0.0 (clang-1500.0.40.1)]

----Optional dependencies----
adbc_driver_manager:  <not installed>
cloudpickle:          <not installed>
connectorx:           <not installed>
deltalake:            <not installed>
fastexcel:            <not installed>
fsspec:               <not installed>
gevent:               <not installed>
great_tables:         <not installed>
hvplot:               <not installed>
matplotlib:           <not installed>
nest_asyncio:         <not installed>
numpy:                1.23.5
openpyxl:             <not installed>
pandas:               1.5.3
pyarrow:              8.0.0
pydantic:             1.10.17
pyiceberg:            <not installed>
sqlalchemy:           1.4.37
torch:                <not installed>
xlsx2csv:             <not installed>
xlsxwriter:           3.2.0
@postatum postatum added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Jul 5, 2024
@c-peters c-peters added the accepted Ready for implementation label Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Ready for implementation bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants