Skip to content

Commit d555cf8

Browse files
committed
update from feedback, add tests
1 parent e399acd commit d555cf8

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

R/pkg/NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ exportMethods("arrange",
2828
"cache",
2929
"collect",
3030
"colnames",
31+
"colnames<-",
3132
"coltypes",
3233
"coltypes<-",
3334
"columns",
@@ -58,6 +59,7 @@ exportMethods("arrange",
5859
"mutate",
5960
"na.omit",
6061
"names",
62+
"names<-",
6163
"ncol",
6264
"nrow",
6365
"orderBy",

R/pkg/R/types.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ COMPLEX_TYPES <- list(
4343
DATA_TYPES <- as.environment(c(as.list(PRIMITIVE_TYPES), COMPLEX_TYPES))
4444

4545
# An environment for mapping R to Scala, names are R types and values are Scala types.
46-
rToSQLTypes <- new.env()
47-
rToSQLTypes[["integer"]] <- "integer" # in R, integer is 32bit
48-
rToSQLTypes[["numeric"]] <- "double" # in R, numeric == double which is 64bit
49-
rToSQLTypes[["double"]] <- "double"
50-
rToSQLTypes[["character"]] <- "string"
51-
rToSQLTypes[["logical"]] <- "boolean"
46+
rToSQLTypes <- as.environment(list(
47+
"integer" = "integer", # in R, integer is 32bit
48+
"numeric" = "double", # in R, numeric == double which is 64bit
49+
"double" = "double",
50+
"character" = "string",
51+
"logical" = "boolean"))

R/pkg/inst/tests/test_sparkSQL.R

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,11 +630,16 @@ test_that("names() colnames() set the column names", {
630630
colnames(df) <- c("col3", "col4")
631631
expect_equal(names(df)[1], "col3")
632632

633-
# Test base::colnames
633+
# Test base::colnames base::names
634634
m2 <- cbind(1, 1:4)
635635
expect_equal(colnames(m2, do.NULL = FALSE), c("col1", "col2"))
636636
colnames(m2) <- c("x","Y")
637637
expect_equal(colnames(m2), c("x", "Y"))
638+
639+
z <- list(a = 1, b = "c", c = 1:3)
640+
expect_equal(names(z)[3], "c")
641+
names(z)[3] <- "c2"
642+
expect_equal(names(z)[3], "c2")
638643
})
639644

640645
test_that("head() and first() return the correct data", {

0 commit comments

Comments
 (0)