Ultimate access to all questions.
Upgrade Now 🚀
Sign in to unlock AI tutor
Given a DataFrame df with a column event_time in string format, how would you cast this column to a timestamp using Spark? Provide the code snippet.
df
event_time
A
df.withColumn('event_time', to_timestamp('event_time', 'yyyy-MM-dd HH:mm:ss'))
B
df.select(to_timestamp('event_time', 'yyyy-MM-dd HH:mm:ss'))
C
df.withColumn('event_time', col('event_time').cast('timestamp'))
D
df.select(col('event_time').cast('timestamp'))