0
votes

I know there's a 'current_timestamp' function in Spark 1.5 & above, but we're still on 1.4. How do I add a column to a DataFrame that is set to 'current timestamp'?

df.withColumn("date_inserted", ????)
1

1 Answers

1
votes

Simple timestamp literal should do the trick:

df.withColumn(
  "date_inserted",
  lit(java.sql.Timestamp.from(java.time.Instant.now)))