Open marenwestermann opened 1 month ago
ping @MarcoGorelli
The problem here is that time_unit
determines the internal representation of the polars.datetime
and not the unit of the seventh parameter (which is always microseconds).
ms = pl.datetime(1990, 12, 31, 10, 0, 59, 999999, time_unit="ms").alias("ms")
ns = pl.datetime(1990, 12, 31, 10, 0, 59, 999999, time_unit="ns").alias("ns")
pl.select(ms, ns)
However, I think this should not silently fail and return null
or overflow when microseconds > 999999
which it does not do consistently.
# overflows to 1991-01-01 00:00:00.200
pl.select(pl.datetime(1990, 12, 31, 23, 59, 59, 1200000, time_unit="ns").alias("ns"))
# returns null
pl.select(pl.datetime(1990, 12, 31, 23, 59, 58, 1200000, time_unit="ns").alias("ns"))
Either it should fail, return null
or overflow?!
Checks
Reproducible example
Log output
No response
Issue description
It is possible to include nanoseconds when creating an expression with
polars.datetime
. However, when the expression gets evaluated, the result isnull
(see examples above).Expected behavior
A warning should be raised that
polars.datetime
cannot be evaluated if nanoseconds are included. Additionally, the option "ns" might need to be removed from the documentation of the parametertime_unit
.Installed versions