Github user viirya commented on a diff in the pull request: https://github.com/apache/spark/pull/10391#discussion_r48314187 --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/encoders/ExpressionEncoderSuite.scala --- @@ -239,6 +240,30 @@ class ExpressionEncoderSuite extends SparkFunSuite { ExpressionEncoder.tuple(intEnc, ExpressionEncoder.tuple(intEnc, longEnc)) } + test("Option in Array") { + val data = (Seq(Some(1), Some(2), None), "Option in array") + + val schema = ScalaReflection.schemaFor[Tuple2[Seq[Option[Int]], String]] + .dataType.asInstanceOf[StructType] + val attributeSeq = schema.toAttributes + val dataEncoder = encoderFor[Tuple2[Seq[Option[Int]], String]] + val boundEncoder = dataEncoder.resolve(attributeSeq, outers).bind(attributeSeq) + assert(boundEncoder.fromRow(boundEncoder.toRow(data)) === ( + Seq(Some(1), Some(2), null), "Option in array")) + } + + test("Option in Map") { + val data = (Map(1 -> Some(10L), 2 -> Some(20L), 3 -> None), "Option in map") + + val schema = ScalaReflection.schemaFor[Tuple2[Map[Int, Option[Long]], String]] + .dataType.asInstanceOf[StructType] + val attributeSeq = schema.toAttributes + val dataEncoder = encoderFor[Tuple2[Map[Int, Option[Long]], String]] + val boundEncoder = dataEncoder.resolve(attributeSeq, outers).bind(attributeSeq) + assert(boundEncoder.fromRow(boundEncoder.toRow(data)) === ( + Map(1 -> Some(10L), 2 -> Some(20L), 3 -> null), "Option in map")) + } --- End diff -- OK. I am investigating the now.
--- 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