Skip to content
Snippets Groups Projects
Commit 59cc3894 authored by Liang-Chi Hsieh's avatar Liang-Chi Hsieh Committed by Davies Liu
Browse files

[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.
parent a1964e9d
No related branches found
No related tags found
No related merge requests found
...@@ -86,7 +86,9 @@ infer_type <- function(x) { ...@@ -86,7 +86,9 @@ infer_type <- function(x) {
createDataFrame <- function(sqlContext, data, schema = NULL, samplingRatio = 1.0) { createDataFrame <- function(sqlContext, data, schema = NULL, samplingRatio = 1.0) {
if (is.data.frame(data)) { if (is.data.frame(data)) {
# get the names of columns, they will be put into RDD # get the names of columns, they will be put into RDD
schema <- names(data) if (is.null(schema)) {
schema <- names(data)
}
n <- nrow(data) n <- nrow(data)
m <- ncol(data) m <- ncol(data)
# get rid of factor type # get rid of factor type
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment