Explore Courses Blog Tutorials Interview Questions
0 votes
in Big Data Hadoop & Spark by (11.4k points)

I am doing some testing for spark using scala. We usually read json files which needs to be manipulated like the following example:



val test ="test.json")

How can I convert it to the following format:



1 Answer

0 votes
by (32.3k points)

To convert it into your desired format I would suggest you to use explode function.

explode() takes in an array (or a map) as an input and outputs the elements of the array (map) as separate rows. 

Follow the approach given below:

Browse Categories