How do we unnest an array of order items into individual rows, one row per item?
explode(col) creates a new row for each element in the given array or map column.
Unnesting shopping carts, normalising 1-to-many relationship payloads, and processing clickstream sequences.
from pyspark.sql.functions import col, explode
exploded_df = df.select(col("order_id"), explode(col("items")).alias("item"))Practice typing production-grade PySpark code for Flattening Array Collections with explode().