In the spark shell (which uses scala -repl), it seems impossible to create a class (case) that has a default constructor (i.e. a constructor with no arguments):
scala> case class Hello(i: Int) {
| def this() = this(0)
| }
defined class Hello
scala> classOf[Hello].getName
res1: String = Hello
scala> classOf[Hello].getConstructors()
res2: Array[java.lang.reflect.Constructor[_]] = Array(public Hello($iw), public Hello($iw,int))
This forces Jackson not to deserialize something in this class, because there is no easy way to build an instance of this class using reflection.
Is it possible for the case class to have a default constructor in the spark shell?
source
share