aboutsummaryrefslogtreecommitdiff
path: root/R/pkg
diff options
context:
space:
mode:
authorLiang-Chi Hsieh <viirya@appier.com>2015-07-09 09:57:12 -0700
committerDavies Liu <davies.liu@gmail.com>2015-07-09 09:57:12 -0700
commit59cc38944fe5c1dffc6551775bd939e2ac66c65e (patch)
tree096af5fed8bf82174478386406661adc6119b63c /R/pkg
parenta1964e9d902bb31f001893da8bc81f6dce08c908 (diff)
downloadspark-59cc38944fe5c1dffc6551775bd939e2ac66c65e.tar.gz
spark-59cc38944fe5c1dffc6551775bd939e2ac66c65e.tar.bz2
spark-59cc38944fe5c1dffc6551775bd939e2ac66c65e.zip
[SPARK-8940] [SPARKR] Don't overwrite given schema in createDataFrame
JIRA: https://issues.apache.org/jira/browse/SPARK-8940 The given `schema` parameter will be overwritten in `createDataFrame` now. If it is not null, we shouldn't overwrite it. Author: Liang-Chi Hsieh <viirya@appier.com> Closes #7311 from viirya/df_not_overwrite_schema and squashes the following commits: 2385139 [Liang-Chi Hsieh] Don't overwrite given schema if it is not null.
Diffstat (limited to 'R/pkg')
-rw-r--r--R/pkg/R/SQLContext.R4
1 files changed, 3 insertions, 1 deletions
diff --git a/R/pkg/R/SQLContext.R b/R/pkg/R/SQLContext.R
index 9a743a3411..30978bb50d 100644
--- a/R/pkg/R/SQLContext.R
+++ b/R/pkg/R/SQLContext.R
@@ -86,7 +86,9 @@ infer_type <- function(x) {
createDataFrame <- function(sqlContext, data, schema = NULL, samplingRatio = 1.0) {
if (is.data.frame(data)) {
# get the names of columns, they will be put into RDD
- schema <- names(data)
+ if (is.null(schema)) {
+ schema <- names(data)
+ }
n <- nrow(data)
m <- ncol(data)
# get rid of factor type