From 39d3d6cc965bd09b1719d245e672b013b8cee6f7 Mon Sep 17 00:00:00 2001 From: Dilip Biswal Date: Mon, 3 Sep 2018 00:38:08 -0700 Subject: [PATCH] [SPARK-25167][SPARKR][TEST][MINOR] Minor fixes for R sql tests (timestamp comparison) ## What changes were proposed in this pull request? The "date function on DataFrame" test fails consistently on my laptop. In this PR i am fixing it by changing the way we compare the two timestamp values. With this change i am able to run the tests clean. ## How was this patch tested? Fixed the failing test. Author: Dilip Biswal Closes #22274 from dilipbiswal/r-sql-test-fix2. --- R/pkg/tests/fulltests/test_sparkSQL.R | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/R/pkg/tests/fulltests/test_sparkSQL.R b/R/pkg/tests/fulltests/test_sparkSQL.R index 17e4a970425af..5c07a028f8b0e 100644 --- a/R/pkg/tests/fulltests/test_sparkSQL.R +++ b/R/pkg/tests/fulltests/test_sparkSQL.R @@ -1870,9 +1870,9 @@ test_that("date functions on a DataFrame", { expect_equal(collect(select(df2, minute(df2$b)))[, 1], c(34, 24)) expect_equal(collect(select(df2, second(df2$b)))[, 1], c(0, 34)) expect_equal(collect(select(df2, from_utc_timestamp(df2$b, "JST")))[, 1], - c(as.POSIXlt("2012-12-13 21:34:00 UTC"), as.POSIXlt("2014-12-15 10:24:34 UTC"))) + c(as.POSIXct("2012-12-13 21:34:00 UTC"), as.POSIXct("2014-12-15 10:24:34 UTC"))) expect_equal(collect(select(df2, to_utc_timestamp(df2$b, "JST")))[, 1], - c(as.POSIXlt("2012-12-13 03:34:00 UTC"), as.POSIXlt("2014-12-14 16:24:34 UTC"))) + c(as.POSIXct("2012-12-13 03:34:00 UTC"), as.POSIXct("2014-12-14 16:24:34 UTC"))) expect_gt(collect(select(df2, unix_timestamp()))[1, 1], 0) expect_gt(collect(select(df2, unix_timestamp(df2$b)))[1, 1], 0) expect_gt(collect(select(df2, unix_timestamp(lit("2015-01-01"), "yyyy-MM-dd")))[1, 1], 0) @@ -3652,7 +3652,8 @@ test_that("catalog APIs, currentDatabase, setCurrentDatabase, listDatabases", { expect_equal(currentDatabase(), "default") expect_error(setCurrentDatabase("default"), NA) expect_error(setCurrentDatabase("zxwtyswklpf"), - "Error in setCurrentDatabase : analysis error - Database 'zxwtyswklpf' does not exist") + paste0("Error in setCurrentDatabase : analysis error - Database ", + "'zxwtyswklpf' does not exist")) dbs <- collect(listDatabases()) expect_equal(names(dbs), c("name", "description", "locationUri")) expect_equal(which(dbs[, 1] == "default"), 1)