Skip to content

Commit ab6ee87

Browse files
author
Nathan Howell
committed
Add projection pushdown support to JsonRDD/JsonRDD2
1 parent f636c14 commit ab6ee87

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

sql/core/src/main/scala/org/apache/spark/sql/json/JSONRelation.scala

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ private[sql] class JSONRelation(
111111
@transient val sqlContext: SQLContext)
112112
extends BaseRelation
113113
with TableScan
114-
with InsertableRelation {
114+
with InsertableRelation
115+
with CatalystScan {
115116

116117
def this(
117118
path: String,
@@ -158,6 +159,19 @@ private[sql] class JSONRelation(
158159
}
159160
}
160161

162+
override def buildScan(requiredColumns: Seq[Attribute], filters: Seq[Expression]): RDD[Row] = {
163+
if (useJsonRDD2) {
164+
JsonRDD2.jsonStringToRow(
165+
baseRDD,
166+
StructType.fromAttributes(requiredColumns),
167+
sqlContext.conf.columnNameOfCorruptRecord)
168+
} else {
169+
JsonRDD.jsonStringToRow(
170+
baseRDD,
171+
StructType.fromAttributes(requiredColumns),
172+
sqlContext.conf.columnNameOfCorruptRecord)
173+
}
174+
}
161175

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

0 commit comments

Comments
 (0)