Skip to content

Commit ff4680a

Browse files
zacdav-dbZac Davies
andauthored
Fixing db_sql_query bugs (#101)
* Adding db_sql_query convenience function for querying via warehouse. * adding small tests for `db_sql_query` * Adding logic to fallback to nanoarrow * Removing python SQL connector * Update typo. * copilot is cool - found a booboo * `x` --> `.x` * - Removing unused imports - Removing unused tests & helpers - Removing unused doc pages - Minor doc/vignette updates * Adding error propegation * Adjusting return logic. --------- Co-authored-by: Zac Davies <[email protected]>
1 parent 552670b commit ff4680a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

R/sql-query-execution.R

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,10 @@ db_sql_query <- function(
325325
resp <- db_sql_exec_poll_for_success(resp$statement_id)
326326
}
327327

328+
if (resp$status$state == "FAILED") {
329+
cli::cli_abort(resp$status$error$message)
330+
}
331+
328332
# fetch all external links
329333
total_chunks <- resp$manifest$total_chunk_count - 1
330334
total_rows <- resp$manifest$total_row_count
@@ -367,9 +371,14 @@ db_sql_query <- function(
367371
as_data_frame = FALSE
368372
)
369373
)
370-
arrow_tbl <- do.call(arrow::concat_tables, arrow_tbls)
374+
results <- do.call(arrow::concat_tables, arrow_tbls)
375+
376+
if (!return_arrow) {
377+
results <- tibble::as_tibble(results)
378+
}
371379
} else {
372-
purrr::map(~ tibble::as_tibble(nanoarrow::read_nanoarrow(.x))) |>
380+
results <- purrr::map(~ tibble::as_tibble(nanoarrow::read_nanoarrow(.x))) |>
373381
purrr::list_rbind()
374382
}
383+
results
375384
}

0 commit comments

Comments
 (0)