You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/08/10 23:12:46 UTC

[GitHub] [arrow-rs] bjchambers opened a new issue #685: Implement casting between duration/intervals and numbers

bjchambers opened a new issue #685:
URL: https://github.com/apache/arrow-rs/issues/685


   **Is your feature request related to a problem or challenge? Please describe what you are trying to do.**
   
   After computing the days between two timestamps to produce an interval days, it would be useful to be able to convert that to a number. This is helpful because (1) some output formats don't support durations/intervals and (2) it may be desirable to do math on the number of days / months / seconds.
   
   **Describe the solution you'd like**
   
   The cast kernel extended to support casting from Duration and Interval Types to at least the corresponding primitive type.
   
   **Describe alternatives you've considered**
   A clear and concise description of any alternative solutions or features you've considered.
   
   **Additional context**
   Add any other context or screenshots about the feature request here.
   


-- 
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



[GitHub] [arrow-rs] alamb closed issue #685: Implement casting between duration/intervals and numbers

Posted by GitBox <gi...@apache.org>.
alamb closed issue #685:
URL: https://github.com/apache/arrow-rs/issues/685


   


-- 
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



[GitHub] [arrow-rs] bjchambers edited a comment on issue #685: Implement casting between duration/intervals and numbers

Posted by GitBox <gi...@apache.org>.
bjchambers edited a comment on issue #685:
URL: https://github.com/apache/arrow-rs/issues/685#issuecomment-896946545


   For the most part this seems straightforward to add -- the only weird one is `IntervalDayTime`. The underlying value is an i64 representing the 32-bit days, and the 32-bit milliseconds. A naive cast would produce a somewhat meaningless 64-bit integer value. An alternative would be to allow casting it to the 32-bit days (in some sense "rounding down" to the number of days). Or perhaps both (cast to 64-bit value preserves both parts, cast to 32-bit value returns the days)?
   
   Another option would be to convert to a `f64`, where the integer part is the number of days, and the fractional part is the ratio of the millisecond part to the number of milliseconds in a day.


-- 
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



[GitHub] [arrow-rs] bjchambers commented on issue #685: Implement casting between duration/intervals and numbers

Posted by GitBox <gi...@apache.org>.
bjchambers commented on issue #685:
URL: https://github.com/apache/arrow-rs/issues/685#issuecomment-896946545


   For the most part this seems straightforward to add -- the only weird one is `IntervalDayTime`. The underlying value is an i64 representing the 32-bit days, and the 32-bit milliseconds. A naive cast would produce a somewhat meaningless 64-bit integer value. An alternative would be to allow casting it to the 32-bit days (in some sense "rounding it" to the number of days). Or perhaps both (cast to 64-bit value preserves both parts, cast to 32-bit value returns the days)?


-- 
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



[GitHub] [arrow-rs] jorgecarleitao commented on issue #685: Implement casting between duration/intervals and numbers

Posted by GitBox <gi...@apache.org>.
jorgecarleitao commented on issue #685:
URL: https://github.com/apache/arrow-rs/issues/685#issuecomment-897144631


   imo the `IntervalDayTime` could be left as is and instead offer some API to extract each part of it (as i32 arrays).


-- 
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



[GitHub] [arrow-rs] alamb commented on issue #685: Implement casting between duration/intervals and numbers

Posted by GitBox <gi...@apache.org>.
alamb commented on issue #685:
URL: https://github.com/apache/arrow-rs/issues/685#issuecomment-1016364455


   It seems as if we are going with a dual approach here: 
   1. Allow casting to the underlying primitive type - #1196 
   2. Additional temporal kernels to extract parts of it, e.g https://docs.rs/arrow/7.0.0/arrow/compute/kernels/temporal/index.html#


-- 
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



[GitHub] [arrow-rs] bjchambers commented on issue #685: Implement casting between duration/intervals and numbers

Posted by GitBox <gi...@apache.org>.
bjchambers commented on issue #685:
URL: https://github.com/apache/arrow-rs/issues/685#issuecomment-897877620


   That could work. The `IntervalDayTime` would go to `i64` then, and you could always just do a `unary` operation over that to do the math.


-- 
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