Skip to content

Commit

Permalink
Add projection pushdown support to JsonRDD/JsonRDD2
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Howell committed May 1, 2015
1 parent f636c14 commit ab6ee87
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ private[sql] class JSONRelation(
@transient val sqlContext: SQLContext)
extends BaseRelation
with TableScan
with InsertableRelation {
with InsertableRelation
with CatalystScan {

def this(
path: String,
Expand Down Expand Up @@ -158,6 +159,19 @@ private[sql] class JSONRelation(
}
}

override def buildScan(requiredColumns: Seq[Attribute], filters: Seq[Expression]): RDD[Row] = {
if (useJsonRDD2) {
JsonRDD2.jsonStringToRow(
baseRDD,
StructType.fromAttributes(requiredColumns),
sqlContext.conf.columnNameOfCorruptRecord)
} else {
JsonRDD.jsonStringToRow(
baseRDD,
StructType.fromAttributes(requiredColumns),
sqlContext.conf.columnNameOfCorruptRecord)
}
}

override def insert(data: DataFrame, overwrite: Boolean): Unit = {
val filesystemPath = path match {
Expand Down

0 comments on commit ab6ee87

Please sign in to comment.