Add Number of days column to Date Column in same dataframe for Spark Scala App

前端 未结 2 852
我在风中等你
我在风中等你 2020-12-02 01:55

I have a dataframe df of columns (\"id\", \"current_date\", \"days\") and I am trying to add the the \"days\" to \"

2条回答
  •  生来不讨喜
    2020-12-02 02:23

    No need to use an UDF, you can do it using an SQL expression:

    val newDF = df.withColumn("new_date", expr("date_add(current_date,days)"))
    

提交回复
热议问题