@@ -1222,16 +1222,16 @@ test_that("column functions", {
12221222 # Test struct()
12231223 df <- createDataFrame(list (list (1L , 2L , 3L ), list (4L , 5L , 6L )),
12241224 schema = c(" a" , " b" , " c" ))
1225- result <- collect(select(df , struct(" a" , " c" )))
1225+ result <- collect(select(df , alias( struct(" a" , " c" ), " d " )))
12261226 expected <- data.frame (row.names = 1 : 2 )
1227- expected $ " struct(a, c) " <- list (listToStruct(list (a = 1L , c = 3L )),
1228- listToStruct(list (a = 4L , c = 6L )))
1227+ expected $ " d " <- list (listToStruct(list (a = 1L , c = 3L )),
1228+ listToStruct(list (a = 4L , c = 6L )))
12291229 expect_equal(result , expected )
12301230
1231- result <- collect(select(df , struct(df $ a , df $ b )))
1231+ result <- collect(select(df , alias( struct(df $ a , df $ b ), " d " )))
12321232 expected <- data.frame (row.names = 1 : 2 )
1233- expected $ " struct(a, b) " <- list (listToStruct(list (a = 1L , b = 2L )),
1234- listToStruct(list (a = 4L , b = 5L )))
1233+ expected $ " d " <- list (listToStruct(list (a = 1L , b = 2L )),
1234+ listToStruct(list (a = 4L , b = 5L )))
12351235 expect_equal(result , expected )
12361236
12371237 # Test encode(), decode()
@@ -2659,7 +2659,15 @@ test_that("Call DataFrameWriter.save() API in Java without path and check argume
26592659 # It makes sure that we can omit path argument in write.df API and then it calls
26602660 # DataFrameWriter.save() without path.
26612661 expect_error(write.df(df , source = " csv" ),
2662- " Error in save : illegal argument - 'path' is not specified" )
2662+ " Error in save : illegal argument - Expected exactly one path to be specified" )
2663+ expect_error(write.json(df , jsonPath ),
2664+ " Error in json : analysis error - path file:.*already exists" )
2665+ expect_error(write.text(df , jsonPath ),
2666+ " Error in text : analysis error - path file:.*already exists" )
2667+ expect_error(write.orc(df , jsonPath ),
2668+ " Error in orc : analysis error - path file:.*already exists" )
2669+ expect_error(write.parquet(df , jsonPath ),
2670+ " Error in parquet : analysis error - path file:.*already exists" )
26632671
26642672 # Arguments checking in R side.
26652673 expect_error(write.df(df , " data.tmp" , source = c(1 , 2 )),
@@ -2679,13 +2687,21 @@ test_that("Call DataFrameWriter.load() API in Java without path and check argume
26792687 paste(" Error in loadDF : analysis error - Unable to infer schema for JSON at ." ,
26802688 " It must be specified manually" ))
26812689 expect_error(read.df(" arbitrary_path" ), " Error in loadDF : analysis error - Path does not exist" )
2690+ expect_error(read.json(" arbitrary_path" ), " Error in json : analysis error - Path does not exist" )
2691+ expect_error(read.text(" arbitrary_path" ), " Error in text : analysis error - Path does not exist" )
2692+ expect_error(read.orc(" arbitrary_path" ), " Error in orc : analysis error - Path does not exist" )
2693+ expect_error(read.parquet(" arbitrary_path" ),
2694+ " Error in parquet : analysis error - Path does not exist" )
26822695
26832696 # Arguments checking in R side.
26842697 expect_error(read.df(path = c(3 )),
26852698 " path should be charactor, NULL or omitted." )
26862699 expect_error(read.df(jsonPath , source = c(1 , 2 )),
26872700 paste(" source should be character, NULL or omitted. It is the datasource specified" ,
26882701 " in 'spark.sql.sources.default' configuration by default." ))
2702+
2703+ expect_warning(read.json(jsonPath , a = 1 , 2 , 3 , " a" ),
2704+ " Unnamed arguments ignored: 2, 3, a." )
26892705})
26902706
26912707unlink(parquetPath )
0 commit comments