|
| 1 | +# A set of S3 classes and methods that support the SparkSQL `StructType` and `StructField |
| 2 | +# datatypes. These are used to create and interact with DataFrame schemas. |
| 3 | + |
1 | 4 | #' structType
|
2 | 5 | #'
|
3 | 6 | #' Create a structType object that contains the metadata for a DataFrame. Intended for
|
4 | 7 | #' use with createDataFrame and toDF.
|
5 | 8 | #'
|
6 |
| -#' @param x a Field object (created with the field() function) |
7 |
| -#' @param ... additional Field objects |
| 9 | +#' @param x a structField object (created with the field() function) |
| 10 | +#' @param ... additional structField objects |
8 | 11 | #' @return a structType object
|
9 | 12 | #' @export
|
10 | 13 | #' @examples
|
11 | 14 | #'\dontrun{
|
12 | 15 | #' sc <- sparkR.init()
|
13 | 16 | #' sqlCtx <- sparkRSQL.init(sc)
|
14 | 17 | #' rdd <- lapply(parallelize(sc, 1:10), function(x) { list(x, as.character(x)) })
|
15 |
| -#' schema <- buildSchema(field("a", "integer"), field("b", "string")) |
| 18 | +#' schema <- structType(structField("a", "integer"), structField("b", "string")) |
16 | 19 | #' df <- createDataFrame(sqlCtx, rdd, schema)
|
17 | 20 | #' }
|
18 | 21 | structType <- function(x, ...) {
|
@@ -63,16 +66,16 @@ print.structType <- function(x, ...) {
|
63 | 66 | #' @param x The name of the field
|
64 | 67 | #' @param type The data type of the field
|
65 | 68 | #' @param nullable A logical vector indicating whether or not the field is nullable
|
66 |
| -#' @return a Field object |
| 69 | +#' @return a structField object |
67 | 70 | #' @export
|
68 | 71 | #' @examples
|
69 | 72 | #'\dontrun{
|
70 | 73 | #' sc <- sparkR.init()
|
71 | 74 | #' sqlCtx <- sparkRSQL.init(sc)
|
72 | 75 | #' rdd <- lapply(parallelize(sc, 1:10), function(x) { list(x, as.character(x)) })
|
73 |
| -#' field1 <- field("a", "integer", TRUE) |
74 |
| -#' field2 <- field("b", "string", TRUE) |
75 |
| -#' schema <- buildSchema(field1, field2) |
| 76 | +#' field1 <- structField("a", "integer", TRUE) |
| 77 | +#' field2 <- structField("b", "string", TRUE) |
| 78 | +#' schema <- structType(field1, field2) |
76 | 79 | #' df <- createDataFrame(sqlCtx, rdd, schema)
|
77 | 80 | #' }
|
78 | 81 |
|
|
0 commit comments