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

Expression panics instead of showing ColumnNotFoundError #14974

Closed
2 tasks done
edavisau opened this issue Mar 11, 2024 · 0 comments · Fixed by #15006
Closed
2 tasks done

Expression panics instead of showing ColumnNotFoundError #14974

edavisau opened this issue Mar 11, 2024 · 0 comments · Fixed by #15006
Assignees
Labels
A-optimizer Area: plan optimization A-panic Area: code that results in panic exceptions accepted Ready for implementation bug Something isn't working P-medium Priority: medium python Related to Python Polars

Comments

@edavisau
Copy link
Contributor

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

df = pl.DataFrame()

result = df.select(1 / (1 + pl.col("a")))
print(result)

Log output

thread '<unnamed>' panicked at crates/polars-plan/src/logical_plan/optimizer/simplify_expr.rs:296:14:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0: rust_begin_unwind
             at /rustc/dd430bc8c22f57992ec1457a87437d14283fdd65/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/dd430bc8c22f57992ec1457a87437d14283fdd65/library/core/src/panicking.rs:72:14
   2: core::panicking::panic
             at /rustc/dd430bc8c22f57992ec1457a87437d14283fdd65/library/core/src/panicking.rs:127:5
   3: polars_plan::logical_plan::optimizer::simplify_expr::string_addition_to_linear_concat
   4: <polars_plan::logical_plan::optimizer::simplify_expr::SimplifyExprRule as polars_plan::logical_plan::optimizer::stack_opt::OptimizationRule>::optimize_expr
   5: polars_plan::logical_plan::optimizer::stack_opt::StackOptimizer::optimize_loop
   6: polars_plan::logical_plan::optimizer::optimize
   7: polars_lazy::frame::LazyFrame::optimize_with_scratch
   8: polars_lazy::frame::LazyFrame::prepare_collect
   9: polars_lazy::frame::LazyFrame::collect
  10: polars::lazyframe::_::<impl polars::lazyframe::PyLazyFrame>::__pymethod_collect__
  11: pyo3::impl_::trampoline::trampoline
  12: <unknown>
  13: _PyEval_EvalFrameDefault
  14: _PyFunction_Vectorcall
  15: PyObject_Call
  16: _PyEval_EvalFrameDefault
  17: <unknown>
  18: _PyEval_EvalFrameDefault
  19: _PyFunction_Vectorcall
  20: _PyEval_EvalFrameDefault
  21: <unknown>
  22: PyEval_EvalCode
  23: <unknown>
  24: <unknown>
  25: <unknown>
  26: _PyRun_InteractiveLoopObject
  27: _PyRun_AnyFileObject
  28: PyRun_AnyFileExFlags
  29: <unknown>
  30: Py_BytesMain
  31: <unknown>
  32: __libc_start_main
  33: _start

Issue description

The ordering/choice of the operators matter to cause this panic
e.g. 1 / (pl.col("a") + 1) and 1 / (1 - pl.col("a")) are both fine

Expected behavior

Code above should give me the correct message

ColumnNotFoundError: a

Installed versions

--------Version info---------
Polars:               0.20.15
Index type:           UInt32
Platform:             Linux-5.15.0-91-generic-x86_64-with-glibc2.35
Python:               3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]

----Optional dependencies----
adbc_driver_manager:  <not installed>
cloudpickle:          2.2.1
connectorx:           <not installed>
deltalake:            <not installed>
fastexcel:            <not installed>
fsspec:               2023.1.0
gevent:               <not installed>
hvplot:               <not installed>
matplotlib:           3.7.0
numpy:                1.26.2
openpyxl:             3.1.2
pandas:               1.5.3
pyarrow:              14.0.1
pydantic:             1.10.5
pyiceberg:            <not installed>
pyxlsb:               <not installed>
sqlalchemy:           1.4.46
xlsx2csv:             <not installed>
xlsxwriter:           <not installed>
@edavisau edavisau added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Mar 11, 2024
@orlp orlp added accepted Ready for implementation A-optimizer Area: plan optimization A-panic Area: code that results in panic exceptions P-medium Priority: medium and removed needs triage Awaiting prioritization by a maintainer labels Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-optimizer Area: plan optimization A-panic Area: code that results in panic exceptions accepted Ready for implementation bug Something isn't working P-medium Priority: medium python Related to Python Polars
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants