@@ -44,25 +44,25 @@ test_that("infer types", {
44
44
expect_equal(infer_type(list (1L , 2L )),
45
45
list (type = ' array' , elementType = " integer" , containsNull = TRUE ))
46
46
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 )))
49
49
e <- new.env()
50
50
assign(" a" , 1L , envir = e )
51
51
expect_equal(infer_type(e ),
52
52
list (type = " map" , keyType = " string" , valueType = " integer" ,
53
53
valueContainsNull = TRUE ))
54
54
})
55
55
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() )
61
61
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 " )
66
66
})
67
67
68
68
test_that(" create DataFrame from RDD" , {
@@ -77,8 +77,8 @@ test_that("create DataFrame from RDD", {
77
77
expect_true(inherits(df , " DataFrame" ))
78
78
expect_equal(columns(df ), c(" _1" , " _2" ))
79
79
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 ))
82
82
df <- createDataFrame(sqlCtx , rdd , schema )
83
83
expect_true(inherits(df , " DataFrame" ))
84
84
expect_equal(columns(df ), c(" a" , " b" ))
@@ -104,8 +104,8 @@ test_that("toDF", {
104
104
expect_true(inherits(df , " DataFrame" ))
105
105
expect_equal(columns(df ), c(" _1" , " _2" ))
106
106
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 ))
109
109
df <- toDF(rdd , schema )
110
110
expect_true(inherits(df , " DataFrame" ))
111
111
expect_equal(columns(df ), c(" a" , " b" ))
0 commit comments