You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "pmac0451 (via GitHub)" <gi...@apache.org> on 2026/01/12 16:24:24 UTC

[I] arrow::write_parquet error with zero-length datetimes in R 4.5.2 [arrow]

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

   ### Describe the bug, including details regarding any error messages, version, and platform.
   
   ### Description
   Using R 4.5.2 there is an error using `arrow::write_parquet` with zero-length datetimes:
   `Error: Invalid: Invalid conversion to timestamp`
   
   I believe this may be caused by the following change in the [release note](https://cran.r-project.org/doc/manuals/r-patched/[NEWS.2.pdf](https://cran.r-project.org/doc/manuals/r-patched/NEWS.2.pdf)) for R 4.5.2 (patched):
   
   >  `str(x, give.attr=FALSE)` no longer shows attributes when `x` is a zero length "Date" or "POSIXt" object.
   
   I can't be sure if the error was present before the patched release of 4.5.2 on 5 Jan 2026.
   
   ### Reprex
   
   ```
   dplyr::tibble(
       timeStamp = as.POSIXct(x = NULL), # works ok with this line commented out
       otherColumn = character()
     ) |>
     arrow::write_parquet(
       sink = tempfile(fileext = ".parquet")
     )
   ```
   
   ### 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-unsubscribe@arrow.apache.org.apache.org

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


Re: [I] arrow::write_parquet error with zero-length datetimes in R 4.5.2 [arrow]

Posted by "raulcd (via GitHub)" <gi...@apache.org>.
raulcd commented on issue #48832:
URL: https://github.com/apache/arrow/issues/48832#issuecomment-3744548166

   thanks @shashbha14 , I've assigned you the issue.


-- 
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: [I] arrow::write_parquet error with zero-length datetimes in R 4.5.2 [arrow]

Posted by "shashbha14 (via GitHub)" <gi...@apache.org>.
shashbha14 commented on issue #48832:
URL: https://github.com/apache/arrow/issues/48832#issuecomment-3744311929

   I would like to work on this issue.


-- 
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: [I] [R] arrow::write_parquet error with zero-length datetimes in R 4.5.2 [arrow]

Posted by "thisisnic (via GitHub)" <gi...@apache.org>.
thisisnic closed issue #48832: [R] arrow::write_parquet error with zero-length datetimes in R 4.5.2
URL: https://github.com/apache/arrow/issues/48832


-- 
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-unsubscribe@arrow.apache.org

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


Re: [I] [R] arrow::write_parquet error with zero-length datetimes in R 4.5.2 [arrow]

Posted by "thisisnic (via GitHub)" <gi...@apache.org>.
thisisnic commented on issue #48832:
URL: https://github.com/apache/arrow/issues/48832#issuecomment-4177602976

   Issue resolved by pull request 49619
   https://github.com/apache/arrow/pull/49619


-- 
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: [I] arrow::write_parquet error with zero-length datetimes in R 4.5.2 [arrow]

Posted by "shashbha14 (via GitHub)" <gi...@apache.org>.
shashbha14 commented on issue #48832:
URL: https://github.com/apache/arrow/issues/48832#issuecomment-3745473862

   @raulcd Yes, I have completed the analysis and solution.
   
   **Root Cause:**
   The crash occurs in [r/src/type_infer.cpp](cci:7://file:///C:/Users/ishwet/.gemini/antigravity/scratch/arrow/r/src/type_infer.cpp:0:0-0:0) at lines 72 and 89. The code checks if the timezone attribute is NULL, but doesn't verify it has content before reading it. In R 4.5.2, zero-length POSIXct objects can have a `tzone` attribute with length 0, causing an out-of-bounds memory access when the code tries to read `STRING_ELT(tzone_sexp, 0)`.
   
   **Solution:**
   Added a length check before accessing the timezone:
   - Changed: `if (Rf_isNull(tzone_sexp))`
   - To: `if (Rf_isNull(tzone_sexp) || XLENGTH(tzone_sexp) == 0)`
   
   Applied to both INTSXP (line 72) and REALSXP (line 89) specializations.
   
   **Testing:**
   Created [r/tests/testthat/test-issue-48832.R](cci:7://file:///C:/Users/ishwet/.gemini/antigravity/scratch/arrow/r/tests/testthat/test-issue-48832.R:0:0-0:0) with a regression test that reproduces the exact scenario from the bug report.
   
   Preparing PR now!


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