Skip to content

Commit 338d66e

Browse files
authored
Support views in the INFORMATION_SCHEMA schema (#587)
Which appear to error when you attempt to get their metadata. Fixes #468
1 parent b965950 commit 338d66e

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

NEWS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# bigrquery (development version)
22

3-
* `tbl()` now works with views (#519).
3+
* `tbl()` now works with views (#519), including the views found in the
4+
`INFORMATION_SCHEMA` schema (#468).
45

56
* dplyr joins now work correctly across any bigquery connections (#433).
67

R/dplyr.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ tbl.BigQueryConnection <- function(src, from, ...) {
4848

4949
# This is ugly, but I don't see a better way of doing this
5050
tb <- as_bq_table(src$con, from)
51-
tbl$lazy_query$is_view <- !inherits(from, "sql") && bq_table_meta(tb, "type")$type == "VIEW"
51+
tbl$lazy_query$is_view <- !inherits(from, "sql") &&
52+
tryCatch(bq_table_meta(tb, "type")$type == "VIEW", bigrquery_notFound = function(e) TRUE)
5253
tbl
5354
}
5455

tests/testthat/test-dplyr.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ test_that("collect can identify directly download tables", {
106106
defer(DBI::dbExecute(con, 'DROP VIEW mtcars2'))
107107
bq6 <- dplyr::tbl(con, "mtcars2")
108108
expect_false(op_can_download(bq6))
109+
110+
# INFORMATION_SCHEMA.TABLES errors when we attempt to get metadata
111+
bq7 <- dplyr::tbl(con, "INFORMATION_SCHEMA.PARTITIONS")
112+
expect_false(op_can_download(bq7))
113+
expect_false(op_can_download(head(bq7)))
109114
})
110115

111116
test_that("casting uses bigquery types", {

0 commit comments

Comments
 (0)