I am using Spark SQL for extracting some information from a JSON file. The question is I want to save the result from the SQL analysis into a CSV file for plotting it with Plateau or with d3.js and I'm not able to add a row which contains the "identifiers" of my columns. For example, if I execute the code which is below, I obtain something like this:
val languages = sqlContext.sql(""""<QUERY>"""")
val result = idiomas.map(row => row(0) + "," + row(1))
result.saveAsTextFile(outputDirectory + "/lang")
result.collect.foreach(println)
A,395
B,275
C,106
D,60
And what I want is to add an identifier row and obtain this:
letter,number
A,395
B,275
C,106
D,60
How can I do it? Thanks!