Hi Sir,
Please help me on the below error: in spark 2.1.0 (scala-2.11)
java.lang.ClassCastException: java.sql.Date cannot be cast to java.lang.String
at org.apache.spark.sql.Row$class.getString(Row.scala)
at org.apache.spark.sql.catalyst.expressions.GenericRow.getString(rows.scala)
import java.text.SimpleDateFormat
val someRDD =RDD.groupByKey().mapPartitions {
(iterator) =>
{
val dataFormatter = new SimpleDateFormat(“yyyy-MM-dd”)
myList.map(ip => Row(ip._1.getInt(0),ip._1.getLong(1), ip._1.getInt(2),
new java.sql.Date(dataFormatter.parse(ip._1.getString(7)).getTime), new java.sql.Date(dataFormatter.parse(ip._1.getString(8)).getTime),
error is showing in the above 2 lines.
I have tried the different approach with the following ways.
import java.sql.Date
Date.valueOf(ip._1.getString(7)).getTime,
Date.valueOf(ip._1.getString(8)).getTime,
Still I’m getting the same error saying "Caused by: java.lang.ClassCastException: java.sql.Date cannot be cast to java.lang.String