Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2019 11:16 PM
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)