How do we unnest an array while retaining users who have zero or null elements in their list?
explode_outer() unnests arrays like explode(), but outputs a row with NULL instead of dropping empty arrays.
Preventing accidental row loss when flattening optional array attributes like user subscriptions.
from pyspark.sql.functions import col, explode_outer
df = df.select(col("user_id"), explode_outer(col("subscriptions")).alias("subscription"))Practice typing production-grade PySpark code for Preserving Empty Rows with explode_outer().