You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "viirya (via GitHub)" <gi...@apache.org> on 2023/11/25 01:52:40 UTC
[PR] Cast from floating/timestamp to timestamp/floating [arrow-rs]
viirya opened a new pull request, #5123:
URL: https://github.com/apache/arrow-rs/pull/5123
# Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
Closes #5122.
# Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
# What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
# Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
<!---
If there are any breaking changes to public APIs, please add the `breaking change` label.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Cast from floating/timestamp to timestamp/floating [arrow-rs]
Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on code in PR #5123:
URL: https://github.com/apache/arrow-rs/pull/5123#discussion_r1405480668
##########
arrow-cast/src/cast.rs:
##########
@@ -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() => {
Review Comment:
Perhaps we could use `is_numeric` or is there a particular reason to exclude decimals?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Cast from floating/timestamp to timestamp/floating [arrow-rs]
Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on code in PR #5123:
URL: https://github.com/apache/arrow-rs/pull/5123#discussion_r1405670182
##########
arrow-cast/src/cast.rs:
##########
@@ -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() => {
Review Comment:
No, I plan to add decimals too (in a separate PR).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Cast from numeric/timestamp to timestamp/numeric [arrow-rs]
Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold merged PR #5123:
URL: https://github.com/apache/arrow-rs/pull/5123
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Cast from floating/timestamp to timestamp/floating [arrow-rs]
Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on code in PR #5123:
URL: https://github.com/apache/arrow-rs/pull/5123#discussion_r1404702004
##########
arrow-cast/src/cast.rs:
##########
@@ -4719,6 +4726,35 @@ mod tests {
assert_eq!(&actual, &expected);
}
+ #[test]
+ fn test_cast_floating_to_timestamp() {
+ 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]);
Review Comment:
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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Cast from floating/timestamp to timestamp/floating [arrow-rs]
Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on code in PR #5123:
URL: https://github.com/apache/arrow-rs/pull/5123#discussion_r1405670182
##########
arrow-cast/src/cast.rs:
##########
@@ -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() => {
Review Comment:
<del>No, I plan to add decimals too (in a separate PR).</del>
Let me add it here with test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Cast from numeric/timestamp to timestamp/numeric [arrow-rs]
Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on PR #5123:
URL: https://github.com/apache/arrow-rs/pull/5123#issuecomment-1827567309
Seems to be a slight issue with can_cast_types
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org