You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Nicola Crane (Jira)" <ji...@apache.org> on 2021/12/16 14:59:00 UTC

[jira] [Commented] (ARROW-14919) [R] write_parquet() drops attributes for grouped dataframes

    [ https://issues.apache.org/jira/browse/ARROW-14919?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17460793#comment-17460793 ] 

Nicola Crane commented on ARROW-14919:
--------------------------------------

Thanks for reporting this [~milesmcbain] , just looking into it now.  It appears to work the same way for {{write_feather()}} as well, but in {{write_csv_arrow()}} this metadata gets dropped regardless (though this is unsurprising as a CSV wouldn't retain that information anyway).

It appears to be happening in the conversion from a {{data.frame}} to an Arrow table; here's an even closer example:

{code:r}
attr(cars, "my_metadata") <- "hi, look, i'm still here"
arrow_table(cars)$metadata # is still there
arrow_table(group_by(cars, speed))$metadata # gone now
{code}


> [R] write_parquet() drops attributes for grouped dataframes
> -----------------------------------------------------------
>
>                 Key: ARROW-14919
>                 URL: https://issues.apache.org/jira/browse/ARROW-14919
>             Project: Apache Arrow
>          Issue Type: Bug
>          Components: R
>    Affects Versions: 6.0.1
>         Environment: Linux
>            Reporter: Miles McBain
>            Assignee: Nicola Crane
>            Priority: Major
>             Fix For: 7.0.0
>
>
> Reprex:
> {code:r}
> library(dplyr)
> #>
> #> Attaching package: 'dplyr'
> #> The following objects are masked from 'package:stats':
> #>
> #>     filter, lag
> #> The following objects are masked from 'package:base':
> #>
> #>     intersect, setdiff, setequal, union
> library(purrr)
> library(arrow)
> #>
> #> Attaching package: 'arrow'
> #> The following object is masked from 'package:utils':
> #>
> #>     timestamp
> attr(mtcars, "etag") <- "test"
> mtcars_grouped <-
>   mtcars |>
>   group_by("cyl")write_parquet(mtcars, "mtcars.parquet")
> read_parquet("mtcars.parquet") |>
>   attributes() |>
>   pluck("etag")
> #> [1] "test"write_parquet(mtcars_grouped, "mtcars_grouped.parquet")
> read_parquet("mtcars_grouped.parquet") |>
>   attributes() |>
>   pluck("etag")
> #> NULLunlink("mtcars_grouped.parquet")
> unlink("mtcars.parquet") {code}
> <sup>Created on 2021-11-30 by the [reprex package]([https://reprex.tidyverse.org|https://reprex.tidyverse.org/]) (v2.0.1)</sup>
> Attributes are preserved for ungrouped data but unexpectedly dropped for grouped data. May affect other read/write formats.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)