Skip to contents

Returns one row per column of the table read_record_set() returns for the record set, in the same order: one row per field without sub-fields, depth first.

Usage

fields(
  x,
  record_set = NULL,
  output = c("data.table", "tibble", "data.frame", "arrow"),
  ...
)

Arguments

x

Croissant or RecordSet object.

record_set

Character: @id or name of the record set, when x is a Croissant. NULL when x is a RecordSet.

output

Character {"data.table", "tibble", "data.frame", "arrow"}: Class of the result. "tibble" requires the 'tibble' package and "arrow" the 'arrow' package.

...

Not used.

Value

A data.table, tibble, data.frame, or arrow Table, by output, with character columns column (the column name in read_record_set()), id, data_type, description, source (@id of the file object, file set, field, or record set the field reads from), extract (the column, JSONPath, or file property extracted), and references (@id of the referenced field or record set), and logical column repeated (a list column in read_record_set()). A property the field does not set is NA.

Author

EDG

Examples

file <- tempfile(fileext = ".csv")
x <- croissant_from_data(
  data.frame(age = c(22L, 38L), sex = factor(c("male", "female"))),
  file = file,
  name = "people"
)
fields(x, "default")
#>    column          id  data_type description               source    extract
#>    <char>      <char>     <char>      <char>               <char>     <char>
#> 1:    age default/age sc:Integer        <NA> filec2e2293ecf37.csv column age
#> 2:    sex default/sex    sc:Text        <NA> filec2e2293ecf37.csv column sex
#>                  references repeated
#>                      <char>   <lgcl>
#> 1:                     <NA>    FALSE
#> 2: default_sex_levels/label    FALSE
fields(record_sets(x)[["default"]], output = "data.frame")
unlink(file)