Skip to content

Commit

Permalink
Update NAMESPACE and tests
Browse files Browse the repository at this point in the history
Updated `NAMESPACE`, `DESCRIPTION`, and unit tests for new schema functions.

Deleted `SQLTypes.R` since everything has been moved to `schema.R`.
  • Loading branch information
cafreeman authored and Davies Liu committed Apr 14, 2015
1 parent 1a3b63d commit 275deb4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 85 deletions.
2 changes: 1 addition & 1 deletion R/pkg/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ License: Apache License (== 2.0)
Collate:
'generics.R'
'jobj.R'
'SQLTypes.R'
'RDD.R'
'pairRDD.R'
'column.R'
'group.R'
'schema.R'
'DataFrame.R'
'SQLContext.R'
'broadcast.R'
Expand Down
15 changes: 10 additions & 5 deletions R/pkg/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,21 @@ export("cacheTable",
"jsonRDD",
"loadDF",
"parquetFile",
"buildSchema",
"field",
"sql",
"table",
"tableNames",
"tables",
"toDF",
"uncacheTable")

export("print.structType",
export("sparkRSQL.init",
"sparkRHive.init")

export("structField",
"structField.jobj",
"structField.character",
"print.structField",
"print.struct",
"print.field")
"structType",
"structType.jobj",
"structType.structField",
"print.structField")
64 changes: 0 additions & 64 deletions R/pkg/R/SQLTypes.R

This file was deleted.

30 changes: 15 additions & 15 deletions R/pkg/inst/tests/test_sparkSQL.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,25 @@ test_that("infer types", {
expect_equal(infer_type(list(1L, 2L)),
list(type = 'array', elementType = "integer", containsNull = TRUE))
expect_equal(infer_type(list(a = 1L, b = "2")),
buildSchema(field(name = "a", type = "integer", nullable = TRUE),
field(name = "b", type = "string", nullable = TRUE)))
structType(structField(x = "a", type = "integer", nullable = TRUE),
structField(x = "b", type = "string", nullable = TRUE)))
e <- new.env()
assign("a", 1L, envir = e)
expect_equal(infer_type(e),
list(type = "map", keyType = "string", valueType = "integer",
valueContainsNull = TRUE))
})

test_that("buildSchema and field", {
testField <- field("a", "string")
expect_true(inherits(testField, "field"))
expect_true(testField$name == "a")
expect_true(testField$nullable)
test_that("structType and structField", {
testField <- structField("a", "string")
expect_true(inherits(testField, "structField"))
expect_true(testField$name() == "a")
expect_true(testField$nullable())

testSchema <- buildSchema(testField, field("b", "integer"))
expect_true(inherits(testSchema, "struct"))
expect_true(inherits(testSchema[[2]], "field"))
expect_true(testSchema[[1]]$type == "string")
testSchema <- structType(testField, structField("b", "integer"))
expect_true(inherits(testSchema, "structType"))
expect_true(inherits(testSchema$fields()[[2]], "structField"))
expect_true(testSchema$fields()[[1]]$dataType.toString() == "StringType")
})

test_that("create DataFrame from RDD", {
Expand All @@ -77,8 +77,8 @@ test_that("create DataFrame from RDD", {
expect_true(inherits(df, "DataFrame"))
expect_equal(columns(df), c("_1", "_2"))

schema <- buildSchema(field(name = "a", type = "integer", nullable = TRUE),
field(name = "b", type = "string", nullable = TRUE))
schema <- structType(structField(x = "a", type = "integer", nullable = TRUE),
structField(x = "b", type = "string", nullable = TRUE))
df <- createDataFrame(sqlCtx, rdd, schema)
expect_true(inherits(df, "DataFrame"))
expect_equal(columns(df), c("a", "b"))
Expand All @@ -104,8 +104,8 @@ test_that("toDF", {
expect_true(inherits(df, "DataFrame"))
expect_equal(columns(df), c("_1", "_2"))

schema <- buildSchema(field(name = "a", type = "integer", nullable = TRUE),
field(name = "b", type = "string", nullable = TRUE))
schema <- structType(structField(x = "a", type = "integer", nullable = TRUE),
structField(x = "b", type = "string", nullable = TRUE))
df <- toDF(rdd, schema)
expect_true(inherits(df, "DataFrame"))
expect_equal(columns(df), c("a", "b"))
Expand Down

0 comments on commit 275deb4

Please sign in to comment.