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

fix: Ensure pl.datetime returns empty column when input columns are empty #20278

Merged

Conversation

haocheng6
Copy link
Contributor

@haocheng6 haocheng6 commented Dec 13, 2024

Fixes #19696

In the new code, the returned column is named as "datetime" for consistency. The column name issue of pl.datetime is tracked by #18808.

@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Dec 13, 2024
Copy link

codecov bot commented Dec 13, 2024

Codecov Report

Attention: Patch coverage is 84.21053% with 3 lines in your changes missing coverage. Please review.

Project coverage is 79.61%. Comparing base (f599e88) to head (8b48562).
Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
...ates/polars-plan/src/dsl/function_expr/temporal.rs 84.21% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #20278      +/-   ##
==========================================
+ Coverage   79.59%   79.61%   +0.02%     
==========================================
  Files        1565     1565              
  Lines      218462   218344     -118     
  Branches     2475     2478       +3     
==========================================
- Hits       173885   173841      -44     
+ Misses      44010    43936      -74     
  Partials      567      567              

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

},
_ => {
polars_ensure!(
time_zone.is_none(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be an assert. We panic on missing features.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the info! Updated in 8b48562. The existing polars_ensure on line 200 has also been replaced with assert.

@@ -78,6 +81,29 @@ pub(super) fn datetime(
use polars_core::export::chrono::NaiveDate;
use polars_core::utils::CustomIterTools;

if s.iter().any(|s| s.is_empty()) {
return Ok(Column::new_empty(
PlSmallStr::from_static("datetime"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we hoist this into a variable at the start of the function? Then we can reuse that here and on line 207.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Updated in 8b48562.

@ritchie46
Copy link
Member

Thank you @haocheng6

@ritchie46 ritchie46 merged commit 8baddbc into pola-rs:main Dec 15, 2024
25 checks passed
@haocheng6 haocheng6 deleted the 19696-fix-datetime-to-return-empty-result branch December 15, 2024 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Filter and datetime do not work together
2 participants