Ultimate access to all questions.
Upgrade Now 🚀
Sign in to unlock AI tutor
You have a DataFrame df with a nested column address.city. How would you extract this nested field into a top-level column named city using Spark? Provide the code snippet.
df
address.city
city
A
df.withColumn('city', col('address.city'))
B
df.select(col('address.city').alias('city'))
C
df.withColumn('city', 'address.city')
D
df.select('address.city').alias('city')