Skip to content

.NATURAL join fails to re-use index #6667

@MichaelChirico

Description

@MichaelChirico
DT = data.table(a=1)
setindex(DT, a)
l = list(a = 1)
DT[l, on=.NATURAL, verbose=TRUE]

Has output:

Joining but 'x' has no key, natural join using all 'x' columnsi.a has same type (double) as x.a. No coercion needed.
on= matches existing index, using index
Starting bmerge ...
forder.c received 1 rows and 1 columns
forderReuseSorting: opt=-1, took 0.000s
bmerge: looping bmerge_r took 0.000s
bmerge: took 0.000s
bmerge done in 0.000s elapsed (0.000s cpu)
Constructing irows for '!byjoin || nqbyjoin' ... 0.000s elapsed (0.000s cpu) 
       a
   <num>
1:     1

A simple change gets us the more efficient join, we shouldn't have to do this:

DT[l, on=names(l), verbose=TRUE]
i.a has same type (double) as x.a. No coercion needed.
on= matches existing index, using index
Starting bmerge ...
forder.c received 1 rows and 1 columns
forderReuseSorting: opt=-1, took 0.000s
bmerge: looping bmerge_r took 0.000s
bmerge: took 0.000s
bmerge done in 0.001s elapsed (0.000s cpu)
Constructing irows for '!byjoin || nqbyjoin' ... 0.000s elapsed (0.000s cpu) 
       a
   <num>
1:     1

Metadata

Metadata

Assignees

No one assigned

    Labels

    joinsUse label:"non-equi joins" for rolling, overlapping, and non-equi joins

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions