From 8526d2e71c9cead1af549d2e5982f9ef34498e88 Mon Sep 17 00:00:00 2001 From: cafreeman Date: Fri, 10 Apr 2015 08:45:41 -0500 Subject: [PATCH] Remove `tojson` functions --- pkg/R/schema.R | 27 ------------------- .../org/apache/spark/sql/api/r/SQLUtils.scala | 8 ------ 2 files changed, 35 deletions(-) diff --git a/pkg/R/schema.R b/pkg/R/schema.R index 2f6221d9a2ffb..7aad74a066c9d 100644 --- a/pkg/R/schema.R +++ b/pkg/R/schema.R @@ -140,30 +140,3 @@ print.structField <- function(x, ...) { ")", sep = "") } - -# cfreeman: Don't think we need this function since we can create -# structType in R and pass to createDataFrame -# -# #' dump the schema into JSON string -# tojson <- function(x) { -# if (inherits(x, "struct")) { -# # schema object -# l <- paste(lapply(x, tojson), collapse = ", ") -# paste('{\"type\":\"struct\", \"fields\":','[', l, ']}', sep = '') -# } else if (inherits(x, "field")) { -# # field object -# names <- names(x) -# items <- lapply(names, function(n) { -# safe_n <- gsub('"', '\\"', n) -# paste(tojson(safe_n), ':', tojson(x[[n]]), sep = '') -# }) -# d <- paste(items, collapse = ", ") -# paste('{', d, '}', sep = '') -# } else if (is.character(x)) { -# paste('"', x, '"', sep = '') -# } else if (is.logical(x)) { -# if (x) "true" else "false" -# } else { -# stop(paste("unexpected type:", class(x))) -# } -# } 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 6532ae690aea4..ae77f72998a22 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 @@ -66,14 +66,6 @@ private[r] object SQLUtils { StructField(name, dtObj, nullable) } - // cfreeman: I don't think we need this anymore since we can pass structType from R - // def createDF(rdd: RDD[Array[Byte]], schemaString: String, sqlContext: SQLContext): DataFrame = { - // val schema = DataType.fromJson(schemaString).asInstanceOf[StructType] - // val num = schema.fields.size - // val rowRDD = rdd.map(bytesToRow) - // sqlContext.createDataFrame(rowRDD, schema) - // } - def createDF(rdd: RDD[Array[Byte]], schema: StructType, sqlContext: SQLContext): DataFrame = { val num = schema.fields.size val rowRDD = rdd.map(bytesToRow)