diff options
author | hyukjinkwon <gurwls223@gmail.com> | 2017-03-14 19:51:25 -0700 |
---|---|---|
committer | Felix Cheung <felixcheung@apache.org> | 2017-03-14 19:51:25 -0700 |
commit | d1f6c64c4b763c05d6d79ae5497f298dc3835f3e (patch) | |
tree | 3212b7cef66bde23763bba7358f7560a973d8beb /sql/core | |
parent | 8fb2a02e2ce6832e3d9338a7d0148dfac9fa24c2 (diff) | |
download | spark-d1f6c64c4b763c05d6d79ae5497f298dc3835f3e.tar.gz spark-d1f6c64c4b763c05d6d79ae5497f298dc3835f3e.tar.bz2 spark-d1f6c64c4b763c05d6d79ae5497f298dc3835f3e.zip |
[SPARK-19828][R] Support array type in from_json in R
## What changes were proposed in this pull request?
Since we could not directly define the array type in R, this PR proposes to support array types in R as string types that are used in `structField` as below:
```R
jsonArr <- "[{\"name\":\"Bob\"}, {\"name\":\"Alice\"}]"
df <- as.DataFrame(list(list("people" = jsonArr)))
collect(select(df, alias(from_json(df$people, "array<struct<name:string>>"), "arrcol")))
```
prints
```R
arrcol
1 Bob, Alice
```
## How was this patch tested?
Unit tests in `test_sparkSQL.R`.
Author: hyukjinkwon <gurwls223@gmail.com>
Closes #17178 from HyukjinKwon/SPARK-19828.
Diffstat (limited to 'sql/core')
-rw-r--r-- | sql/core/src/main/scala/org/apache/spark/sql/api/r/SQLUtils.scala | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/api/r/SQLUtils.scala b/sql/core/src/main/scala/org/apache/spark/sql/api/r/SQLUtils.scala index a4c5bf756c..c77328690d 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/api/r/SQLUtils.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/api/r/SQLUtils.scala @@ -81,7 +81,7 @@ private[sql] object SQLUtils extends Logging { new JavaSparkContext(spark.sparkContext) } - def createStructType(fields : Seq[StructField]): StructType = { + def createStructType(fields: Seq[StructField]): StructType = { StructType(fields) } |