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

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   Double-valued attributes, including date-times, do not round-trip through 
Arrow's R metadata. No warning is raised. (Tested on arrow 25.0.1, R 4.6.1, 
Linux.)
   
   ```r
   library(arrow)
   options(digits.secs = 6)
   
   df <- data.frame(x = 1:3)
   attr(df, "updated") <- as.POSIXct("2026-10-02 14:30:15.987654321", tz = 
"UTC")
   
   f <- tempfile(fileext = ".parquet")
   write_parquet(df, f)
   back <- read_parquet(f)
   
   attr(df, "updated")
   #> [1] "2026-10-02 14:30:15.987654 UTC"
   attr(back, "updated")
   #> [1] "2026-10-02 14:30:15.987653 UTC"
   identical(attr(back, "updated"), attr(df, "updated"))
   #> [1] FALSE
   ```
   
   ### Suggested fix
   
   Fortuitously, R already has an exact variant of the ASCII format, so the fix 
is simple and fully backwards compatible.
   
   Arrow uses `R_pstream_ascii_format` (`ascii = TRUE` in `base::serialize`). 
Instead use `R_pstream_asciihex_format` (`ascii = NA`).
   
   ```r
   out <- serialize(safe_r_metadata(x, on_save = TRUE), NULL, ascii = NA)
   ```
   
   The hex format means that doubles are written out in hex instead of decimal.
   
   Either way, the output still starts with `"A"` (arrow's check) and base 
`unserialize()` reads it fine, so the reader needs no change and previous 
versions work with the output.
   
   
   ### 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to