Skip to content

allow.cartesian when i has no duplicate values #742

Closed

Description

@nigmastar

Please consider the following:

> dt <- data.table(id=rep(letters[1:2], 2), var = rnorm(4), key="id")
> dt
   id       var
1:  a 0.9609685
2:  a 0.1432707
3:  b 1.1276582
4:  b 0.8051821

> dt[letters[1:3], list(var)]
Error in vecseq(f__, len__, if (allow.cartesian) NULL else as.integer(max(nrow(x),  : 
  Join results in 5 rows; more than 4 = max(nrow(x),nrow(i)). Check for duplicate key values in i, each of which join to the same group in x over and over again. [...]

> dt[letters[1:3], list(var), by=.EACHI]
   id       var
1:  a 0.9609685
2:  a 0.1432707
3:  b 1.1276582
4:  b 0.8051821
5:  c        NA

The second join results in 5 rows too, shouldn't both joins above be consistent? (Maybe both like the second)

I also wander, the concept behind the implementation of allow.cartesian is simply 1) output rows has not to be more than max(nrow(x),nrow(i)) or 2) to avoid duplicates in key values of i?

> sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
# data.table installed today from github

Activity

  1. arunsrinivasan commented on Jul 26, 2014

    @arunsrinivasan
    Member

    Thanks @nigmastar. We'll take a look at this asap.

    Regarding your last question: I think this SO post should help.

  2. added this to the v1.9.4 milestone on Jul 26, 2014
  3. nigmastar commented on Jul 27, 2014

    @nigmastar
    Author

    Hi Arun,

    thanks for the link. It helped. So, (besides what you say in the link about the error only for 'huge' results) don't you think that when i has no duplicates, like above, no error should be thrown?

    Thanks,

    Michele.

  4. arunsrinivasan commented on Jul 27, 2014

    @arunsrinivasan
    Member

    There've been quite a few issues filed on this topic now. Without giving too much thought, it does appear to me that i having no duplicates need not provide an error.

    Bumping all allow.cartesian=. issues to 1.9.4 milestone.

  5. mgriebe commented on Aug 14, 2014

    @mgriebe

    Maybe the error can mention "nomatch=0" as a possible solution.

  6. modified the milestones: , on Sep 6, 2014
  7. added
    joins
    on Apr 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Highbugjoins

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions