aboutsummaryrefslogtreecommitdiff
path: root/R/pkg/inst/tests/testthat/test_sparkSQL.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/pkg/inst/tests/testthat/test_sparkSQL.R')
-rw-r--r--R/pkg/inst/tests/testthat/test_sparkSQL.R11
1 files changed, 11 insertions, 0 deletions
diff --git a/R/pkg/inst/tests/testthat/test_sparkSQL.R b/R/pkg/inst/tests/testthat/test_sparkSQL.R
index 236bae6bde..cad5766812 100644
--- a/R/pkg/inst/tests/testthat/test_sparkSQL.R
+++ b/R/pkg/inst/tests/testthat/test_sparkSQL.R
@@ -691,6 +691,17 @@ test_that("names() colnames() set the column names", {
colnames(df) <- c("col3", "col4")
expect_equal(names(df)[1], "col3")
+ expect_error(colnames(df) <- c("sepal.length", "sepal_width"),
+ "Colum names cannot contain the '.' symbol.")
+ expect_error(colnames(df) <- c(1, 2), "Invalid column names.")
+ expect_error(colnames(df) <- c("a"),
+ "Column names must have the same length as the number of columns in the dataset.")
+ expect_error(colnames(df) <- c("1", NA), "Column names cannot be NA.")
+
+ # Note: if this test is broken, remove check for "." character on colnames<- method
+ irisDF <- suppressWarnings(createDataFrame(sqlContext, iris))
+ expect_equal(names(irisDF)[1], "Sepal_Length")
+
# Test base::colnames base::names
m2 <- cbind(1, 1:4)
expect_equal(colnames(m2, do.NULL = FALSE), c("col1", "col2"))