Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
221 changes: 128 additions & 93 deletions R/pkg/R/DataFrame.R

Large diffs are not rendered by default.

30 changes: 18 additions & 12 deletions R/pkg/R/SQLContext.R
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ getDefaultSqlSource <- function() {
#'
#' Converts R data.frame or list into SparkDataFrame.
#'
#' @param data An RDD or list or data.frame
#' @param schema a list of column names or named list (StructType), optional
#' @return a SparkDataFrame
#' @param data an RDD or list or data.frame.
#' @param schema a list of column names or named list (StructType), optional.
#' @return A SparkDataFrame.
#' @rdname createDataFrame
#' @export
#' @examples
Expand Down Expand Up @@ -257,23 +257,25 @@ createDataFrame.default <- function(data, schema = NULL, samplingRatio = 1.0) {
}

createDataFrame <- function(x, ...) {
dispatchFunc("createDataFrame(data, schema = NULL, samplingRatio = 1.0)", x, ...)
dispatchFunc("createDataFrame(data, schema = NULL)", x, ...)
}

#' @param samplingRatio Currently not used.
#' @rdname createDataFrame
#' @aliases createDataFrame
#' @export
#' @method as.DataFrame default
#' @note as.DataFrame since 1.6.0
as.DataFrame.default <- function(data, schema = NULL, samplingRatio = 1.0) {
createDataFrame(data, schema, samplingRatio)
createDataFrame(data, schema)
}

#' @param ... additional argument(s).
#' @rdname createDataFrame
#' @aliases as.DataFrame
#' @export
as.DataFrame <- function(x, ...) {
dispatchFunc("as.DataFrame(data, schema = NULL, samplingRatio = 1.0)", x, ...)
as.DataFrame <- function(data, ...) {
dispatchFunc("as.DataFrame(data, schema = NULL)", data, ...)
}

#' toDF
Expand Down Expand Up @@ -398,7 +400,7 @@ read.orc <- function(path) {
#'
#' Loads a Parquet file, returning the result as a SparkDataFrame.
#'
#' @param path Path of file to read. A vector of multiple paths is allowed.
#' @param path path of file to read. A vector of multiple paths is allowed.
#' @return SparkDataFrame
#' @rdname read.parquet
#' @export
Expand All @@ -418,6 +420,7 @@ read.parquet <- function(x, ...) {
dispatchFunc("read.parquet(...)", x, ...)
}

#' @param ... argument(s) passed to the method.
#' @rdname read.parquet
#' @name parquetFile
#' @export
Expand Down Expand Up @@ -727,6 +730,7 @@ dropTempView <- function(viewName) {
#' @param source The name of external data source
#' @param schema The data schema defined in structType
#' @param na.strings Default string value for NA when source is "csv"
#' @param ... additional external data source specific named properties.
#' @return SparkDataFrame
#' @rdname read.df
#' @name read.df
Expand Down Expand Up @@ -791,10 +795,11 @@ loadDF <- function(x, ...) {
#' If `source` is not specified, the default data source configured by
#' "spark.sql.sources.default" will be used.
#'
#' @param tableName A name of the table
#' @param path The path of files to load
#' @param source the name of external data source
#' @return SparkDataFrame
#' @param tableName a name of the table.
#' @param path the path of files to load.
#' @param source the name of external data source.
#' @param ... additional argument(s) passed to the method.
#' @return A SparkDataFrame.
#' @rdname createExternalTable
#' @export
#' @examples
Expand Down Expand Up @@ -840,6 +845,7 @@ createExternalTable <- function(x, ...) {
#' clause expressions used to split the column `partitionColumn` evenly.
#' This defaults to SparkContext.defaultParallelism when unset.
#' @param predicates a list of conditions in the where clause; each one defines one partition
#' @param ... additional JDBC database connection named propertie(s).
#' @return SparkDataFrame
#' @rdname read.jdbc
#' @name read.jdbc
Expand Down
11 changes: 8 additions & 3 deletions R/pkg/R/WindowSpec.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ setMethod("show", "WindowSpec",
#'
#' Defines the partitioning columns in a WindowSpec.
#'
#' @param x a WindowSpec
#' @return a WindowSpec
#' @param x a WindowSpec.
#' @param col a column to partition on (desribed by the name or Column).
#' @param ... additional column(s) to partition on.
#' @return A WindowSpec.
#' @rdname partitionBy
#' @name partitionBy
#' @aliases partitionBy,WindowSpec-method
Expand Down Expand Up @@ -86,7 +88,7 @@ setMethod("partitionBy",
#'
#' Defines the ordering columns in a WindowSpec.
#' @param x a WindowSpec
#' @param col a character or Column object indicating an ordering column
#' @param col a character or Column indicating an ordering column
#' @param ... additional sorting fields
#' @return A WindowSpec.
#' @name orderBy
Expand Down Expand Up @@ -192,6 +194,9 @@ setMethod("rangeBetween",
#'
#' Define a windowing column.
#'
#' @param x a Column, usually one returned by window function(s).
#' @param window a WindowSpec object. Can be created by `windowPartitionBy` or
#' `windowOrderBy` and configured by other WindowSpec methods.
#' @rdname over
#' @name over
#' @aliases over,Column,WindowSpec-method
Expand Down
18 changes: 15 additions & 3 deletions R/pkg/R/column.R
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,9 @@ setMethod("alias",
#' @family colum_func
#' @aliases substr,Column-method
#'
#' @param start starting position
#' @param stop ending position
#' @param x a Column.
#' @param start starting position.
#' @param stop ending position.
#' @note substr since 1.4.0
setMethod("substr", signature(x = "Column"),
function(x, start, stop) {
Expand Down Expand Up @@ -219,6 +220,7 @@ setMethod("endsWith", signature(x = "Column"),
#' @family colum_func
#' @aliases between,Column-method
#'
#' @param x a Column
#' @param bounds lower and upper bounds
#' @note between since 1.5.0
setMethod("between", signature(x = "Column"),
Expand All @@ -233,6 +235,11 @@ setMethod("between", signature(x = "Column"),

#' Casts the column to a different data type.
#'
#' @param x a Column.
#' @param dataType a character object describing the target data type.
#' See
#' \href{https://spark.apache.org/docs/latest/sparkr.html#data-type-mapping-between-r-and-spark}{
#' Spark Data Types} for available data types.
#' @rdname cast
#' @name cast
#' @family colum_func
Expand All @@ -254,10 +261,12 @@ setMethod("cast",

#' Match a column with given values.
#'
#' @param x a Column.
#' @param table a collection of values (coercible to list) to compare with.
#' @rdname match
#' @name %in%
#' @aliases %in%,Column-method
#' @return a matched values as a result of comparing with given values.
#' @return A matched values as a result of comparing with given values.
#' @export
#' @examples
#' \dontrun{
Expand All @@ -277,6 +286,9 @@ setMethod("%in%",
#' If values in the specified column are null, returns the value.
#' Can be used in conjunction with `when` to specify a default value for expressions.
#'
#' @param x a Column.
#' @param value value to replace when the corresponding entry in \code{x} is NA.
#' Can be a single value or a Column.
#' @rdname otherwise
#' @name otherwise
#' @family colum_func
Expand Down
Loading