Browse Source

cleanup before public debut

master
boB Rudis 7 years ago
parent
commit
d9d7a06ccb
No known key found for this signature in database GPG Key ID: 2A514A4997464560
  1. 13
      R/jdbc.r
  2. 14
      R/metis.r
  3. 2
      README.Rmd
  4. 2
      README.md
  5. 12
      man/athena_connect.Rd
  6. 3
      man/dbConnect-AthenaDriver-method.Rd

13
R/jdbc.r

@ -9,7 +9,7 @@ setClass("AthenaDriver", representation("JDBCDriver", identifier.quote="characte
Athena <- function(identifier.quote='`') { Athena <- function(identifier.quote='`') {
drv <- JDBC(driverClass="com.amazonaws.athena.jdbc.AthenaDriver", drv <- JDBC(driverClass="com.amazonaws.athena.jdbc.AthenaDriver",
system.file("AthenaJDBC41-1.0.1.jar", package="metis"), system.file("AthenaJDBC41-1.0.1.jar", package="metis"),
identifier.quote="'") identifier.quote=identifier.quote)
return(as(drv, "AthenaDriver")) return(as(drv, "AthenaDriver"))
} }
@ -23,8 +23,10 @@ setMethod(
def = function(drv, def = function(drv,
provider = "com.amazonaws.athena.jdbc.shaded.com.amazonaws.auth.EnvironmentVariableCredentialsProvider", provider = "com.amazonaws.athena.jdbc.shaded.com.amazonaws.auth.EnvironmentVariableCredentialsProvider",
conn_string = 'jdbc:awsathena://athena.us-east-1.amazonaws.com:443/', region = "us-east-1",
schema_name, ...) { schema_name = "default", ...) {
conn_string = sprintf('jdbc:awsathena://athena.%s.amazonaws.com:443/', region)
if (!is.null(provider)) { if (!is.null(provider)) {
@ -35,8 +37,7 @@ setMethod(
} else { } else {
jc <- callNextMethod(drv, jc <- callNextMethod(drv, conn_string,
'jdbc:awsathena://athena.us-east-1.amazonaws.com:443/',
s3_staging_dir=Sys.getenv("AWS_S3_STAGING_DIR"), s3_staging_dir=Sys.getenv("AWS_S3_STAGING_DIR"),
schema_name=schema_name, schema_name=schema_name,
user = Sys.getenv("AWS_ACCESS_KEY_ID"), user = Sys.getenv("AWS_ACCESS_KEY_ID"),
@ -85,7 +86,7 @@ setMethod(
def = function(conn, statement, ...) { def = function(conn, statement, ...) {
r <- dbSendQuery(conn, statement, ...) r <- dbSendQuery(conn, statement, ...)
on.exit(.jcall(r@stat, "V", "close")) on.exit(.jcall(r@stat, "V", "close"))
dplyr::tbl_df(fetch(r, -1, block=256)) dplyr::tbl_df(fetch(r, -1, block=1000))
} }
) )

14
R/metis.r

@ -11,11 +11,15 @@
#' For `simple` == `FALSE` the expectation is that you're working with a managed #' For `simple` == `FALSE` the expectation is that you're working with a managed
#' `~/.aws/credentials` file. #' `~/.aws/credentials` file.
#' #'
#' There's a high likelihood of params changing in the near term as I work this out, but I'm
#' not very keen on parameter-izing things like id/secret.
#'
#' @md #' @md
#' @param default_schema def sch #' @param default_schema def schema
#' @param simple simple #' @param region AWS region (Ref: <http://docs.aws.amazon.com/general/latest/gr/rande.html#athena>)
#' @param simple pickup id/secret only or use temp token? (this will become more robust)
#' @export #' @export
athena_connect <- function(default_schema, simple=FALSE) { athena_connect <- function(default_schema = "default", region = "us-east-1", simple=FALSE) {
athena_jdbc <- Athena() athena_jdbc <- Athena()
@ -35,11 +39,11 @@ athena_connect <- function(default_schema, simple=FALSE) {
Sys.unsetenv("AWS_SESSION_TOKEN") Sys.unsetenv("AWS_SESSION_TOKEN")
Sys.setenv(AWS_SESSION_TOKEN = aws_profile$aws_session_token) Sys.setenv(AWS_SESSION_TOKEN = aws_profile$aws_session_token)
con <- dbConnect(athena_jdbc, schema_name = default_schema) con <- dbConnect(athena_jdbc, schema_name = default_schema, region = region)
} else { } else {
con <- dbConnect(athena_jdbc, provider = NULL, schema_name = default_schema) con <- dbConnect(athena_jdbc, provider = NULL, schema_name = default_schema, region = region)
} }

2
README.Rmd

@ -15,6 +15,8 @@ connecitons from "just working" with `dplyr` v0.6.0+ and also get around the [`f
It will also support more than the vanilla id/secret auth mechism (it currently support the default basic auth and temp token auth, the latter via environment variables). It will also support more than the vanilla id/secret auth mechism (it currently support the default basic auth and temp token auth, the latter via environment variables).
This package includes the `AthenaJDBC41-1.0.1.jar` JAR file out of convenience but that will likely move to a separate package as this gets closer to prime time.
See the **Usage** section for an example. See the **Usage** section for an example.
The following functions are implemented: The following functions are implemented:

2
README.md

@ -11,6 +11,8 @@ The goal will be to get around enough of the "gotchas" that are preventing raw R
It will also support more than the vanilla id/secret auth mechism (it currently support the default basic auth and temp token auth, the latter via environment variables). It will also support more than the vanilla id/secret auth mechism (it currently support the default basic auth and temp token auth, the latter via environment variables).
This package includes the `AthenaJDBC41-1.0.1.jar` JAR file out of convenience but that will likely move to a separate package as this gets closer to prime time.
See the **Usage** section for an example. See the **Usage** section for an example.
The following functions are implemented: The following functions are implemented:

12
man/athena_connect.Rd

@ -4,12 +4,15 @@
\alias{athena_connect} \alias{athena_connect}
\title{Make a JDBC connection to Athena} \title{Make a JDBC connection to Athena}
\usage{ \usage{
athena_connect(default_schema, simple = FALSE) athena_connect(default_schema = "default", region = "us-east-1",
simple = FALSE)
} }
\arguments{ \arguments{
\item{default_schema}{def sch} \item{default_schema}{def schema}
\item{simple}{simple} \item{region}{AWS region (Ref: \url{http://docs.aws.amazon.com/general/latest/gr/rande.html#athena})}
\item{simple}{pickup id/secret only or use temp token? (this will become more robust)}
} }
\description{ \description{
Handles the up-front JDBC config Handles the up-front JDBC config
@ -24,4 +27,7 @@ defined (a good place is \code{~/.Renviron}):
For \code{simple} == \code{FALSE} the expectation is that you're working with a managed For \code{simple} == \code{FALSE} the expectation is that you're working with a managed
\code{~/.aws/credentials} file. \code{~/.aws/credentials} file.
There's a high likelihood of params changing in the near term as I work this out, but I'm
not very keen on parameter-izing things like id/secret.
} }

3
man/dbConnect-AthenaDriver-method.Rd

@ -7,8 +7,7 @@
\usage{ \usage{
\S4method{dbConnect}{AthenaDriver}(drv, \S4method{dbConnect}{AthenaDriver}(drv,
provider = "com.amazonaws.athena.jdbc.shaded.com.amazonaws.auth.EnvironmentVariableCredentialsProvider", provider = "com.amazonaws.athena.jdbc.shaded.com.amazonaws.auth.EnvironmentVariableCredentialsProvider",
conn_string = "jdbc:awsathena://athena.us-east-1.amazonaws.com:443/", region = "us-east-1", schema_name = "default", ...)
schema_name, ...)
} }
\description{ \description{
AthenaJDBC AthenaJDBC

Loading…
Cancel
Save