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

Cast from numeric/timestamp to timestamp/numeric #5123

Merged
merged 4 commits into from
Nov 27, 2023

Conversation

viirya
Copy link
Member

@viirya viirya commented Nov 25, 2023

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?

@github-actions github-actions bot added the arrow Changes to the arrow crate label Nov 25, 2023
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]);
Copy link
Member Author

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.

@@ -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() => {
Copy link
Contributor

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?

Copy link
Member Author

@viirya viirya Nov 27, 2023

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.

@viirya viirya changed the title Cast from floating/timestamp to timestamp/floating Cast from numeric/timestamp to timestamp/numeric Nov 27, 2023
@tustvold
Copy link
Contributor

Seems to be a slight issue with can_cast_types

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cast from floating/timestamp to timestamp/floating
2 participants