title: Equivalent of R data.table rolling join in Python and PySpark
body: <p>Does anyone know how to do an R data.table rolling join in PySpark?</p>
  
  <p>Borrowing the example and nice explanation of rolling joins from Ben <a href="http://gormanalysis.com/r-data-table-rolling-joins/" rel="nofollow">here</a>;</p>
  
  <pre><code>sales&lt;-data.table(saleID=c("S1","S2","S3","S4","S5"), 
                saleDate=as.Date(c("2014-2-20","2014-5-1","2014-6-15","2014-7- 1","2014-12-31")))
  
  commercials&lt;-data.table(commercialID=c("C1","C2","C3","C4"), 
                      commercialDate=as.Date(c("2014-1-1","2014-4-1","2014-7-1","2014-9-15")))
  
  setkey(sales,"saleDate")
  setkey(commercials,"commercialDate")
  
  sales[commercials, roll=TRUE]
  </code></pre>
  
  <p>Result being;</p>
  
  <pre><code>saleDate saleID commercialID
  1: 2014-01-01     NA    C1
  2: 2014-04-01     S1    C2
  3: 2014-07-01     S4    C3
  4: 2014-09-15     S4    C4
  </code></pre>
  
  <p>Many thanks for the help.</p>