No flags found
Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.
e.g., #unittest #integration
#production #enterprise
#frontend #backend
504185d
... +2 ...
b5664af
Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.
e.g., #unittest #integration
#production #enterprise
#frontend #backend
106 | 106 | n = Inf, |
|
107 | 107 | warn_incomplete = TRUE) { |
|
108 | 108 | assert_that(length(n) == 1, n > 0L) |
|
109 | + | con <- dbplyr::remote_con(x) |
|
109 | 110 | ||
110 | - | if (op_can_download(x$ops)) { |
|
111 | - | name <- op_table(x$ops, x$src$con) |
|
112 | - | tb <- as_bq_table(x$src$con, name) |
|
113 | - | n <- min(op_rows(x$ops), n) |
|
111 | + | if (op_can_download(x)) { |
|
112 | + | lq <- x$lazy_query |
|
113 | + | name <- op_table(x, con) |
|
114 | + | tb <- as_bq_table(con, name) |
|
115 | + | n <- min(op_rows(x$lazy_query), n) |
|
114 | 116 | } else { |
|
115 | - | sql <- dbplyr::db_sql_render(x$src$con, x) |
|
117 | + | sql <- dbplyr::db_sql_render(con, x) |
|
116 | 118 | ||
117 | - | billing <- x$src$con@billing |
|
118 | - | if (is.null(x$src$con@dataset)) { |
|
119 | - | tb <- bq_project_query(billing, sql, quiet = x$src$con@quiet, ...) |
|
119 | + | billing <- con@billing |
|
120 | + | if (is.null(con@dataset)) { |
|
121 | + | tb <- bq_project_query(billing, sql, quiet = con@quiet, ...) |
|
120 | 122 | } else { |
|
121 | - | ds <- as_bq_dataset(x$src$con) |
|
122 | - | tb <- bq_dataset_query(ds, sql, quiet = x$src$con@quiet, billing = billing, ...) |
|
123 | + | ds <- as_bq_dataset(con) |
|
124 | + | tb <- bq_dataset_query(ds, sql, quiet = con@quiet, billing = billing, ...) |
|
123 | 125 | } |
|
124 | 126 | } |
|
125 | 127 | ||
126 | - | quiet <- if (n < 100) TRUE else x$src$con@quiet |
|
127 | - | bigint <- x$src$con@bigint %||% "integer" |
|
128 | + | quiet <- if (n < 100) TRUE else con@quiet |
|
129 | + | bigint <- con@bigint %||% "integer" |
|
128 | 130 | out <- bq_table_download(tb, |
|
129 | 131 | n_max = n, |
|
130 | 132 | page_size = page_size, |
139 | 141 | ||
140 | 142 | op_can_download <- function(x) UseMethod("op_can_download") |
|
141 | 143 | #' @export |
|
142 | - | op_can_download.op <- function(x) FALSE |
|
144 | + | op_can_download.tbl_lazy <- function(x) op_can_download(x$lazy_query) |
|
143 | 145 | #' @export |
|
144 | - | op_can_download.op_head <- function(x) op_can_download(x$x) |
|
146 | + | op_can_download.lazy_query <- function(x) FALSE |
|
145 | 147 | #' @export |
|
146 | - | op_can_download.op_base_remote <- function(x) dbplyr::is.ident(x$x) |
|
148 | + | op_can_download.lazy_select_query <- function(x) { |
|
149 | + | query_is_head_only(x) |
|
150 | + | } |
|
151 | + | #' @export |
|
152 | + | op_can_download.lazy_base_query <- function(x) dbplyr::is.ident(x$x) |
|
153 | + | ||
154 | + | query_is_head_only <- function(x) { |
|
155 | + | if (!inherits(x$x, "lazy_base_remote_query")) return(FALSE) |
|
156 | + | ||
157 | + | vars_base <- dbplyr::op_vars(x$x) |
|
158 | + | if (!is_select_trivial(x$select, vars_base)) return(FALSE) |
|
159 | + | ||
160 | + | if (!rlang::is_empty(x$where)) return(FALSE) |
|
161 | + | if (!rlang::is_empty(x$order_by)) return(FALSE) |
|
162 | + | if (!rlang::is_false(x$distinct)) return(FALSE) |
|
163 | + | ||
164 | + | TRUE |
|
165 | + | } |
|
166 | + | ||
167 | + | is_select_trivial <- function(select, vars_prev) { |
|
168 | + | identical(select$name, vars_prev) && |
|
169 | + | all(vapply(select$expr, rlang::is_symbol, logical(1))) && |
|
170 | + | identical(rlang::syms(select$name), select$expr) |
|
171 | + | } |
|
172 | + | ||
147 | 173 | ||
148 | 174 | op_rows <- function(x) UseMethod("op_rows") |
|
149 | 175 | #' @export |
|
150 | - | op_rows.op_base <- function(x) Inf |
|
176 | + | op_rows.tbl_lazy <- function(x) op_rows(x$lazy_query) |
|
177 | + | #' @export |
|
178 | + | op_rows.lazy_base_query <- function(x) Inf |
|
151 | 179 | #' @export |
|
152 | - | op_rows.op_head <- function(x) min(x$args$n, op_rows(x$x)) |
|
180 | + | op_rows.lazy_select_query <- function(x) { |
|
181 | + | min(x$limit, op_rows(x$x)) |
|
182 | + | } |
|
153 | 183 | ||
154 | 184 | op_table <- function(x, con) UseMethod("op_table") |
|
155 | 185 | #' @export |
|
156 | - | op_table.op <- function(x, con) op_table(x$x, con) |
|
186 | + | op_table.tbl_lazy <- function(x, con) op_table(x$lazy_query, con) |
|
187 | + | #' @export |
|
188 | + | op_table.lazy_query <- function(x, con) NULL |
|
157 | 189 | #' @export |
|
158 | - | op_table.op_base_remote <- function(x, con) { |
|
190 | + | op_table.lazy_base_remote_query <- function(x, con) x$x |
|
191 | + | #' @export |
|
192 | + | op_table.lazy_select_query <- function(x, con) { |
|
193 | + | if (!query_is_head_only(x)) return(NULL) |
|
194 | + | ||
159 | 195 | x$x |
|
160 | 196 | } |
|
161 | 197 |
#505
b5664af
b066973
3f187b2
504185d