Skip to content

[R] arrow_table: as.data.frame() sometimes returns a tbl and sometimes a data.frame #34775

Closed

Description

@daattali

Describe the bug, including details regarding any error messages, version, and platform.

The documentation for arrow_table() says that you can call as.data.frame() on an arrow table object to convert it to a dataframe. It seems like the behaviour is inconsistent. Example:

> class(as.data.frame(arrow::arrow_table(name = "1", mtcars)))
[1] "tbl_df"     "tbl"        "data.frame"
> class(as.data.frame(arrow::arrow_table(mtcars, name = "1")))
[1] "data.frame"

I created the same arrow_table in both cases but only changed the order of the arguments, and it returned a different object type.

I would expect it to be base R dataframe since as.data.frame() is a generic from base R that is generally assumed to convert to actual data.frame objects, not to tibbles. Right now if I want to guarantee a base R data.frame, I need to do as.data.frame(as.data.frame(table)). I need to ocnvert it using the same function twice, which is extremely awkward and unintuitive. I strongly believe arrow should not conflate data.frame() with tbl_df, it can cause errors for users.

Component(s)

R

Activity

  1. thisisnic commented on Mar 30, 2023

    @thisisnic
    Member

    Thanks for reporting this, I agree it's not intended behaviour. Looks like it's something to do with how metadata is handled, will have a closer look at this.

  2. added a commit that references this issue on May 3, 2023
  3. added this to the 13.0.0 milestone on May 3, 2023
  4. added a commit that references this issue on May 11, 2023
  5. added a commit that references this issue on May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions