Skip to content

Non-equi join results in misleading variable names #2307

Description

@aleks-via

Hi,

I've run into the following unexpected issue...

I am trying to join sales to shifts here by timestamp.

sales = data.table( sale_id = 1:5, sale_ts = (1:5)*5 )
shifts = data.table( shift_id= 21:23, shift_start = c(1,10,15), shift_end=c(9,14,19) )

sales[shifts, on=.(sale_ts>=shift_start, sale_ts<shift_end) ]

returns

   sale_id sale_ts sale_ts.1 shift_id
1:       1       1         9       21
2:       2      10        14       22
3:       3      15        19       23

This is misleading because the timestamps that are returned are not sale timestamps at all, but shift timestamps. I realize that reversing the code to do shifts[sales ... will give more appropriate results, but I'm likely not the only one confused by the behavior of the former formulation and possibly not the only one for whom this behavior resulted in some headache.

Thanks!

Activity

  1. Henrik-P commented on Aug 17, 2017

    @Henrik-P
  2. aleks-via commented on Aug 17, 2017

    @aleks-via
    Author

    Yes, essentially the same issue as #1807 and a couple others. I hadn't done a good enough job searching. Closing as duplicate.

    I do think since base merge doesn't support non-equi joins, it made sense there, but I think the SQL naming conventions make more sense for data.table.

  3. added this to the milestone on Apr 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions