Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

spark dataframe explode function error

I'd like to use the explode function on a DF, I just write the code like the document:

    case class Url(url:String)
    val temp3 = temp2.explode($"urls"){
        case Row(urls:Array[String]) => urls.map(Url(_))
    }

However , it came out:

error: not found: value Row

The DF temp2 is like:

temp2.printSchema()
root
 |-- userid: string (nullable = true)
 |-- urls: array (nullable = true)
 |    |-- element: string (containsNull = true)
like image 358
ZMath_lin Avatar asked Dec 01 '22 16:12

ZMath_lin


1 Answers

add the following import:

import org.apache.spark.sql.Row
like image 196
Raphael Roth Avatar answered Dec 05 '22 06:12

Raphael Roth