~hrbrmstr/sergeant

c02beb25190ca7579aca68975a2d6e0847c185a6 — Bob Rudis 4 years ago b9a1301
README update
4 files changed, 16 insertions(+), 27 deletions(-)

M R/aaa.r
M R/query.r
M README.md
M man/drill_query.Rd
M R/aaa.r => R/aaa.r +1 -5
@@ 2,12 2,8 @@ utils::globalVariables(c("error", "everything", "isDirectory", "name", "params",

make_server <- function(drill_con) {

  ret <- sprintf("%s://%s:%s",
  sprintf("%s://%s:%s",
          ifelse(drill_con$ssl[1], "https", "http"),
          drill_con$host, drill_con$port)

  message(ret)

  ret

}

M R/query.r => R/query.r +7 -6
@@ 2,14 2,16 @@
#'
#' @param drill_con drill server connection object setup by \code{drill_connection()}
#' @param query query to run
#' @param uplift automatically run \code{drill_uplift()} on the result?
#' @param .progress if \code{TRUE} then ask \code{httr::PSOT} to display a progress bar
#' @param uplift automatically run \code{drill_uplift()} on the result? (default: \code{TRUE})
#' @param .progress if \code{TRUE} (default if in an interactive session) then ask
#'                  \code{httr::POST} to display a progress bar
#' @references \href{https://drill.apache.org/docs/}{Drill documentation}
#' @export
#' @examples \dontrun{
#' drill_con() %>% drill_query("SELECT * FROM cp.`employee.json` limit 5")
#' drill_con() %>%
#'   drill_query("SELECT * FROM cp.`employee.json` limit 5")
#' }
drill_query <- function(drill_con, query, uplift=TRUE, .progress=FALSE) {
drill_query <- function(drill_con, query, uplift=TRUE, .progress=interactive()) {

  drill_server <- make_server(drill_con)



@@ 32,8 34,7 @@ drill_query <- function(drill_con, query, uplift=TRUE, .progress=FALSE) {
    message(sprintf("Query ==> %s\n%s\n", gsub("[\r\n]", " ", query), out$errorMessage))
    invisible(out)
  } else {
    if (uplift) out <- drill_uplift(out)
    out
    if (uplift) drill_uplift(out)
  }

}

M README.md => README.md +2 -12
@@ 67,15 67,12 @@ packageVersion("sergeant")
dc <- drill_connection() 

drill_active(dc)
#> http://localhost:8047
#> [1] TRUE

drill_version(dc)
#> http://localhost:8047
#> [1] "1.9.0"
#> NULL

drill_storage(dc)$name
#> http://localhost:8047
#> [1] "cp"    "dfs"   "hbase" "hive"  "kudu"  "mongo" "s3"
```



@@ 83,7 80,6 @@ Working with the built-in JSON data sets:

``` r
drill_query(dc, "SELECT * FROM cp.`employee.json` limit 100")
#> http://localhost:8047
#> Parsed with column specification:
#> cols(
#>   store_id = col_integer(),


@@ 120,7 116,6 @@ drill_query(dc, "SELECT * FROM cp.`employee.json` limit 100")
#> #   education_level <chr>, first_name <chr>, position_id <int>

drill_query(dc, "SELECT COUNT(gender) AS gender FROM cp.`employee.json` GROUP BY gender")
#> http://localhost:8047
#> Parsed with column specification:
#> cols(
#>   gender = col_integer()


@@ 132,7 127,6 @@ drill_query(dc, "SELECT COUNT(gender) AS gender FROM cp.`employee.json` GROUP BY
#> 2    554

drill_options(dc)
#> http://localhost:8047
#> # A tibble: 105 × 4
#>                                              name value   type    kind
#> *                                           <chr> <chr>  <chr>   <chr>


@@ 149,7 143,6 @@ drill_options(dc)
#> # ... with 95 more rows

drill_options(dc, "json")
#> http://localhost:8047
#> # A tibble: 7 × 4
#>                                                    name value   type    kind
#>                                                   <chr> <chr>  <chr>   <chr>


@@ 167,7 160,6 @@ Working with parquet files

``` r
drill_query(dc, "SELECT * FROM dfs.`/usr/local/drill/sample-data/nation.parquet` LIMIT 5")
#> http://localhost:8047
#> Parsed with column specification:
#> cols(
#>   N_COMMENT = col_character(),


@@ 189,7 181,6 @@ Including multiple parquet files in different directories (note the wildcard sup

``` r
drill_query(dc, "SELECT * FROM dfs.`/usr/local/drill/sample-data/nations*/nations*.parquet` LIMIT 5")
#> http://localhost:8047
#> Parsed with column specification:
#> cols(
#>   N_COMMENT = col_character(),


@@ 226,7 217,6 @@ select columns[2] as city, columns[4] as lon, columns[3] as lat
                )
            )
")
#> http://localhost:8047
#> Parsed with column specification:
#> cols(
#>   city = col_character(),


@@ 252,7 242,7 @@ library(sergeant)
library(testthat)

date()
#> [1] "Mon Dec  5 10:12:22 2016"
#> [1] "Mon Dec  5 10:27:10 2016"

test_dir("tests/")
#> testthat results ========================================================================================================

M man/drill_query.Rd => man/drill_query.Rd +6 -4
@@ 4,23 4,25 @@
\alias{drill_query}
\title{Submit a query and return results}
\usage{
drill_query(drill_con, query, uplift = TRUE, .progress = FALSE)
drill_query(drill_con, query, uplift = TRUE, .progress = interactive())
}
\arguments{
\item{drill_con}{drill server connection object setup by \code{drill_connection()}}

\item{query}{query to run}

\item{uplift}{automatically run \code{drill_uplift()} on the result?}
\item{uplift}{automatically run \code{drill_uplift()} on the result? (default: \code{TRUE})}

\item{.progress}{if \code{TRUE} then ask \code{httr::PSOT} to display a progress bar}
\item{.progress}{if \code{TRUE} (default if in an interactive session) then ask
\code{httr::POST} to display a progress bar}
}
\description{
Submit a query and return results
}
\examples{
\dontrun{
drill_con() \%>\% drill_query("SELECT * FROM cp.`employee.json` limit 5")
drill_con() \%>\%
  drill_query("SELECT * FROM cp.`employee.json` limit 5")
}
}
\references{