This auxiliary function adds a field, if necessary, to a data frame so that each compartment of the data frame that corresponds to a unique combination of the chunk fields has a size below a certain threshold. This resulting data frame can then be safely used in dbAppendTable() becauase Presto has a size limit on any discrete INSERT INTO statement.
base_chunk_fields: A character vector of existing field names that are used to split the data frame before checking the chunk size.
chunk_size: Maximum size (in bytes) of the VALUES statement encoding each unique chunk. Default to 1,000,000 bytes (i.e. 1Mb).
new_chunk_field_name: A string indicating the new chunk field name. Default to "aux_chunk_idx".
Examples
## Not run:# returns the original data frame because it's within sizeadd_chunk(iris)# add a new aux_chunk_idx fieldadd_chunk(iris, chunk_size =2000)# the new aux_chunk_idx field is added on top of Speciesadd_chunk(iris, chunk_size =2000, base_chunk_fields = c("Species"))## End(Not run)