-
Notifications
You must be signed in to change notification settings - Fork 827
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
Cast from numeric/timestamp to timestamp/numeric #5123
Conversation
let array = Int64Array::from(vec![Some(2), Some(10), None]); | ||
let expected = cast(&array, &DataType::Timestamp(TimeUnit::Microsecond, None)).unwrap(); | ||
|
||
let array = Float32Array::from(vec![Some(2.0), Some(10.6), None]); |
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 don't add test for Float16Array as casting between Float16 and Int64 is not supported by cast kernel now. I will make it in a separate PR later.
arrow-cast/src/cast.rs
Outdated
@@ -1634,24 +1634,31 @@ pub fn cast_with_options( | |||
.unary::<_, Time64MicrosecondType>(|x| x / (NANOSECONDS / MICROSECONDS)), | |||
)), | |||
|
|||
(Timestamp(TimeUnit::Second, _), _) if to_type.is_integer() => { | |||
// Timestamp to integer/floating | |||
(Timestamp(TimeUnit::Second, _), _) if to_type.is_integer() || to_type.is_floating() => { |
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.
Perhaps we could use is_numeric
or is there a particular reason to exclude decimals?
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.
No, I plan to add decimals too (in a separate PR).
Let me add it here with test.
Seems to be a slight issue with can_cast_types |
Which issue does this PR close?
Closes #5122.
Rationale for this change
What changes are included in this PR?
Are there any user-facing changes?