Ultimate access to all questions.
Upgrade Now 🚀
Sign in to unlock AI tutor
You have a DataFrame df with a nested column profile.age. How would you cast this nested field to an integer and create a new top-level column named age using Spark? Provide the code snippet.
df
profile.age
age
A
df.withColumn('age', col('profile.age').cast('int'))
B
df.select(col('profile.age').cast('int').alias('age'))
C
df.withColumn('age', 'profile.age'.cast('int'))
D
df.select('profile.age'.cast('int').alias('age'))