val keysDF = mapTypeDF.select(explode(map_keys($"property"))).distinct() val keys = keysDF.collect().map(f=>f.get(0)) val keyCols = keys.map(f=> col("property").getItem(f).as(f.toString)) val expandedDf = mapTypeDF.select(col("name") +: keyCols:_*).show(false)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter