Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[R] Convenience function for returning schema code #37594

Closed
stephhazlitt opened this issue Sep 6, 2023 · 2 comments
Closed

[R] Convenience function for returning schema code #37594

stephhazlitt opened this issue Sep 6, 2023 · 2 comments

Comments

@stephhazlitt
Copy link
Contributor

Describe the enhancement requested

I wonder if a convenience function for returning the schema code would be handy for users?

Currently you can extract the schema with:

library(arrow)
#> 
#> Attaching package: 'arrow'
#> The following object is masked from 'package:utils':
#> 
#>     timestamp
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

schema(arrow_table(mtcars))
#> Schema
#> mpg: double
#> cyl: double
#> disp: double
#> hp: double
#> drat: double
#> wt: double
#> qsec: double
#> vs: double
#> am: double
#> gear: double
#> carb: double
#> 
#> See $metadata for additional Schema metadata

And you can extract the schema code with:

library(arrow)
#> 
#> Attaching package: 'arrow'
#> The following object is masked from 'package:utils':
#> 
#>     timestamp
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

arrow_table(mtcars)$schema$code()
#> schema(mpg = float64(), cyl = float64(), disp = float64(), hp = float64(), 
#>     drat = float64(), wt = float64(), qsec = float64(), vs = float64(), 
#>     am = float64(), gear = float64(), carb = float64())

The schema code output is very useful for editing/altering and creating schemas, but the code is not very intuitive, especially for new users. I was thinking maybe a schema_code() convenience function might be useful (or some other better suited name).

Component(s)

R

@thisisnic thisisnic changed the title Convenience function for returning schema code [R] Convenience function for returning schema code Sep 6, 2023
@orgadish
Copy link
Contributor

orgadish commented Oct 5, 2023

This would be great! Hopefully it would also include my request from #38033.

@thisisnic
Copy link
Member

Closing as this has now been completed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants