2

I am using spark 1.6 and trying to get and cast a dataframe row value.

here is my problem : i have a row in my dataframe who have this kind of structure:

WrappedArray([List of String], [List of String]) 

I need tu use [List of String] in the WrappedArray , so i try to cast it with the this code :

 val RDD= DF.map(

    f => {

      if(f.getAs("ListOfRficAction")!=null){
        var listActions = f.getAs("ColumnName").asInstanceOf[WrappedArray[List[List[Any]]]] .map(m=>m:+f.getAs("AssetId").toString)


    })

and i have the following error :

java.lang.ClassCastException: org.apache.spark.sql.catalyst.expressions.GenericRowWithSchema cannot be cast to scala.collection.mutable.WrappedArray

Any idea of how i can cast it ?

Pavel
  • 1,519
  • 21
  • 29
Mbula Guy Marcel
  • 81
  • 1
  • 4
  • 11
  • 1
    I can't make your code compile. Please see: [How to create a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). Please provide your build.sbt and imports. Your `map` is strange now. You assign something to `listActions` and don't return anything nor use `listActions`. And if condition is not satisfied you don't return anything either. Even opening and closing brackets don't correspond to each other. – Dmytro Mitin Oct 18 '17 at 20:10
  • thaks for answer, i use a maven project not sbt. – Mbula Guy Marcel Oct 19 '17 at 07:40
  • Then pom.xml of the project. – Dmytro Mitin Oct 19 '17 at 07:41
  • please see my answers – Mbula Guy Marcel Oct 19 '17 at 07:45
  • Try to cast to `WrappedArray[WrappedArray[String]]`. https://stackoverflow.com/questions/41904744/how-to-cast-a-wrappedarraywrappedarrayfloat-to-arrayarrayfloat-in-spark – Dmytro Mitin Oct 19 '17 at 15:47

0 Answers0