-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Querying views returns no rows #519
Comments
This happened to me too. Using dbGetQuery works, but not the dplyr wrapper. |
Somewhat more minimal reprex: library(dplyr, warn.conflicts = FALSE)
library(bigrquery)
options(gargle_oauth_email = TRUE)
ds <- bq_test_dataset()
#> ℹ The bigrquery package is using a cached token for 'hadley@posit.co'.
#> Auto-refreshing stale OAuth token.
con <- DBI::dbConnect(ds)
DBI::dbWriteTable(con, "mtcars", mtcars)
sql <- glue::glue('CREATE VIEW mtcars2 AS SELECT mpg, cyl, disp FROM {ds$dataset}.mtcars')
DBI::dbExecute(con, sql)
#> [1] 0
tbl(con, "mtcars2")
#> # Source: table<mtcars2> [0 x 3]
#> # Database: BigQueryConnection
#> # ℹ 3 variables: mpg <dbl>, cyl <int64>, disp <dbl> Created on 2023-11-07 with reprex v2.0.2.9000 |
Hmmmm, this happens because the metadata for a view says it has 0 rows. |
Ah, the problem is that dplyr thinks that this is a table, so falls through to a faster way of downloading the data (which clearly doesn't work for views). I think the best we can do here is on |
Thank you for the super helpful package! I have found that I can query and return rows from a BigQuery table fine with this package but I'm unable to return rows from a BigQuery view. I just get an empty tibble back using the cran version and the github version of this package. I have verified that I can query the view in the console using the code generated by
dplyr::show_query()
. The reprex below was adapted from an issue filed in another repo which was never submitted here that I could find (I've redacted the project id). Am I missing something?Thank you!
The text was updated successfully, but these errors were encountered: