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

feat!: Restrict casting for temporal data types #14142

Merged
merged 1 commit into from
Jun 4, 2024
Merged

Conversation

stinodego
Copy link
Member

@stinodego stinodego commented Jan 31, 2024

Ref #14124, #16440

Following up on #14127

Changes

  • Casting logical types Date, Time, Datetime, and Duration no longer falls back to casting the physical type. This means certain casts are disabled, such as Duration -> Time or Datetime -> Boolean, that could result in nonsense.
  • Update unsupported cast failures from ComputeError to InvalidOperationError. This should be considered a breaking change.

Example

Before

>>> from datetime import timedelta
>>> s = pl.Series([timedelta(days=1)])
>>> s.cast(pl.Time)
shape: (1,)
Series: '' [time]
[
        00:01:26.400
]

After

>>> s.cast(pl.Time)
Traceback (most recent call last):
...
polars.exceptions.InvalidOperationError: casting from Duration(Microseconds) to Time not supported

@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Jan 31, 2024
@stinodego stinodego marked this pull request as ready for review February 1, 2024 09:42
@stinodego stinodego marked this pull request as draft February 8, 2024 22:51
@stinodego stinodego marked this pull request as ready for review February 15, 2024 16:14
@stinodego stinodego changed the title fix: Disable some logical casts fix: Restrict casting for temporal data types Feb 16, 2024
@stinodego stinodego changed the title fix: Restrict casting for temporal data types feat!: Restrict casting for temporal data types Mar 2, 2024
@github-actions github-actions bot added breaking Change that breaks backwards compatibility enhancement New feature or an improvement of an existing feature labels Mar 2, 2024
@stinodego stinodego added this to the 1.0.0 milestone Mar 2, 2024
@stinodego stinodego self-assigned this May 24, 2024
@stinodego stinodego requested a review from reswqa as a code owner May 24, 2024 10:14
Copy link

codecov bot commented May 24, 2024

Codecov Report

Attention: Patch coverage is 79.68750% with 13 lines in your changes missing coverage. Please review.

Project coverage is 81.48%. Comparing base (9912af0) to head (33c6d0d).
Report is 2 commits behind head on main.

Files Patch % Lines
.../polars-core/src/chunked_array/logical/duration.rs 63.15% 7 Missing ⚠️
.../polars-core/src/chunked_array/logical/datetime.rs 76.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14142      +/-   ##
==========================================
- Coverage   81.49%   81.48%   -0.01%     
==========================================
  Files        1416     1416              
  Lines      186880   186895      +15     
  Branches     3023     3023              
==========================================
+ Hits       152289   152290       +1     
- Misses      34059    34073      +14     
  Partials      532      532              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@stinodego stinodego merged commit ab82b22 into main Jun 4, 2024
26 checks passed
@stinodego stinodego deleted the logical-casts branch June 4, 2024 08:35
@c-peters c-peters added the accepted Ready for implementation label Jun 9, 2024
Wouittone pushed a commit to Wouittone/polars that referenced this pull request Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Ready for implementation breaking Change that breaks backwards compatibility enhancement New feature or an improvement of an existing feature fix Bug fix python Related to Python Polars rust Related to Rust Polars
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants