Skip to content

Commit 2c22073

Browse files
author
cafreeman
committed
Merge branch 'branch-1.4' of github.com:apache/spark into branch-1.4
2 parents 0bea809 + 78b31a2 commit 2c22073

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

R/pkg/inst/tests/test_sparkSQL.R

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ library(testthat)
1919

2020
context("SparkSQL functions")
2121

22+
# Utility function for easily checking the values of a StructField
23+
checkStructField <- function(actual, expectedName, expectedType, expectedNullable) {
24+
expect_equal(class(actual), "structField")
25+
expect_equal(actual$name(), expectedName)
26+
expect_equal(actual$dataType.toString(), expectedType)
27+
expect_equal(actual$nullable(), expectedNullable)
28+
}
29+
2230
# Tests for SparkSQL functions in SparkR
2331

2432
sc <- sparkR.init()
@@ -52,9 +60,10 @@ test_that("infer types", {
5260
list(type = 'array', elementType = "integer", containsNull = TRUE))
5361
expect_equal(infer_type(list(1L, 2L)),
5462
list(type = 'array', elementType = "integer", containsNull = TRUE))
55-
expect_equal(infer_type(list(a = 1L, b = "2")),
56-
structType(structField(x = "a", type = "integer", nullable = TRUE),
57-
structField(x = "b", type = "string", nullable = TRUE)))
63+
testStruct <- infer_type(list(a = 1L, b = "2"))
64+
expect_true(class(testStruct) == "structType")
65+
checkStructField(testStruct$fields()[[1]], "a", "IntegerType", TRUE)
66+
checkStructField(testStruct$fields()[[2]], "b", "StringType", TRUE)
5867
e <- new.env()
5968
assign("a", 1L, envir = e)
6069
expect_equal(infer_type(e),

0 commit comments

Comments
 (0)