Let's say I have a dataframe like this
val df = Seq((2012, 8, "Batman", 9.8), (2012, 8, "Hero", 8.7), (2012, 7, "Robot", 5.5), (2011, 7, "Git", 2.0)).toDF("year", "month", "title", "rating")
I can convert the whole row to json like this.
val jsonColumns = df.select("year", "month", "title", "rating").toJSON
How can I get only the month, year and title in json and year to be out of the json object, but still part of the dataframe (so i can use it as partition column)?