Github user HyukjinKwon commented on the issue: https://github.com/apache/spark/pull/14124 Oh, I see, before this patch ``` +---+ | a| +---+ | 1| | 0| +---+ ``` after this patch ``` +----+ | a| +----+ | 1| |null| +----+ ``` FYI, currently (before this patch) the code below ```scala val rdd = spark.sparkContext.makeRDD(Seq("{\"a\" : 1}", "{\"a\" : null}")) val schema = StructType(StructField("a", StringType, nullable = false) :: Nil) val df = spark.read.schema(schema).json(rdd) df.show() ``` is being failed with the exception below: ``` Error while decoding: java.lang.NullPointerException createexternalrow(input[0, string, false].toString, StructField(a,StringType,false)) +- input[0, string, false].toString +- input[0, string, false] java.lang.RuntimeException: Error while decoding: java.lang.NullPointerException createexternalrow(input[0, string, false].toString, StructField(a,StringType,false)) +- input[0, string, false].toString +- input[0, string, false] at org.apache.spark.sql.catalyst.encoders.ExpressionEncoder.fromRow(ExpressionEncoder.scala:292) at org.apache.spark.sql.Dataset$$anonfun$org$apache$spark$sql$Dataset$$execute$1$1$$anonfun$apply$15.apply(Dataset.scala:2218) at org.apache.spark.sql.Dataset$$anonfun$org$apache$spark$sql$Dataset$$execute$1$1$$anonfun$apply$15.apply(Dataset.scala:2218) at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234) at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234) at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33) at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:186) ... ``` It seems unexpected behaviour anyway. I will submit a patch if this one is decided not worth being added. Thanks @gatorsmile again!
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org