Business analysts need a tabular view where every ad appears as its own row while the campaign_id and start_date values remain attached to each ad. Which data-wrangling step will achieve this result with the least duplication and without information loss?
Pivot the ads array so that the first, second, and third ads become separate groups of columns in the same campaign row.
Concatenate all ad objects into a single semicolon-delimited VARCHAR column in the table.
Leave the JSON intact and rely on the BI tool's JSON parsing functions to interpret the ads array at query time.
Apply an array explode/UNNEST on the ads array, then select the ad-level fields along with campaign_id and start_date.
Flattening an array in JSON is most efficiently done by turning each array element into an individual row (sometimes called exploding or unnesting the array). An explode/UNNEST operation produces one row per element in the ads array and automatically repeats the parent columns (campaign_id, start_date) for every new row, preserving the relationship between parent and child without creating extra wide columns or opaque strings. Leaving the JSON unmodified forces every downstream query or BI tool to parse semi-structured data at run-time, adding latency and complexity. Pivoting the array would require pre-defining a maximum number of ads and would generate many null columns when campaigns have fewer ads, while concatenating the objects into a delimited string removes their structure completely and makes later analysis difficult. Therefore, applying an explode/UNNEST on the ads array is the most correct and scalable approach.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What does explode/UNNEST do in data wrangling?
Open an interactive chat with Bash
Why is pivoting the `ads` array less efficient for this transformation?
Open an interactive chat with Bash
How does leaving the JSON intact impact performance and analysis?