ZMath_lin
ZMath_lin

Reputation: 553

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)

Upvotes: 5

Views: 10161

Answers (1)

Raphael Roth
Raphael Roth

Reputation: 27373

add the following import:

import org.apache.spark.sql.Row

Upvotes: 22

Related Questions