SPRKSCL1118
org.apache.spark.sql.functions.trunc
Description
Scenario
val df = Seq(
Date.valueOf("2024-10-28"),
Date.valueOf("2023-05-15"),
Date.valueOf("2022-11-20"),
).toDF("date")
val result = df.withColumn("truncated", trunc(col("date"), "month"))val df = Seq(
Date.valueOf("2024-10-28"),
Date.valueOf("2023-05-15"),
Date.valueOf("2022-11-20"),
).toDF("date")
/*EWI: SPRKSCL1118 => org.apache.spark.sql.functions.trunc has a workaround, see documentation for more info*/
val result = df.withColumn("truncated", trunc(col("date"), "month"))Additional recommendations
Last updated
