Once I have got in Spark some Row class, either Dataframe or Catalyst, I want to convert it to a case class in my code. This can be done by matching
someRow
As far as I know you cannot cast a Row to a case class, but I sometimes chose to access the row fields directly, like
map(row => myCaseClass(row.getLong(0), row.getString(1), row.getDouble(2))
I find this to be easier, especially if the case class constructor only needs some of the fields from the row.