From fda5d321db0e361aa2306dd685965de4edf825e6 Mon Sep 17 00:00:00 2001 From: Tom Jemmett Date: Mon, 11 May 2026 14:07:07 +0100 Subject: [PATCH 1/4] adds pagination support for reading from azure tables --- R/read_azure_table.R | 47 ++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/R/read_azure_table.R b/R/read_azure_table.R index c9a9269..377fb6c 100644 --- a/R/read_azure_table.R +++ b/R/read_azure_table.R @@ -10,21 +10,38 @@ read_azure_table <- function( table_endpoint = Sys.getenv("AZ_TABLE_EP"), token = get_auth_token() ) { - access_token <- token |> - purrr::pluck("credentials", "access_token") - headers <- list("2025-11-05", "application/json;odata=nometadata") |> - purrr::set_names(c("x-ms-version", "Accept")) - - resp <- httr2::request(table_endpoint) |> + base_req <- httr2::request(table_endpoint) |> httr2::req_url_path_append(table_name) |> - httr2::req_auth_bearer_token(access_token) |> - httr2::req_headers(!!!headers) |> - httr2::req_perform() |> - httr2::resp_check_status() + httr2::req_auth_bearer_token(token$credentials$access_token) |> + httr2::req_headers( + "x-ms-version" = "2025-11-05", + "Accept" = "application/json;odata=nometadata" + ) + + responses <- httr2::req_perform_iterative( + req = base_req, + next_req = function(resp, req) { + headers <- httr2::resp_headers(resp) + + pk <- headers[["x-ms-continuation-nextpartitionkey"]] + rk <- headers[["x-ms-continuation-nextrowkey"]] + + # Stop when no continuation headers are present + if (is.null(pk) && is.null(rk)) { + return(NULL) + } + + httr2::req_url_query( + req, + NextPartitionKey = pk, + NextRowKey = rk + ) + } + ) - resp |> - httr2::resp_body_json() |> - purrr::pluck("value") |> - purrr::map(tibble::as_tibble) |> - purrr::list_rbind() + responses |> + purrr::map(httr2::resp_body_json, simplifyVector = TRUE) |> + purrr::map("value") |> + purrr::list_rbind() |> + tibble::as_tibble() } From f31d098266e1b52753f78db94f78c1b516c66e0e Mon Sep 17 00:00:00 2001 From: Tom Jemmett Date: Mon, 11 May 2026 14:57:16 +0100 Subject: [PATCH 2/4] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- R/read_azure_table.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/R/read_azure_table.R b/R/read_azure_table.R index 377fb6c..7ecb735 100644 --- a/R/read_azure_table.R +++ b/R/read_azure_table.R @@ -42,6 +42,8 @@ read_azure_table <- function( responses |> purrr::map(httr2::resp_body_json, simplifyVector = TRUE) |> purrr::map("value") |> + purrr::list_flatten() |> + purrr::map(tibble::as_tibble_row) |> purrr::list_rbind() |> tibble::as_tibble() } From 75d9f64ad858c2438878a30a513d4af1f7fd90ab Mon Sep 17 00:00:00 2001 From: Tom Jemmett Date: Mon, 11 May 2026 15:19:45 +0100 Subject: [PATCH 3/4] adds check for status --- R/read_azure_table.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/R/read_azure_table.R b/R/read_azure_table.R index 7ecb735..7df7171 100644 --- a/R/read_azure_table.R +++ b/R/read_azure_table.R @@ -21,6 +21,8 @@ read_azure_table <- function( responses <- httr2::req_perform_iterative( req = base_req, next_req = function(resp, req) { + httr2::resp_check_status(resp) + headers <- httr2::resp_headers(resp) pk <- headers[["x-ms-continuation-nextpartitionkey"]] From 02954fd4a927be84ca560b31bd9f8ca3ba2311be Mon Sep 17 00:00:00 2001 From: Tom Jemmett Date: Tue, 12 May 2026 09:43:17 +0100 Subject: [PATCH 4/4] removes uneccesary call --- R/read_azure_table.R | 1 - 1 file changed, 1 deletion(-) diff --git a/R/read_azure_table.R b/R/read_azure_table.R index 7df7171..399d6ca 100644 --- a/R/read_azure_table.R +++ b/R/read_azure_table.R @@ -45,7 +45,6 @@ read_azure_table <- function( purrr::map(httr2::resp_body_json, simplifyVector = TRUE) |> purrr::map("value") |> purrr::list_flatten() |> - purrr::map(tibble::as_tibble_row) |> purrr::list_rbind() |> tibble::as_tibble() }