.NATURAL join fails to re-use index

Open
#6,667 3 comments 0 reactions 1 assignee View on GitHub

@aam936 is already working on this.

Since Apr 7, 2026.

Assessment

This issue has not been assessed yet.

Description

joins
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
Dominant language
R
Stars
3.9k
Forks
1.1k
Avg merge
14h 4m
Merged PRs (30d)
4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Rdatatable/data.table

All issues in Rdatatable/data.table

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.