Skip to content

Instantly share code, notes, and snippets.

@marcovivero
Created July 30, 2015 19:14
Show Gist options
  • Save marcovivero/069621ed8add8c40bcb2 to your computer and use it in GitHub Desktop.
Save marcovivero/069621ed8add8c40bcb2 to your computer and use it in GitHub Desktop.
val filterRecentTimeUDF : Long => UserDefinedFunction = {
(l : Long) => {
functions.udf(
// s refers to eventTime, t refers to userEventTime
(s : Timestamp, t: Timestamp) => if (s.getTime - t.getTime < l) true else false
)
}
}
val day : Long = 1000*60*60*24
val week : Long = day * 7
val month : Long = week * 4
@yipjustin
Copy link

(s.getTime - t.getTime < l) already return a boolean value. don't need to apply if else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment