Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix R CMD check warnings #1

Merged
merged 1 commit into from
Aug 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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