Eve
New Contributor III

And in SCALA - assuming that df1 has a "date" column:

import org.apache.spark.sql.functions._ import org.apache.spark.sql.types._ import org.apache.spark.sql._

val df2 = df1.withColumn("year", year(col("date"))) .withColumn("month", month(col("date"))) .withColumn("day", dayofmonth(col("date"))) .withColumn("hour", hour(col("date")))

df2.show(Int.MaxValue)