Closed joan38 closed 1 year ago
I get the following error when I return a case class with Options in it:
Option
scala.MatchError: ObjectType(class java.lang.String) (of class org.apache.spark.sql.types.ObjectType)
This test reproduces the issue:
case class DataWithX2(name: Option[String], x: Int) test("Option in case class") { val input = Seq(DataWithPos("zero", 0, 0, 0), DataWithPos("something", 1, 2, 3)) val df = input.toDF() df.createOrReplaceTempView("data") val dataxx = udf((name: String, x: Int) => DataWithX2(Option(name), 2 * x)) val res = spark.sql("SELECT * from data") .withColumn("d", dataxx(col("name"), col("x"))) .collect().toList println("res =====") println(res) // assert(res.size == res.distinct.size) }
I can see a // TODO: Nullable field in EncoderDerivation.scala
// TODO: Nullable field
EncoderDerivation.scala
I get the following error when I return a case class with
Option
s in it:This test reproduces the issue: