Skip to content

Commit 9fabe75

Browse files
zacdav-dbZac Davies
andauthored
fix pagination (#244)
Co-authored-by: Zac Davies <zachary.davies+data@databricks.com>
1 parent 0b68f8c commit 9fabe75

19 files changed

Lines changed: 258 additions & 59 deletions

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- Fixed Unity Catalog volume file requests so `db_volume_*` paths containing spaces are encoded correctly (#231)
55
- `db_cluster_events()` now forwards the `event_types` argument to the API, which was previously ignored
66
- `db_sql_warehouse_create()` and `db_sql_warehouse_edit()` now forward the `tags` argument to the API, which was previously ignored
7+
- Unity Catalog list helpers now preserve `next_page_token` metadata in list responses for catalogs, schemas, tables, and volumes; their list arguments are sent as documented query parameters
78
- `db_uc_volumes_list()` now forwards the `max_results`, `include_browse`, and `page_token` arguments to the API, which were previously ignored
89
- `db_vs_indexes_query()` now sends the `score_threshold` argument to the API, which was previously ignored
910
- Added `show_progress` to `dbConnect()` for the DBI backend; `dbGetQuery()`, `dbFetch()`, `dbWriteTable()`, and dbplyr `collect()` now use the connection default while preserving per-call `show_progress` overrides (#223)

R/connection-pane.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ readable_time <- function(x) {
3333
}
3434

3535
get_catalogs <- function(host, token) {
36-
catalogs <- db_uc_catalogs_list(host = host, token = token)
36+
catalogs <- db_uc_catalogs_list(host = host, token = token)$catalogs
3737
if (length(catalogs) > 0) {
3838
data.frame(
3939
name = purrr::map_chr(catalogs, "name"),
@@ -50,7 +50,7 @@ get_schemas <- function(catalog, host, token) {
5050
catalog = catalog,
5151
host = host,
5252
token = token
53-
)
53+
)$schemas
5454
if (length(schemas) > 0) {
5555
data.frame(
5656
name = purrr::map_chr(schemas, "name"),
@@ -68,7 +68,7 @@ get_tables <- function(catalog, schema, host, token) {
6868
schema = schema,
6969
host = host,
7070
token = token
71-
)
71+
)$tables
7272
if (length(tables) > 0) {
7373
data.frame(
7474
name = purrr::map_chr(tables, "name"),
@@ -238,7 +238,7 @@ get_uc_volumes <- function(catalog, schema, host, token) {
238238
schema = schema,
239239
host = host,
240240
token = token
241-
)
241+
)$volumes
242242
if (length(volumes) > 0) {
243243
data.frame(
244244
name = purrr::map_chr(volumes, "name"),
@@ -256,7 +256,7 @@ get_uc_volume <- function(catalog, schema, host, volume, token) {
256256
schema = schema,
257257
host = host,
258258
token = token
259-
)
259+
)$volumes
260260

261261
volume <- purrr::keep(volumes, \(x) x$name == volume)[[1]]
262262

@@ -394,7 +394,7 @@ get_table_data <- function(catalog, schema, table, host, token, metadata = TRUE)
394394
}
395395

396396
get_experiments <- function(host, token) {
397-
experiments <- db_experiments_list(host = host, token = token)
397+
experiments <- db_experiments_list(host = host, token = token)$experiments
398398
exp_names <- purrr::map_chr(experiments, "name")
399399
exp_ids <- purrr::map_chr(experiments, "experiment_id")
400400
data.frame(

R/experiments.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ db_experiments_list <- function(view_type = c("ACTIVE_ONLY", "DELETED_ONLY", "AL
2222
)
2323

2424
if (perform_request) {
25-
db_perform_request(req)$experiments
25+
db_perform_request(req)
2626
} else {
2727
req
2828
}
@@ -63,4 +63,3 @@ db_experiments_get <- function(name = NULL, id = NULL,
6363
req
6464
}
6565
}
66-

R/uc-catalogs.R

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
#'
1010
#' @family Unity Catalog Management
1111
#'
12-
#' @returns List
12+
#' @returns Full API response list, including `next_page_token` when present,
13+
#' or an `httr2_request` when `perform_request = FALSE`.
1314
#' @export
1415
db_uc_catalogs_list <- function(max_results = 1000,
1516
include_browse = TRUE,
@@ -19,23 +20,21 @@ db_uc_catalogs_list <- function(max_results = 1000,
1920

2021
stopifnot(max_results <= 1000)
2122

22-
body <- list(
23-
max_results = max_results,
24-
include_browse = include_browse,
25-
page_token = page_token
26-
)
27-
2823
req <- db_request(
2924
endpoint = "unity-catalog/catalogs",
3025
method = "GET",
3126
version = "2.1",
3227
host = host,
33-
token = token,
34-
body = body
35-
)
28+
token = token
29+
) |>
30+
httr2::req_url_query(
31+
max_results = max_results,
32+
include_browse = from_logical(include_browse),
33+
page_token = page_token
34+
)
3635

3736
if (perform_request) {
38-
db_perform_request(req)$catalogs
37+
db_perform_request(req)
3938
} else {
4039
req
4140
}

R/uc-schemas.R

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
#'
99
#' @family Unity Catalog Management
1010
#'
11-
#' @returns List
11+
#' @returns Full API response list, including `next_page_token` when present,
12+
#' or an `httr2_request` when `perform_request = FALSE`.
1213
#' @export
1314
db_uc_schemas_list <- function(catalog,
1415
max_results = 1000,
@@ -18,23 +19,21 @@ db_uc_schemas_list <- function(catalog,
1819

1920
stopifnot(max_results <= 1000)
2021

21-
body <- list(
22-
max_results = max_results,
23-
page_token = page_token
24-
)
25-
2622
req <- db_request(
2723
endpoint = "unity-catalog/schemas",
2824
method = "GET",
2925
version = "2.1",
3026
host = host,
31-
token = token,
32-
body = body
27+
token = token
3328
) |>
34-
httr2::req_url_query(catalog_name = catalog)
29+
httr2::req_url_query(
30+
catalog_name = catalog,
31+
max_results = max_results,
32+
page_token = page_token
33+
)
3534

3635
if (perform_request) {
37-
db_perform_request(req)$schemas
36+
db_perform_request(req)
3837
} else {
3938
req
4039
}
@@ -78,4 +77,3 @@ db_uc_schemas_get <- function(catalog, schema,
7877
req
7978
}
8079
}
81-

R/uc-tables.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
#'
2222
#' @family Unity Catalog Table Management
2323
#'
24-
#' @returns List
24+
#' @returns Full API response list, including `next_page_token` when present,
25+
#' or an `httr2_request` when `perform_request = FALSE`.
2526
#' @export
2627
db_uc_tables_list <- function(catalog, schema, max_results = 50,
2728
omit_columns = TRUE,
@@ -47,6 +48,7 @@ db_uc_tables_list <- function(catalog, schema, max_results = 50,
4748
catalog_name = catalog,
4849
schema_name = schema,
4950
include_delta_metadata = from_logical(include_delta_metadata),
51+
max_results = max_results,
5052
omit_columns = from_logical(omit_columns),
5153
omit_properties = from_logical(omit_properties),
5254
omit_username = from_logical(omit_username),
@@ -56,7 +58,7 @@ db_uc_tables_list <- function(catalog, schema, max_results = 50,
5658
)
5759

5860
if (perform_request) {
59-
db_perform_request(req)$tables
61+
db_perform_request(req)
6062
} else {
6163
req
6264
}
@@ -228,4 +230,3 @@ db_uc_tables_summaries <- function(catalog,
228230
req
229231
}
230232
}
231-

R/uc-volumes.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
#'
1212
#' @family Unity Catalog Volume Management
1313
#'
14-
#' @returns List
14+
#' @returns Full API response list, including `next_page_token` when present,
15+
#' or an `httr2_request` when `perform_request = FALSE`.
1516
#' @export
1617
db_uc_volumes_list <- function(catalog, schema,
1718
max_results = 10000,
@@ -36,7 +37,7 @@ db_uc_volumes_list <- function(catalog, schema,
3637
)
3738

3839
if (perform_request) {
39-
db_perform_request(req)$volumes
40+
db_perform_request(req)
4041
} else {
4142
req
4243
}
@@ -214,4 +215,3 @@ db_uc_volumes_create <- function(catalog, schema, volume,
214215
}
215216

216217

217-

man/db_uc_catalogs_list.Rd

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/db_uc_schemas_list.Rd

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/db_uc_tables_list.Rd

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)