@@ -1414,9 +1414,10 @@ setMethod("where",
14141414# ' @param x A Spark DataFrame
14151415# ' @param y A Spark DataFrame
14161416# ' @param joinExpr (Optional) The expression used to perform the join. joinExpr must be a
1417- # ' Column expression. If joinExpr is omitted, join() wil perform a Cartesian join
1417+ # ' Column expression. If joinExpr is omitted, join() will perform a Cartesian join
14181418# ' @param joinType The type of join to perform. The following join types are available:
1419- # ' 'inner', 'outer', 'left_outer', 'right_outer', 'semijoin'. The default joinType is "inner".
1419+ # ' 'inner', 'outer', 'full', 'fullouter', leftouter', 'left_outer', 'left',
1420+ # ' 'right_outer', 'rightouter', 'right', and 'leftsemi'. The default joinType is "inner".
14201421# ' @return A DataFrame containing the result of the join operation.
14211422# ' @rdname join
14221423# ' @name join
@@ -1441,11 +1442,15 @@ setMethod("join",
14411442 if (is.null(joinType )) {
14421443 sdf <- callJMethod(x @ sdf , " join" , y @ sdf , joinExpr @ jc )
14431444 } else {
1444- if (joinType %in% c(" inner" , " outer" , " left_outer" , " right_outer" , " semijoin" )) {
1445+ if (joinType %in% c(" inner" , " outer" , " full" , " fullouter" ,
1446+ " leftouter" , " left_outer" , " left" ,
1447+ " rightouter" , " right_outer" , " right" , " leftsemi" )) {
1448+ joinType <- gsub(" _" , " " , joinType )
14451449 sdf <- callJMethod(x @ sdf , " join" , y @ sdf , joinExpr @ jc , joinType )
14461450 } else {
14471451 stop(" joinType must be one of the following types: " ,
1448- " 'inner', 'outer', 'left_outer', 'right_outer', 'semijoin'" )
1452+ " 'inner', 'outer', 'full', 'fullouter', 'leftouter', 'left_outer', 'left',
1453+ 'rightouter', 'right_outer', 'right', 'leftsemi'" )
14491454 }
14501455 }
14511456 }
@@ -1826,17 +1831,15 @@ setMethod("fillna",
18261831 if (length(colNames ) == 0 || ! all(colNames != " " )) {
18271832 stop(" value should be an a named list with each name being a column name." )
18281833 }
1829-
1830- # Convert to the named list to an environment to be passed to JVM
1831- valueMap <- new.env()
1832- for (col in colNames ) {
1833- # Check each item in the named list is of valid type
1834- v <- value [[col ]]
1834+ # Check each item in the named list is of valid type
1835+ lapply(value , function (v ) {
18351836 if (! (class(v ) %in% c(" integer" , " numeric" , " character" ))) {
18361837 stop(" Each item in value should be an integer, numeric or charactor." )
18371838 }
1838- valueMap [[col ]] <- v
1839- }
1839+ })
1840+
1841+ # Convert to the named list to an environment to be passed to JVM
1842+ valueMap <- convertNamedListToEnv(value )
18401843
18411844 # When value is a named list, caller is expected not to pass in cols
18421845 if (! is.null(cols )) {
@@ -1881,3 +1884,33 @@ setMethod("as.data.frame",
18811884 }
18821885 collect(x )
18831886 })
1887+
1888+ # ' The specified DataFrame is attached to the R search path. This means that
1889+ # ' the DataFrame is searched by R when evaluating a variable, so columns in
1890+ # ' the DataFrame can be accessed by simply giving their names.
1891+ # '
1892+ # ' @rdname attach
1893+ # ' @title Attach DataFrame to R search path
1894+ # ' @param what (DataFrame) The DataFrame to attach
1895+ # ' @param pos (integer) Specify position in search() where to attach.
1896+ # ' @param name (character) Name to use for the attached DataFrame. Names
1897+ # ' starting with package: are reserved for library.
1898+ # ' @param warn.conflicts (logical) If TRUE, warnings are printed about conflicts
1899+ # ' from attaching the database, unless that DataFrame contains an object
1900+ # ' @examples
1901+ # ' \dontrun{
1902+ # ' attach(irisDf)
1903+ # ' summary(Sepal_Width)
1904+ # ' }
1905+ # ' @seealso \link{detach}
1906+ setMethod ("attach ",
1907+ signature(what = " DataFrame" ),
1908+ function (what , pos = 2 , name = deparse(substitute(what )), warn.conflicts = TRUE ) {
1909+ cols <- columns(what )
1910+ stopifnot(length(cols ) > 0 )
1911+ newEnv <- new.env()
1912+ for (i in 1 : length(cols )) {
1913+ assign(x = cols [i ], value = what [, cols [i ]], envir = newEnv )
1914+ }
1915+ attach(newEnv , pos = pos , name = name , warn.conflicts = warn.conflicts )
1916+ })
0 commit comments