I have a Dataset[(Long, String)]
that contains an id and a json String
It's built more or less like this:
val ids: Dataset[Long] = ...
val results = ids.mapPartitions( ids => {
// Create http client
.
.
ids.map( id => (id, getJsonById(id))
}
If I run results.toDF
it will create a dataframe with the id and a string with the json, but what I want to have is a Dataframe with the id and all columns that are in the json.
How can I achieve that?
Edit: I want to load the whole json as dataframe, not a particular field of it.
Something like what sparkContext.read.json(jsonRDD: RDD[String])
would do.
Thanks