diff --git a/R/pkg/tests/fulltests/test_sparkSQL.R b/R/pkg/tests/fulltests/test_sparkSQL.R index 0b88e47f4dfef..62e3aaa497ef7 100644 --- a/R/pkg/tests/fulltests/test_sparkSQL.R +++ b/R/pkg/tests/fulltests/test_sparkSQL.R @@ -1267,6 +1267,11 @@ test_that("column functions", { expect_equal(collect(df2)[[3, 1]], FALSE) expect_equal(collect(df2)[[3, 2]], TRUE) + # Test that input_file_name() + actual_names <- collect(distinct(select(df, input_file_name()))) + expect_equal(length(actual_names), 1) + expect_equal(basename(actual_names[1, 1]), basename(jsonPath)) + df3 <- select(df, between(df$name, c("Apache", "Spark"))) expect_equal(collect(df3)[[1, 1]], TRUE) expect_equal(collect(df3)[[2, 1]], FALSE) diff --git a/R/pkg/tests/fulltests/test_utils.R b/R/pkg/tests/fulltests/test_utils.R index c87524842876e..2db91f6cc6f95 100644 --- a/R/pkg/tests/fulltests/test_utils.R +++ b/R/pkg/tests/fulltests/test_utils.R @@ -64,7 +64,12 @@ test_that("cleanClosure on R functions", { actual <- get("y", envir = env, inherits = FALSE) expect_equal(actual, y) actual <- get("g", envir = env, inherits = FALSE) - expect_equal(actual, g) + if (as.numeric(R.Version()$major) >= 4 && !startsWith(R.Version()$minor, "0")) { + # 4.1+ checks environment in the function + expect_true(all.equal(actual, g, check.environment = FALSE)) + } else { + expect_equal(actual, g) + } # Test for nested enclosures and package variables. env2 <- new.env() @@ -77,7 +82,12 @@ test_that("cleanClosure on R functions", { actual <- get("y", envir = env, inherits = FALSE) expect_equal(actual, y) actual <- get("g", envir = env, inherits = FALSE) - expect_equal(actual, g) + if (as.numeric(R.Version()$major) >= 4 && !startsWith(R.Version()$minor, "0")) { + # 4.1+ checks environment in the function + expect_true(all.equal(actual, g, check.environment = FALSE)) + } else { + expect_equal(actual, g) + } base <- c(1, 2, 3) l <- list(field = matrix(1))