Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.NATURAL join fails to re-use index #6667

Open
MichaelChirico opened this issue Dec 19, 2024 · 0 comments
Open

.NATURAL join fails to re-use index #6667

MichaelChirico opened this issue Dec 19, 2024 · 0 comments
Labels
joins Use label:"non-equi joins" for rolling, overlapping, and non-equi joins

Comments

@MichaelChirico
Copy link
Member

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
@MichaelChirico MichaelChirico added the joins Use label:"non-equi joins" for rolling, overlapping, and non-equi joins label Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
joins Use label:"non-equi joins" for rolling, overlapping, and non-equi joins
Projects
None yet
Development

No branches or pull requests

1 participant