contoso_dict_columns()
#> # A tibble: 103 × 9
#> table rows column type constraints units missing values description
#> <chr> <int> <chr> <chr> <chr> <chr> <int> <list> <chr>
#> 1 sales 7794 order_key numbe… required <NA> 0 <NULL> Order this…
#> 2 sales 7794 line_number numbe… required <NA> 0 <NULL> Position o…
#> 3 sales 7794 order_date date required <NA> 0 <NULL> Date the o…
#> 4 sales 7794 delivery_date date required <NA> 0 <NULL> Date the o…
#> 5 sales 7794 customer_key numbe… required, … <NA> 0 <NULL> Customer w…
#> 6 sales 7794 store_key numbe… required, … <NA> 0 <NULL> Where the …
#> 7 sales 7794 product_key numbe… required, … <NA> 0 <NULL> Product on…
#> 8 sales 7794 quantity numbe… required <NA> 0 <NULL> Units of t…
#> 9 sales 7794 unit_price numbe… required USD 0 <NULL> Transacted…
#> 10 sales 7794 net_price numbe… required USD 0 <NULL> Price per …
#> # ℹ 93 more rows
# one table
subset(contoso_dict_columns(), table == "store")
#> # A tibble: 11 × 9
#> table rows column type constraints units missing values description
#> <chr> <int> <chr> <chr> <chr> <chr> <int> <list> <chr>
#> 1 store 74 store_key numbe… "primary_k… <NA> 0 <NULL> Unique ide…
#> 2 store 74 store_code numbe… "required" <NA> 0 <NULL> Business c…
#> 3 store 74 geo_area_key numbe… "required" <NA> 0 <NULL> Geographic…
#> 4 store 74 country_code enum "required" <NA> 0 <chr> ISO 3166-1…
#> 5 store 74 country_name enum "required" <NA> 0 <chr> Country na…
#> 6 store 74 state string "required" <NA> 0 <NULL> State or r…
#> 7 store 74 open_date date "required" <NA> 0 <NULL> Date the s…
#> 8 store 74 close_date date "" <NA> 58 <NULL> Date the s…
#> 9 store 74 description string "required" <NA> 0 <NULL> Always `Co…
#> 10 store 74 square_meters numbe… "" <NA> 1 <NULL> Floor area…
#> 11 store 74 status enum "" <NA> 59 <chr> Exceptiona…
# which columns can be missing?
subset(contoso_dict_columns(), missing > 0, c(table, column, missing))
#> # A tibble: 6 × 3
#> table column missing
#> <chr> <chr> <int>
#> 1 product weight_unit 222
#> 2 product weight 284
#> 3 customer company 1
#> 4 store close_date 58
#> 5 store square_meters 1
#> 6 store status 59Data dictionary for the Contoso dataset
Source: R/dict.R
Reads the machine-readable data dictionary shipped with the package and returns it as a tibble with one row per column of every table. The dictionary follows the data-dict schema and documents the traps – notably that store_key 999999 is a sentinel for the online channel rather than a real location, and that store.status is missing (never “Open”) for stores trading normally.
Usage
contoso_dict_columns()Value
A tibble with columns table, rows (row count of the whole table), column, type, constraints, units, missing, values (a list column of permitted values for enums) and description.