pola-rs / polars

Dataframes powered by a multithreaded, vectorized query engine, written in Rust
https://docs.pola.rs
Other
30.09k stars 1.94k forks source link

collect_schema() Panic #19450

Open Chuck321123 opened 1 week ago

Chuck321123 commented 1 week ago

Checks

Reproducible example

No reproducible example

Log output

thread '<unnamed>' panicked at crates\polars-python\src\conversion\mod.rs:263:22:
called `Result::unwrap()` on an `Err` value: PyErr { type: <class 'KeyboardInterrupt'>, value: KeyboardInterrupt(), traceback: Some(<traceback object at 0x000001BDEC3595C0>) }
stack backtrace:
   0:     0x7fff2e78da0f - ffi_select_with_compiled_path
   1:     0x7fff29b6b359 - PyInit_polars
   2:     0x7fff2e76db67 - ffi_select_with_compiled_path
   3:     0x7fff2e78ed98 - ffi_select_with_compiled_path
   4:     0x7fff2e78fbda - ffi_select_with_compiled_path
   5:     0x7fff2e78f726 - ffi_select_with_compiled_path
   6:     0x7fff2e78f67f - ffi_select_with_compiled_path
   7:     0x7fff2e78f666 - ffi_select_with_compiled_path
   8:     0x7fff2e8c8fd4 - ffi_select_with_compiled_path
   9:     0x7fff2e8c9440 - ffi_select_with_compiled_path
  10:     0x7fff2cee631d - ffi_select_with_compiled_path
  11:     0x7fff2d6815a2 - ffi_select_with_compiled_path
  12:     0x7fff2d09666d - ffi_select_with_compiled_path
  13:     0x7fff2d67ea91 - ffi_select_with_compiled_path
  14:     0x7fff7f8b69b8 - _PyEval_EvalFrameDefault
                               at \pcbuild\python\bytecodes.c:3150
  15:     0x7fff7f8b0686 - _PyEval_EvalFrame
                               at \include\internal\pycore_ceval.h:89
  16:     0x7fff7f8b0686 - _PyEval_Vector
                               at \python\ceval.c:1683
  17:     0x7fff7f8b0686 - PyEval_EvalCode
                               at \python\ceval.c:578
  18:     0x7fff7f8ac006 - builtin_exec_impl
                               at \python\bltinmodule.c:1096
  19:     0x7fff7f8a965e - builtin_exec
                               at \python\clinic\bltinmodule.c.h:586
  20:     0x7fff7f8b6403 - _PyEval_EvalFrameDefault
                               at \pcbuild\python\bytecodes.c:2966
  21:     0x7fff7f7a0fc4 - _PyFunction_Vectorcall
                               at \objects\call.c:424
  22:     0x7fff7f7a37c7 - _PyObject_VectorcallTstate
                               at \include\internal\pycore_call.h:92
  23:     0x7fff7f7a37c7 - method_vectorcall
                               at \objects\classobject.c:61
  24:     0x7fff7f7a0c89 - _PyVectorcall_Call
                               at \objects\call.c:283
  25:     0x7fff7f7a0df6 - _PyObject_Call
                               at \objects\call.c:354
  26:     0x7fff7f8b6f48 - _PyEval_EvalFrameDefault
                               at \pcbuild\python\bytecodes.c:3254
  27:     0x7fff7f8b0686 - _PyEval_EvalFrame
                               at \include\internal\pycore_ceval.h:89
  28:     0x7fff7f8b0686 - _PyEval_Vector
                               at \python\ceval.c:1683
  29:     0x7fff7f8b0686 - PyEval_EvalCode
                               at \python\ceval.c:578
  30:     0x7fff7f8ac006 - builtin_exec_impl
                               at \python\bltinmodule.c:1096
  31:     0x7fff7f8a965e - builtin_exec
                               at \python\clinic\bltinmodule.c.h:586
  32:     0x7fff7f8b6403 - _PyEval_EvalFrameDefault
                               at \pcbuild\python\bytecodes.c:2966
  33:     0x7fff7f7cddfa - _PyEval_EvalFrame
                               at \include\internal\pycore_ceval.h:89
  34:     0x7fff7f7cddfa - gen_send_ex2
                               at \objects\genobject.c:230
  35:     0x7fff7f7cdf8e - gen_send_ex
                               at \objects\genobject.c:274
  36:     0x7fff7f7cdf8e - gen_send
                               at \objects\genobject.c:297
  37:     0x7fff7f8b67a6 - _PyEval_EvalFrameDefault
                               at \pcbuild\python\bytecodes.c:3085
  38:     0x7fff7f7a0fc4 - _PyFunction_Vectorcall
                               at \objects\call.c:424
  39:     0x7fff7f7a37c7 - _PyObject_VectorcallTstate
                               at \include\internal\pycore_call.h:92
  40:     0x7fff7f7a37c7 - method_vectorcall
                               at \objects\classobject.c:61
  41:     0x7fff7f7a0c89 - _PyVectorcall_Call
                               at \objects\call.c:283
  42:     0x7fff7f7a0df6 - _PyObject_Call
                               at \objects\call.c:354
  43:     0x7fff7f8b6f48 - _PyEval_EvalFrameDefault
                               at \pcbuild\python\bytecodes.c:3254
  44:     0x7fff7f7cddfa - _PyEval_EvalFrame
                               at \include\internal\pycore_ceval.h:89
  45:     0x7fff7f7cddfa - gen_send_ex2
                               at \objects\genobject.c:230
  46:     0x7fff7f7cdea4 - PyGen_am_send
                               at \objects\genobject.c:267
  47:     0x7fffcc4f560b - <unknown>
  48:     0x7fffcc4f5c86 - <unknown>
  49:     0x7fff7f7eb48a - cfunction_vectorcall_O
                               at \objects\methodobject.c:509
  50:     0x7fff7f8dd0ea - _PyObject_VectorcallTstate
                               at \include\internal\pycore_call.h:92
  51:     0x7fff7f8dd0ea - context_run
                               at \python\context.c:668
  52:     0x7fff7f7eb1b1 - cfunction_vectorcall_FASTCALL_KEYWORDS
                               at \objects\methodobject.c:438
  53:     0x7fff7f7a0cbe - _PyVectorcall_Call
                               at \objects\call.c:271
  54:     0x7fff7f7a0df6 - _PyObject_Call
                               at \objects\call.c:354
  55:     0x7fff7f8b6f48 - _PyEval_EvalFrameDefault
                               at \pcbuild\python\bytecodes.c:3254
  56:     0x7fff7f8b0686 - _PyEval_EvalFrame
                               at \include\internal\pycore_ceval.h:89
  57:     0x7fff7f8b0686 - _PyEval_Vector
                               at \python\ceval.c:1683
  58:     0x7fff7f8b0686 - PyEval_EvalCode
                               at \python\ceval.c:578
  59:     0x7fff7f8ac006 - builtin_exec_impl
                               at \python\bltinmodule.c:1096
  60:     0x7fff7f8a965e - builtin_exec
                               at \python\clinic\bltinmodule.c.h:586
  61:     0x7fff7f7eb1b1 - cfunction_vectorcall_FASTCALL_KEYWORDS
                               at \objects\methodobject.c:438
  62:     0x7fff7f7a0619 - _PyObject_VectorcallTstate
                               at \include\internal\pycore_call.h:92
  63:     0x7fff7f7a0d65 - PyObject_Vectorcall
                               at \objects\call.c:325
  64:     0x7fff7f8b6c3d - _PyEval_EvalFrameDefault
                               at \pcbuild\python\bytecodes.c:2706
  65:     0x7fff7f7a0fc4 - _PyFunction_Vectorcall
                               at \objects\call.c:424
  66:     0x7fff7f7a0cbe - _PyVectorcall_Call
                               at \objects\call.c:271
  67:     0x7fff7f7a0df6 - _PyObject_Call
                               at \objects\call.c:354
  68:     0x7fff7f71fc0f - PyObject_Call
                               at \objects\call.c:379
  69:     0x7fff7f71fc0f - pymain_run_module
                               at \modules\main.c:300
  70:     0x7fff7f720acd - pymain_run_python
                               at \modules\main.c:623
  71:     0x7fff7f721018 - Py_RunMain
                               at \modules\main.c:709
  72:     0x7fff7f7210a2 - pymain_main
                               at \modules\main.c:739
  73:     0x7fff7f7210a2 - Py_Main
                               at \modules\main.c:751
  74:     0x7ff740cd1494 - invoke_main
                               at d:\agent\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:90
  75:     0x7ff740cd1494 - __scrt_common_main_seh
                               at d:\agent\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
  76:     0x7ffff4dd257d - BaseThreadInitThunk
  77:     0x7ffff54caf08 - RtlUserThreadStart
