Kratos Kratos - 1 year ago 66
Scala Question

Type mismatch in scala list. How to get List[String] from a sequence

I have a dataframe that's reading from a MySQL table. What I eventually what after some filters are applied is to create a

Here is what I did:

val ColSelection="session","name")
var sessionData=ColSelection.filter($"session".contains(element.toString()))
var nameSequence ="name").collect.flatMap(_.toSeq)
val sessionList =nameSequence.toList

But with this I am getting a
element causing mismatches when handling it later.
How could I create straight a list that is defined to contain
or how can I convert a
to list of strings?

Answer Source

To convert List[Any] to List[String] you could just

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download