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(rust): date_range with unit microseconds was producing incorrect results #9413

Merged
merged 5 commits into from
Jun 19, 2023

Conversation

MarcoGorelli
Copy link
Collaborator

closes #9409

@github-actions github-actions bot added fix Bug fix rust Related to Rust Polars labels Jun 17, 2023
@MarcoGorelli MarcoGorelli force-pushed the date-range-micro-rust branch 2 times, most recently from 7584c4f to 4e46771 Compare June 17, 2023 08:00
@MarcoGorelli MarcoGorelli force-pushed the date-range-micro-rust branch from 4e46771 to 438ea2c Compare June 17, 2023 08:04
Comment on lines 67 to 69
TimeUnit::Nanoseconds => (start.timestamp_nanos(), stop.timestamp_nanos()),
TimeUnit::Microseconds => (
start.timestamp() + start.timestamp_subsec_micros() as i64,
stop.timestamp() + stop.timestamp_subsec_millis() as i64,
),
TimeUnit::Microseconds => (start.timestamp_micros(), stop.timestamp_micros()),
TimeUnit::Milliseconds => (start.timestamp_millis(), stop.timestamp_millis()),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the difference was introduced in https://github.com/pola-rs/polars/pull/2711/files, but I can't tell why - @ritchie46 do you happen to remember?

Copy link
Member

Choose a reason for hiding this comment

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

No, no idea. It has been a while. :)

@MarcoGorelli MarcoGorelli marked this pull request as ready for review June 17, 2023 08:35
@MarcoGorelli MarcoGorelli requested a review from ritchie46 as a code owner June 17, 2023 08:35
Comment on lines 67 to 69
TimeUnit::Nanoseconds => (start.timestamp_nanos(), stop.timestamp_nanos()),
TimeUnit::Microseconds => (
start.timestamp() + start.timestamp_subsec_micros() as i64,
stop.timestamp() + stop.timestamp_subsec_millis() as i64,
),
TimeUnit::Microseconds => (start.timestamp_micros(), stop.timestamp_micros()),
TimeUnit::Milliseconds => (start.timestamp_millis(), stop.timestamp_millis()),
Copy link
Member

Choose a reason for hiding this comment

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

No, no idea. It has been a while. :)

@@ -110,3 +107,84 @@ pub fn time_range(
let stop = time_to_time64ns(&stop);
time_range_impl(name, start, stop, every, closed)
}

#[cfg(test)]
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 move these tests to the integration tests? This will save a lot of compile times as every test module is compiled in a separate binary. In the aggregation tests we can accumulate that.

@ritchie46 ritchie46 merged commit 80d0303 into pola-rs:main Jun 19, 2023
c-peters pushed a commit to c-peters/polars that referenced this pull request Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

polars_time::date_range produces incorrect results when time unit is Milliseconds
2 participants