Traceback (most recent call last):

  File ~\anaconda3\envs\py3122\Lib\site-packages\spyder_kernels\customize\utils.py:209 in exec_encapsulate_locals
    exec_fun(compile(code_ast, filename, "exec"), globals)

  File \Filepath\script.py:2246
    Raw_Data_File_List2[i] = Raw_Data_File_List2[i].select(Raw_Data_File_List2[i].collect_schema().names()[0:1] + sorted(Raw_Data_File_List2[i].collect_schema().names()[1:]))

  File ~\anaconda3\envs\py3122\Lib\site-packages\polars\lazyframe\frame.py:2264 in collect_schema
    return Schema(self._ldf.collect_schema())

PanicException: called `Result::unwrap()` on an `Err` value: PyErr { type: <class 'KeyboardInterrupt'>, value: KeyboardInterrupt(), traceback: Some(<traceback object at 0x000001BDEC3595C0>) }

Issue description

So i did a keyboard interrupt, but got a panic before doing so. Thought I would report in case someone would be interested.

Expected behavior

That it doesnt panic

Installed versions

``` --------Version info--------- Polars: 1.8.2 Index type: UInt32 Platform: Windows-11-10.0.22631-SP0 Python: 3.12.2 | packaged by Anaconda, Inc. | (main, Feb 27 2024, 17:28:07) [MSC v.1916 64 bit (AMD64)] ----Optional dependencies---- adbc_driver_manager altair cloudpickle 3.0.0 connectorx deltalake fastexcel fsspec gevent great_tables matplotlib 3.9.2 nest_asyncio 1.6.0 numpy 2.0.2 openpyxl 3.1.5 pandas 2.2.3 pyarrow 17.0.0 pydantic pyiceberg sqlalchemy torch xlsx2csv xlsxwriter ```
ritchie46 commented 5 days ago

The to_object call is infallible as this is the trait definition. Normally this would be infallible, but it just is a very lucky keyboard interrupt.