Skip to content

Commit

Permalink
new version of CreateDF
Browse files Browse the repository at this point in the history
New version uses takes a `StructType` from R and creates a DataFrame.

Commented out the `tojson` version since we don't currently use it.
  • Loading branch information
cafreeman authored and Davies Liu committed Apr 14, 2015
1 parent 836c4bf commit 1a3b63d
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ 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)
sqlContext.createDataFrame(rowRDD, schema)
Expand Down

0 comments on commit 1a3b63d

Please sign in to comment.