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

PanicException broadcasting struct of datetime #19300

Closed
2 tasks done
gab23r opened this issue Oct 18, 2024 · 1 comment
Closed
2 tasks done

PanicException broadcasting struct of datetime #19300

gab23r opened this issue Oct 18, 2024 · 1 comment
Labels
bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars

Comments

@gab23r
Copy link
Contributor

gab23r commented Oct 18, 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
from datetime import datetime

s_struct = pl.Series([{'c': datetime(1970, 1, 1, 0, 0)}])
schema = pl.DataFrame().with_columns(a = pl.Series(range(10)), b = s_struct).schema
# pyo3_runtime.PanicException: called `Result::unwrap()` on an `Err` value: SchemaMismatch(ErrString("unexpected value while building Series of type Datetime(Microseconds, None); found value of type Datetime(Microseconds, None): 1970-01-01 00:00:00"))

Log output

thread '<unnamed>' panicked at crates/polars-core/src/scalar/mod.rs:46:92:
called `Result::unwrap()` on an `Err` value: SchemaMismatch(ErrString("unexpected value while building Series of type Datetime(Microseconds, None); found value of type Datetime(Microseconds, None): 1970-01-01 00:00:00"))
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/robin_ga/dev/patito/.venv/lib/python3.10/site-packages/polars/dataframe/frame.py", line 914, in schema
    return Schema(zip(self.columns, self.dtypes))
  File "/Users/robin_ga/dev/patito/.venv/lib/python3.10/site-packages/polars/dataframe/frame.py", line 883, in dtypes
    return self._df.dtypes()
pyo3_runtime.PanicException: called `Result::unwrap()` on an `Err` value: SchemaMismatch(ErrString("unexpected value while building Series of type Datetime(Microseconds, None); found value of type Datetime(Microseconds, None): 1970-01-01 00:00:00"))

Issue description

Bug coming from the patito test suite

Expected behavior

The struct series get broadcasted with no error

Installed versions

--------Version info---------
Polars:              1.9.0
Index type:          UInt32
Platform:            macOS-14.1.1-x86_64-i386-64bit
Python:              3.10.11 (v3.10.11:7d4cc5aa85, Apr  4 2023, 19:05:19) [Clang 13.0.0 (clang-1300.0.29.30)]

----Optional dependencies----
adbc_driver_manager  <not installed>
altair               <not installed>
cloudpickle          <not installed>
connectorx           <not installed>
deltalake            <not installed>
fastexcel            <not installed>
fsspec               <not installed>
gevent               <not installed>
great_tables         <not installed>
matplotlib           <not installed>
nest_asyncio         1.6.0
numpy                2.0.2
openpyxl             <not installed>
pandas               2.2.3
pyarrow              17.0.0
pydantic             2.9.2
pyiceberg            <not installed>
sqlalchemy           <not installed>
torch                <not installed>
xlsx2csv             <not installed>
xlsxwriter           <not installed>```

</details>
@gab23r gab23r added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Oct 18, 2024
@cmdlineluser
Copy link
Contributor

This does run on main, I believe it has already been fixed.

>>> schema
# Schema([('a', Int64),
#       ('b', Struct({'c': Datetime(time_unit='us', time_zone=None)}))])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars
Projects
None yet
Development

No branches or pull requests

3 participants