Skip to content
Advertisement

Extracting a string from a nested dictionary in presto

I have data that looks like this:

I’d like to extract “subquestions” into separate rows (in an sql table): — Making ads for Meta platforms — Producing video content — Applying mobile creatives best…

I have a tried a few functions json_extract_scalar, and Map functions etc, but I didn’t succeed.

Thanks in advance for your help.

So the thing I was doing, which is a bit convoluted and leads to an incorrect solution is this:

I come close to what am trying to do, but I end up with a lot more rows than I need. I think I’m getting closer though.

The thing am really trying to do is put together a datasets of questions and answers. I want to pair them up together nicely.

The data looks like this::

I want to create a table where in the end I have a question:

I was trying to take a shot at it one column at a time

Advertisement

Answer

After fixing the json (the first property for some reason contains mailformed array, not another json object), you can do next:

Output:

subquestion
Kick-off call
Creative presentation
Design Sessions
Final deliverables (assets)
Making ads for Meta platforms
Producing video content
Applying mobile creative best practices
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement