7373# ' @examplesIf bq_testable()
7474# ' df <- bq_table_download("publicdata.samples.natality", n_max = 35000, billing = bq_test_project())
7575bq_table_download <-
76- function (x ,
77- n_max = Inf ,
78- page_size = NULL ,
79- start_index = 0L ,
80- max_connections = 6L ,
81- quiet = NA ,
82- bigint = c(" integer" , " integer64" , " numeric" , " character" ),
83- api = c(" json" , " arrow" ),
84- billing = x $ project ,
85- max_results = deprecated()) {
76+ function (
77+ x ,
78+ n_max = Inf ,
79+ page_size = NULL ,
80+ start_index = 0L ,
81+ max_connections = 6L ,
82+ quiet = NA ,
83+ bigint = c(" integer" , " integer64" , " numeric" , " character" ),
84+ api = c(" json" , " arrow" ),
85+ billing = x $ project ,
86+ max_results = deprecated()
87+ ) {
8688 x <- as_bq_table(x )
8789 check_number_whole(n_max , min = 0 , allow_infinite = TRUE )
8890 check_number_whole(start_index , min = 0 )
@@ -93,13 +95,18 @@ bq_table_download <-
9395
9496 if (lifecycle :: is_present(max_results )) {
9597 lifecycle :: deprecate_warn(
96- " 1.4.0" , " bq_table_download(max_results)" , " bq_table_download(n_max)"
98+ " 1.4.0" ,
99+ " bq_table_download(max_results)" ,
100+ " bq_table_download(n_max)"
97101 )
98102 n_max <- max_results
99103 }
100104
101105 if (api == " arrow" ) {
102- check_installed(" bigrquerystorage" , " required to download using arrow API" )
106+ check_installed(
107+ " bigrquerystorage" ,
108+ " required to download using arrow API"
109+ )
103110 if (! missing(page_size )) {
104111 cli :: cli_warn(
105112 ' {.arg page_size} is ignored when {.code api == "arrow"}' ,
@@ -264,7 +271,6 @@ check_api <- function(api = c("json", "arrow"), error_call = caller_env()) {
264271# This function is a modified version of
265272# https://github.com/r-dbi/RPostgres/blob/master/R/PqResult.R
266273parse_postprocess <- function (df , bigint ) {
267-
268274 df <- col_apply(
269275 df ,
270276 function (x ) identical(attr(x , " bq_type" ), " DATE" ),
@@ -337,15 +343,17 @@ set_row_params <- function(nrow, n_max = Inf, start_index = 0L) {
337343 list (n_max = n_max , start_index = start_index )
338344}
339345
340- bq_download_plan <- function (n_max ,
341- chunk_size = NULL ,
342- n_chunks = NULL ,
343- start_index = 0 ) {
346+ bq_download_plan <- function (
347+ n_max ,
348+ chunk_size = NULL ,
349+ n_chunks = NULL ,
350+ start_index = 0
351+ ) {
344352 params <- set_chunk_params(n_max , chunk_size , n_chunks )
345353 list (
346- n_max = n_max ,
354+ n_max = n_max ,
347355 chunk_size = params $ chunk_size ,
348- n_chunks = params $ n_chunks ,
356+ n_chunks = params $ n_chunks ,
349357 dat = set_chunk_plan(
350358 n_max ,
351359 params $ chunk_size ,
@@ -373,7 +381,10 @@ set_chunk_plan <- function(n_max, chunk_size, n_chunks, start_index = 0) {
373381 chunk_begin ,
374382 chunk_rows ,
375383 path = sort(
376- tempfile(rep_len(" bq-download-" , length.out = n_chunks ), fileext = " .json" )
384+ tempfile(
385+ rep_len(" bq-download-" , length.out = n_chunks ),
386+ fileext = " .json"
387+ )
377388 )
378389 )
379390}
@@ -390,7 +401,10 @@ bq_download_chunk_handle <- function(x, begin = 0L, max_results = 1e4) {
390401 maxResults = format(max_results , scientific = FALSE )
391402 )
392403
393- url <- paste0(base_url , bq_path(x $ project , dataset = x $ dataset , table = x $ table , data = " " ))
404+ url <- paste0(
405+ base_url ,
406+ bq_path(x $ project , dataset = x $ dataset , table = x $ table , data = " " )
407+ )
394408 url <- httr :: modify_url(url , query = prepare_bq_query(query ))
395409
396410 if (bq_has_token()) {
0 commit comments