Repository: spark
Updated Branches:
  refs/heads/master 2cbb3e433 -> 2e0c08452


[SPARK-5789][SQL]Throw a better error message if JsonRDD.parseJson encounters 
unrecoverable parsing errors.

Author: Yin Huai <yh...@databricks.com>

Closes #4582 from yhuai/jsonErrorMessage and squashes the following commits:

152dbd4 [Yin Huai] Update error message.
1466256 [Yin Huai] Throw a better error message when a JSON object in the input 
dataset span multiple records (lines for files or strings for an RDD of 
strings).


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/2e0c0845
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/2e0c0845
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/2e0c0845

Branch: refs/heads/master
Commit: 2e0c084528409e1c565e6945521a33c0835ebbee
Parents: 2cbb3e4
Author: Yin Huai <yh...@databricks.com>
Authored: Fri Feb 13 13:51:06 2015 -0800
Committer: Michael Armbrust <mich...@databricks.com>
Committed: Fri Feb 13 13:51:06 2015 -0800

----------------------------------------------------------------------
 sql/core/src/main/scala/org/apache/spark/sql/json/JsonRDD.scala | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/2e0c0845/sql/core/src/main/scala/org/apache/spark/sql/json/JsonRDD.scala
----------------------------------------------------------------------
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/json/JsonRDD.scala 
b/sql/core/src/main/scala/org/apache/spark/sql/json/JsonRDD.scala
index 7dfb304..3b8dde1 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/json/JsonRDD.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/json/JsonRDD.scala
@@ -306,6 +306,10 @@ private[sql] object JsonRDD extends Logging {
           val parsed = mapper.readValue(record, classOf[Object]) match {
             case map: java.util.Map[_, _] => 
scalafy(map).asInstanceOf[Map[String, Any]] :: Nil
             case list: java.util.List[_] => 
scalafy(list).asInstanceOf[Seq[Map[String, Any]]]
+            case _ =>
+              sys.error(
+                s"Failed to parse record $record. Please make sure that each 
line of the file " +
+                "(or each string in the RDD) is a valid JSON object or an 
array of JSON objects.")
           }
 
           parsed


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to