SPARK data filter error: cannot be used for scala.Function2 when using UDF to split rows in a column

I keep getting an error when I use udf to split a row in a column using a separator. I am using scala

Error: java.lang.ClassCastException: $iwC$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC$$anonfun$1 cannot be cast to scala.Function2 

I don’t know what it is and how to fix it.

This is my udf and data frame:

 val rsplit = udf((refsplit: String) => refsplit.split(":")) +---------+--------------------+--------------------+ | user| jsites| jsites1| +---------+--------------------+--------------------+ |123ashish|m.mangahere.co:m....|m.mangahere.co:m....| |456ashish|m.mangahere2.co:m...|m.mangahere2.co:m...| | ashish|m.mangahere.co:m....|m.mangahere.co:m....| +---------+--------------------+--------------------+ 

jsites column looks like m.manghere.co:m.facebook.com:.msn.com . And I'm trying to use udf to split m.manghere.co:m.facebook.com:.msn.com into :

I get this error

+5
source share

All Articles