Amazon Athena JDBC Driver Wrapper Supporting the 'metis' Package
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
boB Rudis a01ab3351f
initial commit
7 年前
R initial commit 7 年前
inst initial commit 7 年前
man initial commit 7 年前
tests initial commit 7 年前
.Rbuildignore initial commit 7 年前
.codecov.yml initial commit 7 年前
.gitignore initial commit 7 年前
.travis.yml initial commit 7 年前
DESCRIPTION initial commit 7 年前
NAMESPACE initial commit 7 年前
NEWS.md initial commit 7 年前
README.Rmd initial commit 7 年前
README.md initial commit 7 年前
metis.Rproj initial commit 7 年前

README.md

metis : Helpers for Accessing and Querying Amazon Athena

Including a lightweight RJDBC shim.

THIS IS SUPER ALPHA QUALITY. NOTHING TO SEE HERE. MOVE ALONG.

The goal will be to get around enough of the "gotchas" that are preventing raw RJDBC Athena connecitons from "just working" with dplyr v0.6.0+ and also get around the fetchSize problem without having to not use dbGetQuery().

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

See the Usage section for an example.

The following functions are implemented:

  • athena_connect: Make a JDBC connection to Athena (this returns an AthenaConnection object which is a super-class of it's RJDBC vanilla counterpart)
  • Athena: AthenaJDBC`
  • AthenaConnection-class: AthenaJDBC
  • AthenaDriver-class: AthenaJDBC
  • AthenaResult-class: AthenaJDBC
  • dbConnect-method: AthenaJDBC
  • dbGetQuery-method: AthenaJDBC
  • dbSendQuery-method: AthenaJDBC

Installation

devtools::install_github("hrbrmstr/metis")

Usage

library(metis)
library(dplyr)

# current verison
packageVersion("metis")
## [1] '0.1.0'
ath <- athena_connect("your_schema_name")

res <- dbGetQuery(ath, "
SELECT format_datetime(timestamp, 'yyyy-MM-dd HH:00:00') timestamp,
        port as field, count(port) cnt_field FROM your_schema_name.your_table_name
        WHERE CONTAINS(ARRAY['201705'], date)
        AND port IN (445, 139, 3389)
        AND timestamp > date '2017-05-01'
        AND timestamp <= date '2017-05-22'
GROUP BY format_datetime(timestamp, 'yyyy-MM-dd HH:00:00'), port LIMIT 1000000
")