Skip to content

Commit 275deb4

Browse files
cafreemanDavies Liu
cafreeman
authored and
Davies Liu
committed
Update NAMESPACE and tests
Updated `NAMESPACE`, `DESCRIPTION`, and unit tests for new schema functions. Deleted `SQLTypes.R` since everything has been moved to `schema.R`.
1 parent 1a3b63d commit 275deb4

File tree

4 files changed

+26
-85
lines changed

4 files changed

+26
-85
lines changed

R/pkg/DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ License: Apache License (== 2.0)
1717
Collate:
1818
'generics.R'
1919
'jobj.R'
20-
'SQLTypes.R'
2120
'RDD.R'
2221
'pairRDD.R'
2322
'column.R'
2423
'group.R'
24+
'schema.R'
2525
'DataFrame.R'
2626
'SQLContext.R'
2727
'broadcast.R'

R/pkg/NAMESPACE

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,21 @@ export("cacheTable",
175175
"jsonRDD",
176176
"loadDF",
177177
"parquetFile",
178-
"buildSchema",
179-
"field",
180178
"sql",
181179
"table",
182180
"tableNames",
183181
"tables",
184182
"toDF",
185183
"uncacheTable")
186184

187-
export("print.structType",
185+
export("sparkRSQL.init",
186+
"sparkRHive.init")
187+
188+
export("structField",
189+
"structField.jobj",
190+
"structField.character",
188191
"print.structField",
189-
"print.struct",
190-
"print.field")
192+
"structType",
193+
"structType.jobj",
194+
"structType.structField",
195+
"print.structField")

R/pkg/R/SQLTypes.R

Lines changed: 0 additions & 64 deletions
This file was deleted.

R/pkg/inst/tests/test_sparkSQL.R

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,25 @@ test_that("infer types", {
4444
expect_equal(infer_type(list(1L, 2L)),
4545
list(type = 'array', elementType = "integer", containsNull = TRUE))
4646
expect_equal(infer_type(list(a = 1L, b = "2")),
47-
buildSchema(field(name = "a", type = "integer", nullable = TRUE),
48-
field(name = "b", type = "string", nullable = TRUE)))
47+
structType(structField(x = "a", type = "integer", nullable = TRUE),
48+
structField(x = "b", type = "string", nullable = TRUE)))
4949
e <- new.env()
5050
assign("a", 1L, envir = e)
5151
expect_equal(infer_type(e),
5252
list(type = "map", keyType = "string", valueType = "integer",
5353
valueContainsNull = TRUE))
5454
})
5555

56-
test_that("buildSchema and field", {
57-
testField <- field("a", "string")
58-
expect_true(inherits(testField, "field"))
59-
expect_true(testField$name == "a")
60-
expect_true(testField$nullable)
56+
test_that("structType and structField", {
57+
testField <- structField("a", "string")
58+
expect_true(inherits(testField, "structField"))
59+
expect_true(testField$name() == "a")
60+
expect_true(testField$nullable())
6161

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

6868
test_that("create DataFrame from RDD", {
@@ -77,8 +77,8 @@ test_that("create DataFrame from RDD", {
7777
expect_true(inherits(df, "DataFrame"))
7878
expect_equal(columns(df), c("_1", "_2"))
7979

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

107-
schema <- buildSchema(field(name = "a", type = "integer", nullable = TRUE),
108-
field(name = "b", type = "string", nullable = TRUE))
107+
schema <- structType(structField(x = "a", type = "integer", nullable = TRUE),
108+
structField(x = "b", type = "string", nullable = TRUE))
109109
df <- toDF(rdd, schema)
110110
expect_true(inherits(df, "DataFrame"))
111111
expect_equal(columns(df), c("a", "b"))

0 commit comments

Comments
 (0)