Skip to content

Commit

Permalink
Merge pull request #72 from ekocsis3/location
Browse files Browse the repository at this point in the history
add location param to bqr_get_job
  • Loading branch information
MarkEdmondson1234 authored May 20, 2024
2 parents c012ac8 + d407c95 commit 13c6307
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
21 changes: 17 additions & 4 deletions R/jobs.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ bqr_wait_for_job <- function(job, wait=5){
format = "%H:%M:%S"), level = 3)

job <- bqr_get_job(projectId = job$jobReference$projectId,
jobId = job$jobReference$jobId)
jobId = job$jobReference$jobId,
location = job$jobReference$location)

if(getOption("googleAuthR.verbose") <= 2){
myMessage("job configuration:")
Expand Down Expand Up @@ -81,6 +82,7 @@ bqr_wait_for_job <- function(job, wait=5){
#'
#' @param projectId projectId of job
#' @param jobId jobId to poll, or a job Object
#' @param location location where job is run. Required for single-region locations when jobId is not a job Object.
#'
#' @return A Jobs resource
#'
Expand Down Expand Up @@ -134,24 +136,35 @@ bqr_wait_for_job <- function(job, wait=5){
#'
#' @family BigQuery asynch query functions
#' @export
bqr_get_job <- function(jobId = .Last.value, projectId = bqr_get_global_project()){
bqr_get_job <- function(jobId = .Last.value,
projectId = bqr_get_global_project(),
location = NULL) {
check_bq_auth()

if(is.job(jobId)){
jobId <- jobId$jobReference$jobId
location <- jobId$jobReference$location
}
stopifnot(inherits(projectId, "character"),
inherits(jobId, "character"))

if (!is.null(location)) {
pars <- list(location = location)
} else {
pars <- NULL
}

## make job
job <-
googleAuthR::gar_api_generator("https://bigquery.googleapis.com/bigquery/v2",
"GET",
path_args = list(projects = projectId,
jobs = jobId))
jobs = jobId),
pars_args = pars)

req <- job(path_arguments = list(projects = projectId,
jobs = jobId))
jobs = jobId),
pars_args = pars)

as.job(req$content)

Expand Down
5 changes: 3 additions & 2 deletions R/uploadData.R
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,8 @@ check_req <- function(req, wait) {
req$content$jobReference$jobId, level = 3)

out <- bqr_get_job(req$content$jobReference$jobId,
projectId = req$content$jobReference$projectId)
projectId = req$content$jobReference$projectId,
location = req$content$jobReference$location)
}

} else {
Expand Down Expand Up @@ -525,4 +526,4 @@ standard_csv <- function(values) {

# Don't read trailing nl
readChar(tmp, file.info(tmp)$size - 1, useBytes = TRUE)
}
}
8 changes: 7 additions & 1 deletion man/bqr_get_job.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 13c6307

Please sign in to comment.