aboutsummaryrefslogtreecommitdiff
path: root/R/pkg/R/SQLContext.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/pkg/R/SQLContext.R')
-rw-r--r--R/pkg/R/SQLContext.R4
1 files changed, 4 insertions, 0 deletions
diff --git a/R/pkg/R/SQLContext.R b/R/pkg/R/SQLContext.R
index 783df53c12..ce531c3f88 100644
--- a/R/pkg/R/SQLContext.R
+++ b/R/pkg/R/SQLContext.R
@@ -202,7 +202,10 @@ getDefaultSqlSource <- function() {
# TODO(davies): support sampling and infer type from NA
createDataFrame.default <- function(data, schema = NULL, samplingRatio = 1.0) {
sparkSession <- getSparkSession()
+
if (is.data.frame(data)) {
+ # Convert data into a list of rows. Each row is a list.
+
# get the names of columns, they will be put into RDD
if (is.null(schema)) {
schema <- names(data)
@@ -227,6 +230,7 @@ createDataFrame.default <- function(data, schema = NULL, samplingRatio = 1.0) {
args <- list(FUN = list, SIMPLIFY = FALSE, USE.NAMES = FALSE)
data <- do.call(mapply, append(args, data))
}
+
if (is.list(data)) {
sc <- callJStatic("org.apache.spark.sql.api.r.SQLUtils", "getJavaSparkContext", sparkSession)
rdd <- parallelize(sc, data)