~hrbrmstr/sergeant

44e7e601fe7901588d516d3577585061fd0bcb9d — Bob Rudis 3 years ago 307fa78
initial stab at de-auto-coupling rJava & RJDBC
M DESCRIPTION => DESCRIPTION +6 -7
@@ 1,17 1,16 @@
Package: sergeant
Title: Tools to Transform and Query Data with the 'Apache Drill' 'REST API' and 'JDBC' Interfaces, 
    Plus 'dplyr' and 'DBI' Interfaces
Version: 0.4.0
Title: Tools to Transform and Query Data with 'Apache' 'Drill'
Version: 0.5.0
Authors@R: c(person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre")),
             person("Edward", "Visel", email = "edward.visel@gmail.com", role = "ctb"))
Description: 'Apache Drill' is a low-latency distributed query engine designed to enable 
    data exploration and analytics on both relational and non-relational datastores, 
    scaling to petabytes of data. Methods are provided that enable working with 'Apache Drill'
    instances via the 'REST API', the JDBC interface, 'DBI' 'methods' and 'dplyr'.
    instances via the 'REST API', the JDBC interface, 'DBI' 'methods' and 'dplyr'/'dbplyr'.
Depends:
    R (>= 3.0.0),
    DBI,
    dplyr (>= 0.5.0.9000),
    dplyr (>= 0.7.0),
    dbplyr
URL: http://github.com/hrbrmstr/sergeant
BugReports: https://github.com/hrbrmstr/sergeant/issues


@@ 25,11 24,11 @@ Imports:
    readr,
    purrr,
    utils,
    RJDBC,
    rJava,
    scales,
    methods
Suggests:
    RJDBC,
    rJava,
    testthat
RoxygenNote: 6.0.1
Remotes:

M NEWS.md => NEWS.md +4 -0
@@ 1,3 1,7 @@
# sergeant 0.5.0

- make rJava & RJDBC optional (WIP)

# sergeant 0.4.0

- Getting ready for new `dplyr` (thx to Edward Visel)

M R/dplyr.r => R/dplyr.r +1 -0
@@ 147,6 147,7 @@ sql_translate_env.DrillConnection <- function(con) {
      as.date = function(x) build_sql("CAST(", x, " AS DATE)"),
      as.posixct = function(x) build_sql("CAST(", x, " AS TIMESTAMP)"),
      as.logical = function(x) build_sql("CAST(", x, " AS BOOLEAN)"),
      grepl = function(x, y) build_sql("CONTAINS(", x, ", ", y, ")"),
      cbrt = sql_prefix("CBRT", 1),
      degrees = sql_prefix("DEGREES", 1),
      e = sql_prefix("E", 0),

M R/jdbc.r => R/jdbc.r +5 -1
@@ 2,7 2,7 @@
#'
#' The DRILL JDBC driver fully-qualified path must be placed in the
#' \code{DRILL_JDBC_JAR} environment variable. This is best done via \code{~/.Renviron}
#' for interactive work. e.g. \code{DRILL_JDBC_JAR=/usr/local/drill/jars/drill-jdbc-all-1.9.0.jar}
#' for interactive work. e.g. \code{DRILL_JDBC_JAR=/usr/local/drill/jars/jdbc-driver/drill-jdbc-all-1.10.0.jar}
#'
#' @param nodes character vector of nodes. If more than one node, you can either have
#'              a single string with the comma-separated node:port pairs pre-made or


@@ 27,6 27,10 @@
#' }
drill_jdbc <- function(nodes="localhost:2181", cluster_id=NULL, schema=NULL, use_zk=TRUE) {

  if (!requireNamespace("RJDBC")) {
    stop("RJDBC & rJava are required to use the Drill JDBC connectors", .call=FALSE)
  }

  jar_path <- Sys.getenv("DRILL_JDBC_JAR")
  if (!file.exists(jar_path)) {
    stop(sprintf("Cannot locate DRILL JDBC JAR [%s]", jar_path))

M R/query.r => R/query.r +6 -2
@@ 17,14 17,18 @@
#' @references \href{https://drill.apache.org/docs/}{Drill documentation}
#' @export
#' @examples \dontrun{
#' drill_con() %>%
#' drill_conection() %>%
#'   drill_query("SELECT * FROM cp.`employee.json` limit 5")
#' }
drill_query <- function(drill_con, query, uplift=TRUE, .progress=interactive()) {

  if (inherits(drill_con, "JDBCConnection")) {

    dplyr::tbl_df(RJDBC::dbGetQuery(drill_con, query) )
    if (!requireNamespace("RJDBC")) {
      stop("RJDBC & rJava are required to use the Drill JDBC connectors", .call=FALSE)
    }

    dplyr::tbl_df(RJDBC::dbGetQuery(drill_con, query))

  } else {


M R/schemas.R => R/schemas.R +1 -1
@@ 28,7 28,7 @@ drill_use <- function(drill_con, schema_name) {
#' @export
#' @references \href{https://drill.apache.org/docs/}{Drill documentation}
#' @examples \dontrun{
#' drill_con() %>% drill_show_files("dfs.tmp")
#' drill_connection() %>% drill_show_files("dfs.tmp")
#' }
drill_show_files <- function(drill_con, schema_spec) {
  query <- sprintf("SHOW FILES IN %s", schema_spec)

M R/sergeant-package.r => R/sergeant-package.r +1 -2
@@ 1,5 1,4 @@
#' Tools to Transform and Query Data with the 'Apache Drill' 'REST API' and 'JDBC' Interfaces,
#' Plus 'dplyr' and 'DBI' Interfaces
#' Tools to Transform and Query Data with 'Apache' 'Drill'
#'
#' Drill is an innovative low-latency distributed query engine designed to enable data
#' exploration and analytics on both relational and non-relational datastores, scaling to

M R/sergeant.r => R/sergeant.r +1 -1
@@ 188,7 188,7 @@ drill_options <- function(drill_con, pattern=NULL) {
#' @export
#' @references \href{https://drill.apache.org/docs/}{Drill documentation}
#' @examples \dontrun{
#' drill_con() %>% drill_stats()
#' drill_connection() %>% drill_stats()
#' }
drill_stats <- function(drill_con) {
  drill_server <- make_server(drill_con)

A R/zzz.R => R/zzz.R +3 -0
@@ 0,0 1,3 @@
.onLoad <- function(libname, pkgname) {
  if (requireNamespace("rJava")) rJava::.jpackage(pkgname, lib.loc = libname)
}

D inst/jars/drill-jdbc-all-1.9.0.jar => inst/jars/drill-jdbc-all-1.9.0.jar +0 -0
A inst/java/log4j.properties => inst/java/log4j.properties +4 -0
@@ 0,0 1,4 @@
log4j.rootLogger=ERROR,stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%p\t%d{ISO8601}\t%r\t%c\t[%t]\t%m%n

M man/drill_jdbc.Rd => man/drill_jdbc.Rd +1 -1
@@ 26,7 26,7 @@ a JDBC connection object
\description{
The DRILL JDBC driver fully-qualified path must be placed in the
\code{DRILL_JDBC_JAR} environment variable. This is best done via \code{~/.Renviron}
for interactive work. e.g. \code{DRILL_JDBC_JAR=/usr/local/drill/jars/drill-jdbc-all-1.9.0.jar}
for interactive work. e.g. \code{DRILL_JDBC_JAR=/usr/local/drill/jars/jdbc-driver/drill-jdbc-all-1.10.0.jar}
}
\examples{
\dontrun{

M man/drill_query.Rd => man/drill_query.Rd +1 -1
@@ 28,7 28,7 @@ set is huge).
}
\examples{
\dontrun{
drill_con() \%>\%
drill_conection() \%>\%
  drill_query("SELECT * FROM cp.`employee.json` limit 5")
}
}

M man/drill_show_files.Rd => man/drill_show_files.Rd +1 -1
@@ 16,7 16,7 @@ Show files in a file system schema.
}
\examples{
\dontrun{
drill_con() \%>\% drill_show_files("dfs.tmp")
drill_connection() \%>\% drill_show_files("dfs.tmp")
}
}
\references{

M man/drill_stats.Rd => man/drill_stats.Rd +1 -1
@@ 14,7 14,7 @@ Get Drillbit information, such as ports numbers
}
\examples{
\dontrun{
drill_con() \%>\% drill_stats()
drill_connection() \%>\% drill_stats()
}
}
\references{

M man/sergeant.Rd => man/sergeant.Rd +1 -2
@@ 4,8 4,7 @@
\name{sergeant}
\alias{sergeant}
\alias{sergeant-package}
\title{Tools to Transform and Query Data with the 'Apache Drill' 'REST API' and 'JDBC' Interfaces,
Plus 'dplyr' and 'DBI' Interfaces}
\title{Tools to Transform and Query Data with 'Apache' 'Drill'}
\description{
Drill is an innovative low-latency distributed query engine designed to enable data
exploration and analytics on both relational and non-relational datastores, scaling to