BAR
BAR

Reputation: 17151

Read Array of String from Spark

I saved an Array[String] to a Parquet file from Spark.

To read it I use:

row.getAs[Array[String]]("result")

But get:

java.lang.ClassCastException: scala.collection.mutable.WrappedArray$ofRef cannot be cast to [Ljava.lang.String;

Here is the result of printSchema():

root                                                                            
 |-- result: array (nullable = true)
 |    |-- element: string (containsNull = true)

How should the getAs() be modified?

Upvotes: 14

Views: 13818

Answers (1)

Reactormonk
Reactormonk

Reputation: 21730

Does row.getAs[Seq[String]]("result") work?

Upvotes: 29

Related Questions