Skip to content

Commit

Permalink
[SPARK-24393][SQL] added R tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Nihal Harish authored and Nihal Harish committed Jun 7, 2018
1 parent 663fa47 commit f240fdf
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions R/pkg/tests/fulltests/test_sparkSQL.R
Expand Up @@ -1444,10 +1444,22 @@ test_that("column functions", {
trunc(c, "month") + trunc(c, "mon") + trunc(c, "mm")
c24 <- date_trunc("hour", c) + date_trunc("minute", c) + date_trunc("week", c) +
date_trunc("quarter", c) + current_date() + current_timestamp()
c25 <- isinf(c) + isInf(c)

# Test if base::is.nan() is exposed
expect_equal(is.nan(c("a", "b")), c(FALSE, FALSE))

# Test isInf and isinf on column values
l <- data.frame(x = c(1L, Inf, 3L))
df <- createDataFrame(l)
expect_equal(collect(select(df, isinf(df$x)))[1,1], FALSE)
expect_equal(collect(select(df, isinf(df$x)))[2,1], TRUE)
expect_equal(collect(select(df, isinf(df$x)))[3,1], FALSE)

expect_equal(collect(select(df, isInf(df$x)))[1,1], FALSE)
expect_equal(collect(select(df, isInf(df$x)))[2,1], TRUE)
expect_equal(collect(select(df, isInf(df$x)))[3,1], FALSE)

# Test if base::rank() is exposed
expect_equal(class(rank())[[1]], "Column")
expect_equal(rank(1:3), as.numeric(c(1:3)))
Expand Down

0 comments on commit f240fdf

Please sign in to comment.