File tree Expand file tree Collapse file tree 2 files changed +11
-11
lines changed Expand file tree Collapse file tree 2 files changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -2165,13 +2165,13 @@ setMethod("coltypes",
21652165 function (x ) {
21662166 # Get the data types of the DataFrame by invoking dtypes() function
21672167 types <- sapply(dtypes(x ), function (x ) {x [[2 ]]})
2168-
2168+
21692169 # Map Spark data types into R's data types using DATA_TYPES environment
21702170 rTypes <- sapply(types , USE.NAMES = F , FUN = function (x ) {
2171-
2171+
21722172 # Check for primitive types
21732173 type <- PRIMITIVE_TYPES [[x ]]
2174-
2174+
21752175 if (is.null(type )) {
21762176 # Check for complex types
21772177 for (t in names(COMPLEX_TYPES )) {
@@ -2180,19 +2180,19 @@ setMethod("coltypes",
21802180 break
21812181 }
21822182 }
2183-
2183+
21842184 if (is.null(type )) {
21852185 stop(paste(" Unsupported data type: " , x ))
21862186 }
21872187 }
21882188 type
21892189 })
2190-
2190+
21912191 # Find which types don't have mapping to R
21922192 naIndices <- which(is.na(rTypes ))
2193-
2193+
21942194 # Assign the original scala data types to the unmatched ones
21952195 rTypes [naIndices ] <- types [naIndices ]
2196-
2196+
21972197 rTypes
21982198 })
Original file line number Diff line number Diff line change @@ -1506,19 +1506,19 @@ test_that("with() on a DataFrame", {
15061506
15071507test_that(" Method coltypes() to get R's data types of a DataFrame" , {
15081508 expect_equal(coltypes(irisDF ), c(rep(" numeric" , 4 ), " character" ))
1509-
1509+
15101510 data <- data.frame (c1 = c(1 ,2 ,3 ),
15111511 c2 = c(T ,F ,T ),
15121512 c3 = c(" 2015/01/01 10:00:00" , " 2015/01/02 10:00:00" , " 2015/01/03 10:00:00" ))
1513-
1513+
15141514 schema <- structType(structField(" c1" , " byte" ),
15151515 structField(" c3" , " boolean" ),
15161516 structField(" c4" , " timestamp" ))
1517-
1517+
15181518 # Test primitive types
15191519 DF <- createDataFrame(sqlContext , data , schema )
15201520 expect_equal(coltypes(DF ), c(" integer" , " logical" , " POSIXct" ))
1521-
1521+
15221522 # Test complex types
15231523 x <- createDataFrame(sqlContext , list (list (as.environment(
15241524 list (" a" = " b" , " c" = " d" , " e" = " f" )))))
You can’t perform that action at this time.
0 commit comments