Skip to content

Commit

Permalink
Fix bug introduced by the change made on SQLContext.inferSchema.
Browse files Browse the repository at this point in the history
  • Loading branch information
yhuai committed Jul 11, 2014
1 parent 43a45e1 commit 7a6a7e5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions sql/core/src/main/scala/org/apache/spark/sql/SQLContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -375,17 +375,15 @@ class SQLContext(@transient val sparkContext: SparkContext)
import scala.collection.JavaConversions._
def typeOfComplexValue: PartialFunction[Any, DataType] = {
case c: java.util.List[_] =>
ArrayType(ScalaReflection.typeOfObject(c.head))
ArrayType(typeOfObject(c.head))
case c: java.util.Set[_] =>
ArrayType(ScalaReflection.typeOfObject(c.head))
ArrayType(typeOfObject(c.head))
case c: java.util.Map[_, _] =>
val (key, value) = c.head
MapType(
ScalaReflection.typeOfObject(key),
ScalaReflection.typeOfObject(value))
MapType(typeOfObject(key), typeOfObject(value))
case c if c.getClass.isArray =>
val elem = c.asInstanceOf[Array[_]].head
ArrayType(ScalaReflection.typeOfObject(elem))
ArrayType(typeOfObject(elem))
case c => throw new Exception(s"Object of type $c cannot be used")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import org.apache.spark.sql.Logging

private[sql] object JsonRDD extends Logging {

def jsonStringToRow(schema: StructType, jsonIter: Iterator[String]): Iterator[Row] = {
private[sql] def jsonStringToRow(schema: StructType, jsonIter: Iterator[String]): Iterator[Row] = {
parseJson(jsonIter).map(parsed => asRow(parsed, schema))
}

Expand Down

0 comments on commit 7a6a7e5

Please sign in to comment.