DataFrame supports two types of current_
on date and timestamp
Let's consider a DataFrame df with id and event_date columns.
We can perform the following filter operations :
import sqlContext.implicits._
import org.apache.spark.sql.functions._
// the event_date is before the current timestamp
df.filter('event_date.lt(current_timestamp()))
// the event_date is after the current timestamp
df.filter('event_date.gt(current_timestamp()))
I advice you to read the associated scala doc for more information here. You have a whole section on dates and timestamps operations.
EDIT: As discussed in the comments, in order to add a day to your event_date
column, you can use the date_add
function :
df.filter(date_add('event_date,1).lt(current_timestamp()))