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

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   When we write the parquet using arrow, we lost information that the data 
frame is `data.frame`. 
   
   ```
   arrow::write_parquet(iris, "iris.parquet")
   ```
   
   When we read `iris.parquet` it's read as tbl by default.
   
   ```r
   arrow::read_parquet("iris.parquet")
   class(arrow::read_parquet("iris.parquet"))
   # [1] "tbl_df"     "tbl"        "data.frame"
   ```
   
   This bug was introduced in https://github.com/apache/arrow/issues/34775
   
   The class `data.frame` is removed in `.serialize_arrow_r_metadata` function.
   
https://github.com/apache/arrow/blame/7ef5437e23bd7d7571a0c7a7fc0c5d3634816802/r/R/metadata.R#L25
   
   ```r
   prop <- arrow::ParquetFileReader$create(
     "iris.parquet",
     props = arrow::ParquetArrowReaderProperties$create()
   )
   prop$GetSchema()$metadata$r$attributes$class
   # NULL
   ```
   
   When the parquet is saved, the attributes were removed.
   
   Workaround:
   1) Apply extra class to `data.frame`
   ```r
   new_iris <- iris
   class(new_iris) <- c("custom.data.frame", "data.frame")
   arrow::write_parquet(new_iris, "iris.parquet")
   prop <- arrow::ParquetFileReader$create(
     "iris.parquet",
     props = arrow::ParquetArrowReaderProperties$create()
   )
   prop$GetSchema()$metadata$r$attributes$class
   # [1] "custom.data.frame" "data.frame"    
   ```
   2) Apply the metadata properties manually
   
   
   Bug description: 
   When we remove `data.frame` class attribute, we read parquet by default as 
tibble. In my opinion it's not expected behavior as when we write `data.frame` 
we should read `data.frame`.
   
   ### 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