0

I used this code to aggragate the grouped data:

val result=union_df.orderBy(desc("timestamp")).groupBy("id").agg(collect_set("region") as "region")

Then I got the datatype:

org.apache.spark.sql.DataFrame = [id: string, region: array<string>]

What is the different between array<string> and Array<String>? How do I iterate over array<string> in map function (there is no getArray function for Row)?

1
  • 1
    array<string> and string are not Scala types, they are just results of toString call on a DataType which is called by toString on DataFrame. Commented May 24, 2017 at 7:16

1 Answer 1

2

There is a getSeq() function that returns a array or you can use getAs method by getAs[Array[String]]() or getAs[Seq[String]]()

array<string> is scala.collection.mutable.WrappedArray[String]] which is same as a Array<String> with a wrapper on it which is used inside a Row.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.