In Scala/Spark DataFrame
dfReduced.schema.fieldNames
is a java String array (String[]). However,
dfReduced.schema.fieldNames.asInstanceOf[Seq[String]]
throws
java.lang.ClassCastException: [Ljava.lang.String; cannot be cast to scala.collection.Seq
Assigning same array to a Seq[String] is fine.
val f3:Seq[String]=dfReduced.schema.fieldNames
As a Java programmer this surprises me as both would require casting in Java. Can someone explain why there is this distinction in Scala
(Note, I'm not being critical, I just want to understand Scala better)