I have some nested jsons I need to "flatten" in databricks, but I don't need all the fields.
I have a list of the required fields.
What's the best way to go about transforming the data into csv/dataframe?
I have two options I thinking:
- Flatten everything, then drop what's not needed (the issue here is that when I flatten the data I get a lot more rows and I'm not sure how to select the ones to drop). When I try json_normalize() on an entire json locally it quickly goes from say 80 columns and 5000 rows to over 150 columns and 100k+ rows.
- Build the dataframe by getting the desired columns and rows from the jsons using only the desired fields.
- another method?