Skip to content

Commit 39d3d6c

Browse files
dilipbiswalFelix Cheung
authored andcommitted
[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 <[email protected]> Closes apache#22274 from dilipbiswal/r-sql-test-fix2.
1 parent 64bbd13 commit 39d3d6c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

R/pkg/tests/fulltests/test_sparkSQL.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1870,9 +1870,9 @@ test_that("date functions on a DataFrame", {
18701870
expect_equal(collect(select(df2, minute(df2$b)))[, 1], c(34, 24))
18711871
expect_equal(collect(select(df2, second(df2$b)))[, 1], c(0, 34))
18721872
expect_equal(collect(select(df2, from_utc_timestamp(df2$b, "JST")))[, 1],
1873-
c(as.POSIXlt("2012-12-13 21:34:00 UTC"), as.POSIXlt("2014-12-15 10:24:34 UTC")))
1873+
c(as.POSIXct("2012-12-13 21:34:00 UTC"), as.POSIXct("2014-12-15 10:24:34 UTC")))
18741874
expect_equal(collect(select(df2, to_utc_timestamp(df2$b, "JST")))[, 1],
1875-
c(as.POSIXlt("2012-12-13 03:34:00 UTC"), as.POSIXlt("2014-12-14 16:24:34 UTC")))
1875+
c(as.POSIXct("2012-12-13 03:34:00 UTC"), as.POSIXct("2014-12-14 16:24:34 UTC")))
18761876
expect_gt(collect(select(df2, unix_timestamp()))[1, 1], 0)
18771877
expect_gt(collect(select(df2, unix_timestamp(df2$b)))[1, 1], 0)
18781878
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", {
36523652
expect_equal(currentDatabase(), "default")
36533653
expect_error(setCurrentDatabase("default"), NA)
36543654
expect_error(setCurrentDatabase("zxwtyswklpf"),
3655-
"Error in setCurrentDatabase : analysis error - Database 'zxwtyswklpf' does not exist")
3655+
paste0("Error in setCurrentDatabase : analysis error - Database ",
3656+
"'zxwtyswklpf' does not exist"))
36563657
dbs <- collect(listDatabases())
36573658
expect_equal(names(dbs), c("name", "description", "locationUri"))
36583659
expect_equal(which(dbs[, 1] == "default"), 1)

0 commit comments

Comments
 (0)