Skip to contents

Selects, on a lazy table from parquet_tbl(), the columns in one language under their plain names and leaves the columns in the other languages out, before the query runs, so they never get read: name_fr takes the place and name of name, or stands in for a name the data doesn't have, and name_en gets left out. parquet_tbl() does this itself when a language is set, this is the verb to do it later, e.g. after reading with language = NULL, or on a join of tables read without a language.

Usage

select_language(tbl, language = getOption("r2parquet.language"))

Arguments

tbl

lazy DuckDB table from parquet_tbl(), or derived from one with dplyr verbs.

language

language code like "en" or "fr", or NULL to return the table unchanged. Defaults to the r2parquet.language option.

Value

the lazy table with the columns of the language selected.

Details

Which suffixes are languages is declared by the metadata of the tables the lazy table was read from (the languages and language entries, see the Languages section of data_to_parquet()), so a column like rate_men next to rate is left alone and a language none of the tables declares changes nothing; the metadata of files in buckets and at URLs gets read once per table. A suffixed column without a plain column or a peer in another language is left alone too. A table without any column in the language is returned as it is. The table remembers the selection and the language, so collect_parquet(), parquet_sources() and parquet_metadata() on it label name with the label of the column it came from, and the first two describe the result in that language when no language is passed to them, whatever the option says; parquet_metadata() returns the metadata as stored by default, as always.

Examples

# \donttest{
if (requireNamespace("curl", quietly = TRUE) && curl::has_internet()) {
  characteristics <- parquet_tbl("https://data.mountainmath.ca/census/2021/profile_characteristics.parquet",
                                 language = NULL)
  colnames(characteristics)
  colnames(select_language(characteristics, "fr"))
}
#> [1] "characteristic_id" "name"              "level"            
#> [4] "note"             
# }