-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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: datetime operations (e.g. .dt.year) were raising when null values were backed by out-of-range integers #15420
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -151,7 +151,7 @@ pub fn timestamp_s_to_datetime_opt(seconds: i64) -> Option<NaiveDateTime> { | |
/// converts a `i64` representing a `timestamp(ms)` to [`NaiveDateTime`] | ||
#[inline] | ||
pub fn timestamp_ms_to_datetime(v: i64) -> NaiveDateTime { | ||
timestamp_ms_to_datetime_opt(v).expect("invalid or out-of-range datetime") | ||
timestamp_ms_to_datetime_opt(v).expect(&format!("invalid or out-of-range datetime: {v}")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yikes. This does a heap allocation and string format for very function call. Which I expect are a lot. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry was just debugging 😄 when I saw what looked like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i.e.:
|
||
} | ||
|
||
/// converts a `i64` representing a `timestamp(ms)` to [`NaiveDateTime`] | ||
|
@@ -164,7 +164,7 @@ pub fn timestamp_ms_to_datetime_opt(v: i64) -> Option<NaiveDateTime> { | |
/// converts a `i64` representing a `timestamp(us)` to [`NaiveDateTime`] | ||
#[inline] | ||
pub fn timestamp_us_to_datetime(v: i64) -> NaiveDateTime { | ||
timestamp_us_to_datetime_opt(v).expect("invalid or out-of-range datetime") | ||
timestamp_us_to_datetime_opt(v).expect(&format!("invalid or out-of-range datetime: {v}")) | ||
} | ||
|
||
/// converts a `i64` representing a `timestamp(us)` to [`NaiveDateTime`] | ||
|
@@ -177,7 +177,7 @@ pub fn timestamp_us_to_datetime_opt(v: i64) -> Option<NaiveDateTime> { | |
/// converts a `i64` representing a `timestamp(ns)` to [`NaiveDateTime`] | ||
#[inline] | ||
pub fn timestamp_ns_to_datetime(v: i64) -> NaiveDateTime { | ||
timestamp_ns_to_datetime_opt(v).expect("invalid or out-of-range datetime") | ||
timestamp_ns_to_datetime_opt(v).expect(&format!("invalid or out-of-range datetime: {v}")) | ||
} | ||
|
||
/// converts a `i64` representing a `timestamp(ns)` to [`NaiveDateTime`] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you collect a Vec of options here and then create a PrimitiveArray. This will be a double allocation. You can create the array directly from the iterator.