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

dtype ingored in pl.lit between date and datetime #16012

Open
2 tasks done
gab23r opened this issue May 2, 2024 · 1 comment · May be fixed by #16018
Open
2 tasks done

dtype ingored in pl.lit between date and datetime #16012

gab23r opened this issue May 2, 2024 · 1 comment · May be fixed by #16018
Labels
A-timeseries Area: date/time functionality bug Something isn't working P-low Priority: low python Related to Python Polars

Comments

@gab23r
Copy link
Contributor

gab23r commented May 2, 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
import datetime

some_datetime = datetime.datetime.now()
pl.select(pl.lit(some_datetime, dtype=pl.Date)).schema.                                 #   <<< Date
# OrderedDict([('literal', Datetime(time_unit='us', time_zone=None))])         #   <<< Datetime


some_date = datetime.date.today()
pl.select(pl.lit(some_date, dtype=pl.Datetime)).schema                                  #   <<< Datetime
# OrderedDict([('literal', Date)])                                #   <<< Date

Log output

No response

Issue description

dtype is silently ignored in these cases (see above).

Expected behavior

I would except either a cast to the provided dtype or a raise.

Installed versions

--------Version info---------
Polars:               0.20.23
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>
cloudpickle:          <not installed>
connectorx:           <not installed>
deltalake:            <not installed>
fastexcel:            <not installed>
fsspec:               <not installed>
gevent:               <not installed>
hvplot:               <not installed>
matplotlib:           <not installed>
nest_asyncio:         1.6.0
numpy:                1.26.4
openpyxl:             <not installed>
pandas:               2.2.0
pyarrow:              15.0.0
pydantic:             <not installed>
pyiceberg:            <not installed>
pyxlsb:               <not installed>
sqlalchemy:           <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 May 2, 2024
@MarcoGorelli MarcoGorelli added A-timeseries Area: date/time functionality P-low Priority: low and removed needs triage Awaiting prioritization by a maintainer labels May 2, 2024
@mcrumiller
Copy link
Contributor

This is happening on the python side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-timeseries Area: date/time functionality bug Something isn't working P-low Priority: low python Related to Python Polars
Projects
Status: Ready
Development

Successfully merging a pull request may close this issue.

3 participants