title: Should non-equi inner join (nomatch=0L) be bidirectional?
body: <p>When doing a non-equi inner join, should the order of X[Y] and Y[X] matters? I am under the impression that it should not.</p>
  
  <pre><code>library(data.table) #data.table_1.12.2
  dt1 &lt;- data.table(ID=LETTERS[1:4], TIME=2L:5L)
  cols1 &lt;- names(dt1)
  dt2 &lt;- data.table(ID=c("A", "B"), START=c(1L, 20L), END=c(3L, 30L))
  cols2 &lt;- names(dt2)
  
  &gt; dt1
     ID TIME
  1:  A    2
  2:  B    3
  3:  C    4
  4:  D    5
  
  &gt; dt2
     ID START END
  1:  A     1   3
  2:  B    20  30
  </code></pre>
  
  <p>I am trying to filter for rows in <code>dt1</code> such that 1) ID matches and 2) dt1$TIME lies between dt2$START and dt2$END. Desired output:</p>
  
  <pre><code>   ID TIME
  1:  A    2
  </code></pre>
  
  <p>Since I wanted rows from <code>dt1</code>, I started with using <code>dt1</code> as <code>i</code> in <code>data.table[</code> but I am getting either columns from <code>dt2</code> or encountered errors:</p>
  
  <pre><code>#no error but using x. values
  dt2[dt1, on=.(ID, START&lt;TIME, END&gt;TIME), nomatch=0L]
  
  #error for the rest 
  dt2[dt1, on=.(ID, START&lt;TIME, END&gt;TIME), nomatch=0L, mget(paste0("i.", cols1))]
  dt2[dt1, on=.(ID, START&lt;TIME, END&gt;TIME), nomatch=0L, .SD]
  dt2[dt1, on=.(ID, START&lt;TIME, END&gt;TIME), nomatch=0L, .(START)]
  </code></pre>
  
  <p>Error message:</p>
  
  <blockquote>
    <p>Error in <code>[.data.table</code>(dt2, dt1, on = .(ID, START &lt; TIME, END > TIME),  : column(s) not found: START </p>
  </blockquote>
  
  <p>So I had to use <code>dt2</code> as the <code>i</code> as a workaround:</p>
  
  <pre><code>#need to type out all the columns:
  dt1[dt2, on=.(ID, TIME&gt;START, TIME&lt;END), nomatch=0L, .(ID, TIME=x.TIME)]
  #using setNames
  dt1[dt2, on=.(ID, TIME&gt;START, TIME&lt;END), nomatch=0L, 
      setNames(mget(paste0("x.", cols1)), cols1)]
  </code></pre>
  
  <p>Or is this a simple case of my misunderstanding?</p>
  
  <p>References: </p>
  
  <ul>
  <li>Confusion arise from answering: <a href="https://stackoverflow.com/questions/56993606/r-compare-two-data-tables-by-row">r compare two data.tables by row</a></li>
  <li><a href="https://github.com/Rdatatable/data.table/issues/1700" rel="nofollow noreferrer">https://github.com/Rdatatable/data.table/issues/1700</a></li>
  <li><a href="https://github.com/Rdatatable/data.table/issues/1807" rel="nofollow noreferrer">https://github.com/Rdatatable/data.table/issues/1807</a></li>
  <li><a href="https://github.com/Rdatatable/data.table/pull/2706" rel="nofollow noreferrer">https://github.com/Rdatatable/data.table/pull/2706</a></li>
  <li><a href="https://github.com/Rdatatable/data.table/pull/3093" rel="nofollow noreferrer">https://github.com/Rdatatable/data.table/pull/3093</a></li>
  </ul>