It seems like scala.collection.SortedMap is not serializable?
Simple code example:
case class MyClass(s: scala.collection.SortedMap[String, String] = SortedMap[String, String]())
object MyClass {
def apply(i: Int): MyClass = MyClass()
}
import sparkSession.implicits._
List(MyClass(1), MyClass()).toDS().show(2)
Will return:
+-----+
| s|
+-----+
|Map()|
|Map()|
+-----+
On the other hand, take() will fail miserably at execution time:
List(MyClass(1), MyClass()).toDS().take(2)
ERROR codegen.CodeGenerator: failed to compile: org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 116, Column 100: No applicable constructor/method found for actual parameters "scala.collection.Map"; candidates are: "com.caspida.algorithms.security.offline.exfiltrationthreat.MyClass(scala.collection.SortedMap)"