Skip to content

Commit

Permalink
version 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Edmondson authored and cran-robot committed May 3, 2017
1 parent 14361cb commit 006af5a
Show file tree
Hide file tree
Showing 62 changed files with 1,418 additions and 533 deletions.
14 changes: 7 additions & 7 deletions DESCRIPTION
@@ -1,6 +1,6 @@
Package: bigQueryR
Title: Interface with Google BigQuery with Shiny Compatibility
Version: 0.2.0
Version: 0.3.0
Authors@R: c(person("Mark", "Edmondson",email = "r@sunholo.com",
role = c("aut", "cre")),
person("Hadley", "Wickham", , "hadley@rstudio.com", role = "ctb")
Expand All @@ -14,15 +14,15 @@ BugReports: https://github.com/cloudyr/bigQueryR/issues
License: MIT + file LICENSE
LazyData: TRUE
Depends: R (>= 3.2.0)
Imports: googleAuthR (>= 0.3.1), googleCloudStorageR
Suggests: shiny (>= 0.12.1), jsonlite (>= 1.0), httr (>= 1.2.1), knitr,
rmarkdown
RoxygenNote: 5.0.1
Imports: googleAuthR (>= 0.5.1), googleCloudStorageR (>= 0.2.0),
jsonlite (>= 1.0), httr (>= 1.2.1), assertthat
Suggests: shiny (>= 0.12.1), knitr, rmarkdown, testthat
RoxygenNote: 6.0.1
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2016-08-11 11:01:22 UTC; mark
Packaged: 2017-05-02 21:18:54 UTC; mark
Author: Mark Edmondson [aut, cre],
Hadley Wickham [ctb]
Maintainer: Mark Edmondson <r@sunholo.com>
Repository: CRAN
Date/Publication: 2016-08-11 13:58:11
Date/Publication: 2017-05-03 06:52:58 UTC
4 changes: 2 additions & 2 deletions LICENSE
@@ -1,2 +1,2 @@
YEAR: 2015
COPYRIGHT HOLDER: Sunholo Ltd.
YEAR: 2017
COPYRIGHT HOLDER: Sunholo Ltd.
102 changes: 58 additions & 44 deletions MD5
@@ -1,47 +1,61 @@
8f28e45122fb75714fb07970e01cf7ea *DESCRIPTION
6346ec78b27187fcd99986124133fc2a *LICENSE
7c427fa92df77717f351519a54b71791 *NAMESPACE
3e13cc9ced89f79dfc4e469975fd9659 *NEWS.md
648363052aba9854b423375c99657918 *R/bigQueryR.R
01672f25679abbfa0707f48efd714348 *R/cloudStorage.R
9b3a51b950a50b6ecd6b406a1be1369a *R/dataParseFunctions.R
758e0bc804503f03ad4a72b14418527e *R/downloadData.R
17dd3b9c30dac16d5bd026f3df74b488 *R/jobs.R
2e82d5ec073e9d2b36ae027e193f7cbf *R/listBigQuery.R
440c9973dcb208844c3edb429d0b9802 *R/options.R
f772297399468e70b3e420a1516a1351 *R/query.R
c8a80e9159390e4888025b8a8910b029 *R/tables.R
a72bfa91dafebe6fe204accf2009264c *R/uploadData.R
f20c09c89a63a3f153f162a16cd64c95 *R/utilities.R
03521890ac6dd06a536a5d3d7a8af502 *README.md
b6bf9fa119de5ecadc2965be4246d273 *build/vignette.rds
f71310f8d070e87efc1fa772ca5ffe07 *DESCRIPTION
1918b8807c8b12031663a9efe23458e0 *LICENSE
bc6b17f202ec4268089cc692723e20ca *NAMESPACE
1da1f905feb2803ffe111ca9d961a4b2 *NEWS.md
b0c470bbd0c12471ff6d861f1218fc40 *R/auth.R
086eb868dbba4a932d07a6733668b75d *R/bigQueryR.R
455eeee08045823b8139a02fcbe11184 *R/dataParseFunctions.R
9f55dd2698f912ef056568ea7b7de704 *R/downloadData.R
2c421cc2f3b9e1495cc7eaa2ee2e9455 *R/globals.R
68d75a7ae77b9432833e0e1332f1a668 *R/jobs.R
32aa14239281734f839e12e265f23b92 *R/listBigQuery.R
c19901ae9c831f8fd2a0736d3179e55f *R/options.R
26ab87c8358b202f129adbcb56811423 *R/partition.R
4fcedd2524f11131bff92a22277f68e0 *R/print_methods.R
596baca6e9394a11920a4649eebbb6e3 *R/query.R
eef5d355fb0e6bab3f7a4a456baeb9d7 *R/tables.R
755b8b0ce51436d58e6ccb8f6172566b *R/uploadData.R
e1db41010e5046aa90d77fe6cc3acd1c *R/utilities.R
bdecbcecf9ef55523b5d34dcac0cb906 *build/vignette.rds
e8d818d4be126d9c02920eb65f6437f9 *inst/CITATION
59d79154d6247524cbbc88634227446a *inst/doc/bigQueryR.Rmd
0fb2f16a5513073e8a38c12dfae03306 *inst/doc/bigQueryR.html
0ab1a7ba9227ed7bdd95302ad44b2645 *man/bigQueryR.Rd
21dc463667cc1fcdf1031f8d75f666d2 *man/bqr_auth.Rd
57e2b5ffc089a2058165301bb7a1514e *man/bqr_create_table.Rd
e56931b4b933cbb94f91186d9bfba040 *man/bqr_delete_table.Rd
2d48482a2881a48471a797f925a1b2cf *man/bqr_download_extract.Rd
f3a333525b6c382a76ff09b637c0271d *man/bqr_extract_data.Rd
1d6daf45023594342594cecb9d6ce8c9 *man/bqr_get_job.Rd
164c6b52867cb9c94ddca698c46b90a9 *man/bqr_grant_extract_access.Rd
eb00021cde39fd03185b5325e3db586e *man/bqr_list_datasets.Rd
3242264356742e6692fd2381b94fe97f *man/bqr_list_jobs.Rd
384fc76e5ea61dea13447d889433f663 *man/bqr_list_projects.Rd
1a1da54c1496a3dd366a896fec099a5b *man/bqr_list_tables.Rd
8af9a2131e608514747ddd274f42aa03 *man/bqr_query.Rd
a6cb20f7277f2cba72f7f168559399c6 *man/bqr_query_asynch.Rd
10c0c1853541fe29b740003e4b007400 *man/bqr_table_data.Rd
75e152274b3fb966adcb1b34517787c9 *man/bqr_table_meta.Rd
48d94d31a9d1721c054e97c29c2c17ff *man/bqr_upload_data.Rd
3883396c01758b50b76afed5f31fbf9c *man/bqr_wait_for_job.Rd
a2f3694cd0d6e26e4d2cb131c35ad424 *man/error.message.Rd
0d884342e1dce6a8d9dde386ccefa52f *man/gcs_update_acl.Rd
691565ef7e3c837f1f51d4d6b1b7680a *man/idempotency.Rd
2240e92cd7767970a3f56d45070895a9 *man/is.NullOb.Rd
57e5ee063d87b8133cb4785429c9685a *man/is.error.Rd
172de60e13e30d803506104947d1f6b7 *man/myMessage.Rd
5eeba1d521d9a6dda8a61512f6891b9a *man/parse_bqr_query.Rd
fc01bed2025f8af7aff31ab1c21bfef7 *man/rmNullObs.Rd
ab0078545cd347c3bb7574bf0400c768 *inst/doc/bigQueryR.html
f79d7c7ac5251dc6a23a6b017defdb76 *man/bigQueryR.Rd
f2eaee4efd44db76c75a716149aba951 *man/bq_get_global_dataset.Rd
791f0abace3714d39e1e8756a20d263b *man/bq_get_global_project.Rd
7f09fd4c7f5568d6ca0d5698790d6198 *man/bq_global_dataset.Rd
2f56650fb57a829047a39efaec6da112 *man/bq_global_project.Rd
b3f9e03bb6da6feb766bfad852b58cc8 *man/bqr_auth.Rd
5f1404486f0cf5766c533a467df13929 *man/bqr_create_table.Rd
6336dd1c3338a540170f4bc92f4086ed *man/bqr_delete_table.Rd
167a725f3e64f66bac5a373787a891fb *man/bqr_download_extract.Rd
3f9ef0221ea290493a4531cbcd765a2c *man/bqr_extract_data.Rd
185fcec6d220ac634a599c672913c283 *man/bqr_get_job.Rd
16f5371ae462ea0748418e75d269ca6d *man/bqr_grant_extract_access.Rd
bbf59a86db782fe7738e324eadc78e85 *man/bqr_list_datasets.Rd
19820c74cad33004d559b82769578b46 *man/bqr_list_jobs.Rd
064792bb7a89debc8a6d4ccb396b1473 *man/bqr_list_projects.Rd
b8c81fbd5f4028e1141498493eef45c1 *man/bqr_list_tables.Rd
5b46c8237dbb1507ffd0cd8de3f98b4d *man/bqr_partition.Rd
282f8c0b94ca8120c4bb3c6b8b0abc16 *man/bqr_query.Rd
219d4fe9e4e83d3107a24839f039cc59 *man/bqr_query_asynch.Rd
6e0461025cc743c5bdeea70902f86914 *man/bqr_table_data.Rd
1d8dd1834db2e3b1d997da63bb6ef9f9 *man/bqr_table_meta.Rd
fa5d7faf959fcf014cced69a653fa418 *man/bqr_upload_data.Rd
0b5f0797e3de31820545e97f634e41d0 *man/bqr_wait_for_job.Rd
cd4ec4d5e7dbb8040424decf497029be *man/cat0.Rd
4bbba36b86bbc6eed98145c48630cc03 *man/error.message.Rd
8d453641d4c85e98f7f2c3a688fe5f46 *man/format_object_size.Rd
4e022539f6f9e50a18fceb24ea14d15f *man/idempotency.Rd
99e6d2088a016007fc87b8305dae2b56 *man/is.NullOb.Rd
73380d60c7bfa916fd6ddf62b4d0e5a6 *man/is.error.Rd
321a1d33b48d0e3a2fdb7ea034d54630 *man/js_to_posix.Rd
d76f703325b6d887279822dd0f696961 *man/myMessage.Rd
d73a74c4a41bb745e0c47c8e69b1008b *man/parse_bqr_query.Rd
c9fdcdaed7c24bf33774de3e5207116c *man/rmNullObs.Rd
4f517b883d180122b87094234afadacb *man/schema_fields.Rd
95592f7be17d720b52e846ab24cb9e32 *man/timestamp_to_r.Rd
a59ed0de0e2d665bad365061cc457dbb *tests/testthat.R
4c8d57de99d7aef7be21fe3570a77d99 *tests/testthat/auth.json
6559e60e37c35f770892f18831db6b2e *tests/testthat/test_query.R
59d79154d6247524cbbc88634227446a *vignettes/bigQueryR.Rmd
9 changes: 9 additions & 0 deletions NAMESPACE
@@ -1,5 +1,10 @@
# Generated by roxygen2: do not edit by hand

S3method(print,bqr_job)
export(bq_get_global_dataset)
export(bq_get_global_project)
export(bq_global_dataset)
export(bq_global_project)
export(bqr_auth)
export(bqr_create_table)
export(bqr_delete_table)
Expand All @@ -11,10 +16,14 @@ export(bqr_list_datasets)
export(bqr_list_jobs)
export(bqr_list_projects)
export(bqr_list_tables)
export(bqr_partition)
export(bqr_query)
export(bqr_query_asynch)
export(bqr_table_data)
export(bqr_table_meta)
export(bqr_upload_data)
export(bqr_wait_for_job)
export(schema_fields)
import(googleAuthR)
import(googleCloudStorageR)
importFrom(tools,file_ext)
24 changes: 23 additions & 1 deletion NEWS.md
@@ -1,4 +1,26 @@
# bigQueryR 0.2.0 (CRAN)
# bigQueryR 0.3.0

* Add support for realtime queries, `useQueryCache = FALSE`
* Add support for standard SQL (#21)
* Add support for hms/timestamp class uploads (#27)
* Add support for partitioned tables (#28)
* Fix bug that only returned one row for single column queries (#31 - thanks Rob)
* Allow loading of data from Google Cloud Storage to BigQuery for large files
* no error if delete non-existent table (#26)
* Add auto authentication if set environment var `BQ_AUTH_FILE` to location of auth file
* Add default project if set environment var `BQ_DEFAULT_PROJECT_ID` to project-id
* Add default dataset if set environment var `BQ_DEFAULT_DATASET` to dataset-id
* Add auto paging through table lists in `bqr_list_tables()` (#29)
* Make it clearer when jobs resulted in errors in the job print methods
* Migrate to using `googleCloudStorageR` for Cloud Storage stuff
* Set default authentication scope to `https://www.googleapis.com/auth/cloud-platform`
* Unit tests
* Upload table will now correctly report errors
* More user feedback on BigQuery jobs when running
* Allow upload of data.frames asynchrnously
* Allow auto-detection of schema for uploads

# bigQueryR 0.2.0

* Download asynch queries straight to disk via googleCloudStorageR

Expand Down
66 changes: 66 additions & 0 deletions R/auth.R
@@ -0,0 +1,66 @@
# check authenticated with correct scopes
check_bq_auth <- function(){
cloud_scopes <- c("https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/bigquery")

if(!getOption("googleAuthR.scopes.selected") %in% cloud_scopes){
stop("Not authenticated with Google BigQuery. Needs to be one of ",
paste(cloud_scopes, collapse = " "))
current_op <- getOption("googleAuthR.verbose")
options(googleAuthR.verbose = 2)
googleAuthR::gar_token_info()
options(googleAuthR.verbose = current_op)
}
}

# check authenticated with correct scopes
check_gcs_auth <- function(){
cloud_scopes <- c("https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/devstorage.full_control",
"https://www.googleapis.com/auth/devstorage.read_write")

if(!getOption("googleAuthR.scopes.selected") %in% cloud_scopes){
stop("Not authenticated with Google Cloud Storage. Needs to be one of ",
paste(cloud_scopes, collapse = " "))
current_op <- getOption("googleAuthR.verbose")
options(googleAuthR.verbose = 2)
googleAuthR::gar_token_info()
options(googleAuthR.verbose = current_op)
}
}

#' Authenticate this session
#'
#' A wrapper for \link[googleAuthR]{gar_auth} and \link[googleAuthR]{gar_auth_service}
#'
#' @param new_user If TRUE, reauthenticate via Google login screen
#' @param no_auto Will ignore auto-authentication settings if TRUE
#'
#' If you have set the environment variable \code{BQ_AUTH_FILE} to a valid file location,
#' the function will look there for authentication details.
#' Otherwise it will look in the working directory for the `.httr-oauth` file, which if not present
#' will trigger an authentication flow via Google login screen in your browser.
#'
#' If \code{BQ_AUTH_FILE} is specified, then \code{bqr_auth()} will be called upon loading the package
#' via \code{library(bigQueryR)},
#' meaning that calling this function yourself at the start of the session won't be necessary.
#'
#' \code{BQ_AUTH_FILE} can be either a token generated by \link[googleAuthR]{gar_auth} or
#' service account JSON ending with file extension \code{.json}
#'
#' @return Invisibly, the token that has been saved to the session
#' @import googleAuthR
#' @importFrom tools file_ext
#' @export
bqr_auth <- function(new_user = FALSE, no_auto = FALSE){

required_scopes <- c("https://www.googleapis.com/auth/bigquery",
"https://www.googleapis.com/auth/devstorage.full_control",
"https://www.googleapis.com/auth/cloud-platform")

googleAuthR::gar_auto_auth(required_scopes,
new_user = new_user,
no_auto = no_auto,
environment_var = "BQ_AUTH_FILE",
travis_environment_var = "TRAVIS_BQ_AUTH_FILE")
}
36 changes: 1 addition & 35 deletions R/bigQueryR.R
Expand Up @@ -8,38 +8,4 @@
#' @name bigQueryR
NULL

#' Do OAuth2 authentication
#'
#' @param token An existing OAuth2 token, if you have one.
#' @param new_user Set to TRUE if you want to go through the authentication flow again.
#'
#' @details
#' This function just wraps \code{\link[googleAuthR]{gar_auth}} from googleAuthR,
#' but means you don't need to explictly load that library.
#'
#' @seealso \code{\link[googleAuthR]{gar_auth}}
#'
#' @examples
#'
#' \dontrun{
#' library(bigQueryR)
#'
#' ## this will open your browser
#' ## Authenticate with an email that has access to the BigQuery project you need
#' bqr_auth()
#'
#' ## verify under a new user
#' bqr_auth(new_user=TRUE)
#'
#' }
#'
#' @family bigQuery meta functions
#' @export
bqr_auth <- function(token=NULL, new_user=FALSE){
options("googleAuthR.scopes.selected" = getOption("bigQueryR.scope") )
options("googleAuthR.client_id" = getOption("bigQueryR.client_id"))
options("googleAuthR.client_secret" = getOption("bigQueryR.client_secret"))
options("googleAuthR.webapp.client_id" = getOption("bigQueryR.webapp.client_id"))
options("googleAuthR.webapp.client_secret" = getOption("bigQueryR.webapp.client_secret"))
googleAuthR::gar_auth(token=token, new_user=new_user)
}

0 comments on commit 006af5a

Please sign in to comment.