Skip to content

Commit

Permalink
Merge pull request #1 from JesseKolb/fix-warning
Browse files Browse the repository at this point in the history
fix R CMD check warnings
  • Loading branch information
JesseKolb authored Aug 5, 2019
2 parents 7e205cf + bc023ce commit 975a31a
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 22 deletions.
4 changes: 2 additions & 2 deletions R/filter.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ selector <- function(...) {
#' @param x character vector of possible values to match
#' @method %=% druid.dimension
#' @export
`%=%.druid.dimension` <- function(dimension, x) {
`%=%.druid.dimension` <- function(dimension, pattern) {
stopifnot(is(dimension, "druid.dimension"))
filters <- plyr::llply(x, function(v) {
filters <- plyr::llply(pattern, function(v) {
druid.filter.selector(dimension = as.character(dimension), value = as.character(v))
})
do.call("druid.filter.or", filters)
Expand Down
8 changes: 4 additions & 4 deletions R/query.R
Original file line number Diff line number Diff line change
Expand Up @@ -351,19 +351,19 @@ druid.query.topN <- function(url = druid.url(), dataSource, intervals, aggregati
# check whether aggregations is a list or a single aggregation object
if(is(aggregations, "druid.aggregator")) aggregations <- list(aggregations)

query.js <- RDruid:::json(list(intervals = as.list(toISO(intervals)),
aggregations = RDruid:::renameagg(aggregations),
query.js <- json(list(intervals = as.list(toISO(intervals)),
aggregations = renameagg(aggregations),
dataSource = dataSource,
filter = filter,
granularity = granularity,
postAggregations = RDruid:::renameagg(postAggregations),
postAggregations = renameagg(postAggregations),
context = context,
queryType = "topN", dimension = dimension,
metric = metric, threshold = n), pretty=verbose)
if(verbose) {
cat(query.js)
}
result.l <- RDruid:::query(query.js, url, verbose, ...)
result.l <- query(query.js, url, verbose, ...)

if(rawData) {
return (result.l)
Expand Down
4 changes: 2 additions & 2 deletions R/utilities-query.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ query <- function(jsonstr, url, verbose = F, benchmark = F, ...){
message(jsonstr)
}
res <- httr::POST(
url, content_type_json(),
url, httr::content_type_json(),
body = jsonstr,
verbose = verbose
)
}

if(httr::status_code(res) >= 300 && !is.na(pmatch("application/json", headers(res)$`content-type`))) {
if(httr::status_code(res) >= 300 && !is.na(pmatch("application/json", httr::headers(res)$`content-type`))) {
err <- fromJSON(
httr::content(res, as = "text", type = "application/json", encoding = "UTF-8"),
simplifyVector = TRUE
Expand Down
2 changes: 1 addition & 1 deletion R/utilities-time.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ toISO.character <- function(x) {
#' @method toISO numeric
#' @export
toISO.numeric <- function(x) {
toISO(as.POSIXct(x, origin=origin))
toISO(as.POSIXct(x, lubridate::origin))
}

#' Convert a POSIX* object to its ISO 8601 string representation
Expand Down
2 changes: 1 addition & 1 deletion man/grapes-equals-grapes-.druid.dimension.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions tests/test-all.R → tests/testthat.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
# limitations under the License.
#


library(lubridate)
library(RDruid)
library(testthat)
library(RDruid)

test_package("RDruid")
test_check("RDruid")
3 changes: 2 additions & 1 deletion inst/tests/test-query.R → tests/testthat/test-query.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
#

test_that("groupBy handles missing columns", {
res <- fromJSON('[{"timestamp":"2013-07-01T00:00:00.000Z","version":"v1","event":{"count":10,"col1":"No","col2":"Yes"}},{"timestamp":"2013-07-01T00:00:00.000Z","version":"v1","event":{"count":20,"col1":"Yes"}}]')
res <- fromJSON('[{"timestamp":"2013-07-01T00:00:00.000Z","version":"v1","event":{"count":10,"col1":"No","col2":"Yes"}},{"timestamp":"2013-07-01T00:00:00.000Z","version":"v1","event":{"count":20,"col1":"Yes"}}]',
simplifyVector = F)
df <- RDruid:::druid.groupBytodf(res)
expected <- data.frame(
timestamp = fromISO(c("2013-07-01T00:00:00.000Z", "2013-07-01T00:00:00.000Z")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
test_that("fromISO parses milliseconds", {
t <- fromISO("2011-05-01T02:03:00.123")
expect_equal(second(t), 0.123, tolerance = 0.0001, scale=1)

t <- fromISO("2011-05-01T02:03:00.123+05:30")
expect_equal(second(t), 0.123, tolerance = 0.0001, scale=1)

Expand All @@ -31,21 +31,21 @@ test_that("fromISO parses TZ offset", {

t <- fromISO("2012-04-01T00:00:00")
expect_equal(t, t_exp, tolerance=0.0001, scale=1)

t <- fromISO("2012-04-01T00:00:00+00:00")
expect_equal(t, t_exp, tolerance=0.0001, scale=1)

t <- fromISO("2012-04-01T05:00:00+05:00")
expect_equal(t, t_exp, tolerance=0.0001, scale=1)

t <- fromISO("2012-04-01T05:30:00+05:30")
expect_equal(t, t_exp, tolerance=0.0001, scale=1)

t <- fromISO("2012-03-31T19:00:00-05:00")
expect_equal(t, t_exp, tolerance=0.0001, scale=1)

t <- fromISO("2012-03-31T18:30:00-05:30")
expect_equal(t, t_exp, tolerance=0.0001, scale=1)
expect_equal(t, t_exp, tolerance=0.0001, scale=1)
})

test_that("fromISO properly works in vector format", {
Expand All @@ -63,9 +63,9 @@ test_that("toISO prints milliseconds", {
test_that("toISO prints interval", {
t <- as.POSIXct("2012-01-01", tz="UTC")
t1 <- c(t, t + dminutes(30), t + dhours(14))
t2 <- c(t + dhours(2), t + dhours(3), t + ddays(2))
t2 <- c(t + dhours(2), t + dhours(3), t + ddays(2))
i <- interval(t1, t2)

expect_identical(toISO(i), c("2012-01-01T00:00:00.000+00:00/2012-01-01T02:00:00.000+00:00",
"2012-01-01T00:30:00.000+00:00/2012-01-01T03:00:00.000+00:00",
"2012-01-01T14:00:00.000+00:00/2012-01-03T00:00:00.000+00:00"))
Expand Down

0 comments on commit 975a31a

Please sign in to comment.