-
Notifications
You must be signed in to change notification settings - Fork 861
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 date conversion if timestamp below unixtimestamp #4323
Conversation
Thanks @tustvold I will address the comments. Probably we need to review all tests for cast and use new syntax instead of downcast? |
@@ -1853,7 +1853,7 @@ pub fn cast_with_options( | |||
if time_array.is_null(i) { | |||
b.append_null(); | |||
} else { | |||
b.append_value((time_array.value(i) / from_size) as i32); | |||
b.append_value(num::integer::div_floor::<i64>(time_array.value(i), from_size) as i32); |
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.
Something like
let pre_epoch_adjustment = if value(i) < 0 { -1 } else { 0 };
b.append_value(pre_epoch_adjustment + (time_array.value(i) / from_size) as i32);
might be faster (because it skips all the check made by div_floor
) ?
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.
If you look at the implementation of div floor, that is what it is implemented as
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.
Can this convo be resolved then?
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.
@tustvold you'er right. My ide led me to the BigInt implementation of div_floor which is necessarily more complex, but not relevant here.
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.
Thank you, looks good to me
@@ -9172,4 +9172,41 @@ mod tests { | |||
); | |||
assert!(casted_array.is_err()); | |||
} | |||
|
|||
#[test] | |||
fn test_cast_below_unixtimestamp() { |
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 confirmed this test fails on master
Which issue does this PR close?
Closes #4211 .
Rationale for this change
Fix date conversion if timestamp below unixtimestamp
What changes are included in this PR?
Are there any user-facing changes?
No