Get character variable (varchar) lengths for import into Azure
Source:R/azure-helpers.R
varchar_max.Rd
Use this to generate a list of varchar(n)
specifications to be used in an R to Azure import with the DBI:dbWriteTable()
or smcepi::azure_import_loop()
functions. This list specifies a varchar(n)
value for each character variable based on the maximum string length in that variable. n
is 255 for variables with maximum string lengths of 255 or less and n
is the maximum string length for variables with maximum string lengths longer than 255.
Examples
data <- data.frame(
col1 = c("blue", "pink", "green", "yellow"),
col2 = c(paste(rep("a", 1000), collapse = ""), "b", "cc", "ddd"))
varchar_max(data)
#> col1 col2
#> "varchar(255)" "varchar(1000)"
# output:
# col1 col2
# "varchar(255)" "varchar1000)"