Skip to content

Commit

Permalink
Ensure op_can_download() returns FALSE for hand rolled sql (#552)
Browse files Browse the repository at this point in the history
Fixes #540
  • Loading branch information
hadley authored Nov 3, 2023
1 parent df16933 commit 377e401
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# bigrquery (development version)

* `con |> tbl(sql("..."))` now works robustly once more (#540). (No more
"URL using bad/illegal format or missing URL" error).

* Align Google APIs URLs to Google Cloud Discovery docs. This enables support for Private and Restricted Google APIs configurations.
(@husseyd, #541)
- `R/bq-request.R`
Expand Down
1 change: 1 addition & 0 deletions R/dplyr.R
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ op_can_download.lazy_base_query <- function(x) dbplyr::is.ident(x$x)

query_is_head_only <- function(x) {
if (!inherits(x$x, "lazy_base_remote_query")) return(FALSE)
if (inherits(x$x$x, "sql")) return(FALSE)

vars_base <- dbplyr::op_vars(x$x)
if (!is_select_trivial(x$select, vars_base)) return(FALSE)
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-dplyr.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ test_that("collect can identify directly download tables", {

x <- dplyr::collect(bq1)
expect_s3_class(x, "tbl")

bq5 <- dplyr::tbl(con, dplyr::sql("SELECT * FROM mtcars"))
expect_false(op_can_download(bq5))
expect_false(op_can_download(head(bq5)))
})

test_that("casting uses bigquery types", {
Expand Down

0 comments on commit 377e401

Please sign in to comment.