svraka opened a new issue, #44174:
URL: https://github.com/apache/arrow/issues/44174

   ### Describe the enhancement requested
   
   The data.table package introduces integer based date and time-of-day 
classes, `IDate`, and `ITime`. Besides lower storage/memory cost, they offer 
faster sorting and grouping. It would be useful if Arrow fully supported these 
classes.
   
   As `IDate` inherits from `Date`, Arrow correctly converts it to `date32` but 
there is no way to control which R type `date32` is converted to.
   
   ``` r
   library(arrow)
   library(data.table)
   ```
   
   ``` r
   id <- as.IDate(Sys.Date())
   str(id)
   #>  IDate[1:1], format: "2024-09-19"
   chunked_array(id)
   #> ChunkedArray
   #> <date32[day]>
   #> [
   #>   [
   #>     2024-09-19
   #>   ]
   #> ]
   str(as.vector(chunked_array(id)))
   #>  Date[1:1], format: "2024-09-19"
   ```
   
   `ITime` can be correctly round-tripped, if I’m not mistaken this is because 
Arrow [preserves 
metadata](https://arrow.apache.org/docs/r/articles/metadata.html#r-object-attributes).
   
   ``` r
   it <- as.ITime(Sys.time())
   str(it)
   #>  'ITime' int 17:27:28
   chunked_array(it)
   #> ChunkedArray
   #> <character(0)>
   #> [
   #>   [
   #>     62848
   #>   ]
   #> ]
   str(as.vector(chunked_array(it)))
   #>  'ITime' int 17:27:28
   ```
   
   Although this works, converting to `time32` would improve interoperability 
with other languages. data.table users would need some way to control how 
`time32` is converted back is this case too.
   
   <sup>Created on 2024-09-19 with [reprex 
v2.1.1](https://reprex.tidyverse.org)</sup>
   
   <details style="margin-bottom:10px;">
   <summary>
   Session info
   </summary>
   
   ``` r
   sessioninfo::session_info()
   #> ─ Session info 
─────────────────────────────────────────────────────────────────────────────────────
   #>  setting  value
   #>  version  R version 4.4.1 (2024-06-14 ucrt)
   #>  os       Windows 10 x64 (build 19045)
   #>  system   x86_64, mingw32
   #>  ui       RTerm
   #>  language (EN)
   #>  collate  Hungarian_Hungary.utf8
   #>  ctype    Hungarian_Hungary.utf8
   #>  tz       Europe/Budapest
   #>  date     2024-09-19
   #>  pandoc   3.2 @ C:/Users/SvrakaA/scoop/shims/ (via rmarkdown)
   #> 
   #> ─ Packages 
─────────────────────────────────────────────────────────────────────────────────────────
   #>  package     * version  date (UTC) lib source
   #>  arrow       * 17.0.0.1 2024-08-21 [1] CRAN (R 4.4.1)
   #>  assertthat    0.2.1    2019-03-21 [1] CRAN (R 4.4.0)
   #>  backports     1.5.0    2024-05-23 [1] CRAN (R 4.4.0)
   #>  base64url     1.4      2018-05-14 [1] CRAN (R 4.4.0)
   #>  bit           4.0.5    2022-11-15 [1] CRAN (R 4.4.0)
   #>  bit64         4.0.5    2020-08-30 [1] CRAN (R 4.4.0)
   #>  callr         3.7.6    2024-03-25 [1] CRAN (R 4.4.0)
   #>  cellranger    1.1.0    2016-07-27 [1] CRAN (R 4.4.0)
   #>  cli           3.6.3    2024-06-21 [1] CRAN (R 4.4.1)
   #>  clipr         0.8.0    2022-02-22 [1] CRAN (R 4.4.0)
   #>  codetools     0.2-20   2024-03-31 [2] CRAN (R 4.4.1)
   #>  colorspace    2.1-1    2024-07-26 [1] CRAN (R 4.4.1)
   #>  data.table  * 1.16.0   2024-08-27 [1] CRAN (R 4.4.1)
   #>  digest        0.6.37   2024-08-19 [1] CRAN (R 4.4.1)
   #>  dplyr       * 1.1.4    2023-11-17 [1] CRAN (R 4.4.0)
   #>  evaluate      1.0.0    2024-09-17 [1] CRAN (R 4.4.1)
   #>  fansi         1.0.6    2023-12-08 [1] CRAN (R 4.4.0)
   #>  fastmap       1.2.0    2024-05-15 [1] CRAN (R 4.4.0)
   #>  forcats     * 1.0.0    2023-01-29 [1] CRAN (R 4.4.0)
   #>  fs            1.6.4    2024-04-25 [1] CRAN (R 4.4.0)
   #>  generics      0.1.3    2022-07-05 [1] CRAN (R 4.4.0)
   #>  ggplot2     * 3.5.1    2024-04-23 [1] CRAN (R 4.4.0)
   #>  glue          1.7.0    2024-01-09 [1] CRAN (R 4.4.0)
   #>  gtable        0.3.5    2024-04-22 [1] CRAN (R 4.4.0)
   #>  hms           1.1.3    2023-03-21 [1] CRAN (R 4.4.0)
   #>  htmltools     0.5.8.1  2024-04-04 [1] CRAN (R 4.4.0)
   #>  igraph        2.0.3    2024-03-13 [1] CRAN (R 4.4.0)
   #>  knitr         1.48     2024-07-07 [1] CRAN (R 4.4.1)
   #>  lifecycle     1.0.4    2023-11-07 [1] CRAN (R 4.4.0)
   #>  lubridate   * 1.9.3    2023-09-27 [1] CRAN (R 4.4.0)
   #>  magrittr      2.0.3    2022-03-30 [1] CRAN (R 4.4.0)
   #>  munsell       0.5.1    2024-04-01 [1] CRAN (R 4.4.0)
   #>  pillar        1.9.0    2023-03-22 [1] CRAN (R 4.4.0)
   #>  pkgconfig     2.0.3    2019-09-22 [1] CRAN (R 4.4.0)
   #>  processx      3.8.4    2024-03-16 [1] CRAN (R 4.4.0)
   #>  ps            1.8.0    2024-09-12 [1] CRAN (R 4.4.1)
   #>  purrr       * 1.0.2    2023-08-10 [1] CRAN (R 4.4.0)
   #>  R6            2.5.1    2021-08-19 [1] CRAN (R 4.4.0)
   #>  readr       * 2.1.5    2024-01-10 [1] CRAN (R 4.4.0)
   #>  readxl      * 1.4.3    2023-07-06 [1] CRAN (R 4.4.0)
   #>  reprex        2.1.1    2024-07-06 [1] CRAN (R 4.4.1)
   #>  rlang         1.1.4    2024-06-04 [1] CRAN (R 4.4.0)
   #>  rmarkdown     2.28     2024-08-17 [1] CRAN (R 4.4.1)
   #>  rstudioapi    0.16.0   2024-03-24 [1] CRAN (R 4.4.0)
   #>  scales        1.3.0    2023-11-28 [1] CRAN (R 4.4.0)
   #>  secretbase    1.0.2    2024-09-09 [1] CRAN (R 4.4.1)
   #>  sessioninfo   1.2.2    2021-12-06 [1] CRAN (R 4.4.0)
   #>  stringi       1.8.4    2024-05-06 [1] CRAN (R 4.4.0)
   #>  stringr     * 1.5.1    2023-11-14 [1] CRAN (R 4.4.0)
   #>  targets     * 1.7.1    2024-06-20 [1] CRAN (R 4.4.1)
   #>  tibble      * 3.2.1    2023-03-20 [1] CRAN (R 4.4.0)
   #>  tidyr       * 1.3.1    2024-01-24 [1] CRAN (R 4.4.0)
   #>  tidyselect    1.2.1    2024-03-11 [1] CRAN (R 4.4.0)
   #>  tidyverse   * 2.0.0    2023-02-22 [1] CRAN (R 4.4.0)
   #>  timechange    0.3.0    2024-01-18 [1] CRAN (R 4.4.0)
   #>  tzdb          0.4.0    2023-05-12 [1] CRAN (R 4.4.0)
   #>  utf8          1.2.4    2023-10-22 [1] CRAN (R 4.4.0)
   #>  vctrs         0.6.5    2023-12-01 [1] CRAN (R 4.4.0)
   #>  withr         3.0.1    2024-07-31 [1] CRAN (R 4.4.1)
   #>  xfun          0.47     2024-08-17 [1] CRAN (R 4.4.1)
   #>  yaml          2.3.10   2024-07-26 [1] CRAN (R 4.4.1)
   #> 
   #>  [1] C:/Users/SvrakaA/AppData/Local/R/win-library/4.4
   #>  [2] C:/R/R-4.4.1/library
   #> 
   #> 
────────────────────────────────────────────────────────────────────────────────────────────────────
   ```
   
   </details>
   
   ### Component(s)
   
   R


-- 
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: issues-unsubscr...@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to