Browse Source

cleanup before public debut

master
boB Rudis 3 years ago
parent
commit
d9d7a06ccb
No known key found for this signature in database GPG Key ID: 2A514A4997464560
6 changed files with 30 additions and 16 deletions
  1. +7
    -6
      R/jdbc.r
  2. +9
    -5
      R/metis.r
  3. +2
    -0
      README.Rmd
  4. +2
    -0
      README.md
  5. +9
    -3
      man/athena_connect.Rd
  6. +1
    -2
      man/dbConnect-AthenaDriver-method.Rd

+ 7
- 6
R/jdbc.r View File

@@ -9,7 +9,7 @@ setClass("AthenaDriver", representation("JDBCDriver", identifier.quote="characte
Athena <- function(identifier.quote='`') {
drv <- JDBC(driverClass="com.amazonaws.athena.jdbc.AthenaDriver",
system.file("AthenaJDBC41-1.0.1.jar", package="metis"),
identifier.quote="'")
identifier.quote=identifier.quote)
return(as(drv, "AthenaDriver"))
}

@@ -23,8 +23,10 @@ setMethod(

def = function(drv,
provider = "com.amazonaws.athena.jdbc.shaded.com.amazonaws.auth.EnvironmentVariableCredentialsProvider",
conn_string = 'jdbc:awsathena://athena.us-east-1.amazonaws.com:443/',
schema_name, ...) {
region = "us-east-1",
schema_name = "default", ...) {

conn_string = sprintf('jdbc:awsathena://athena.%s.amazonaws.com:443/', region)

if (!is.null(provider)) {

@@ -35,8 +37,7 @@ setMethod(

} else {

jc <- callNextMethod(drv,
'jdbc:awsathena://athena.us-east-1.amazonaws.com:443/',
jc <- callNextMethod(drv, conn_string,
s3_staging_dir=Sys.getenv("AWS_S3_STAGING_DIR"),
schema_name=schema_name,
user = Sys.getenv("AWS_ACCESS_KEY_ID"),
@@ -85,7 +86,7 @@ setMethod(
def = function(conn, statement, ...) {
r <- dbSendQuery(conn, statement, ...)
on.exit(.jcall(r@stat, "V", "close"))
dplyr::tbl_df(fetch(r, -1, block=256))
dplyr::tbl_df(fetch(r, -1, block=1000))
}

)

+ 9
- 5
R/metis.r View File

@@ -11,11 +11,15 @@
#' For `simple` == `FALSE` the expectation is that you're working with a managed
#' `~/.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
#' @param default_schema def sch
#' @param simple simple
#' @param default_schema def schema
#' @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
athena_connect <- function(default_schema, simple=FALSE) {
athena_connect <- function(default_schema = "default", region = "us-east-1", simple=FALSE) {

athena_jdbc <- Athena()

@@ -35,11 +39,11 @@ athena_connect <- function(default_schema, simple=FALSE) {
Sys.unsetenv("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 {

con <- dbConnect(athena_jdbc, provider = NULL, schema_name = default_schema)
con <- dbConnect(athena_jdbc, provider = NULL, schema_name = default_schema, region = region)

}



+ 2
- 0
README.Rmd View File

@@ -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).

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.

The following functions are implemented:


+ 2
- 0
README.md View File

@@ -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).

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.

The following functions are implemented:


+ 9
- 3
man/athena_connect.Rd View File

@@ -4,12 +4,15 @@
\alias{athena_connect}
\title{Make a JDBC connection to Athena}
\usage{
athena_connect(default_schema, simple = FALSE)
athena_connect(default_schema = "default", region = "us-east-1",
simple = FALSE)
}
\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{
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
\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.
}

+ 1
- 2
man/dbConnect-AthenaDriver-method.Rd View File

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


Loading…
Cancel
Save