镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

.NATURAL join fails to re-use index #6667

Open

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

Activity

  1. added
    joinsUse label:"non-equi joins" for rolling, overlapping, and non-equi joins
    on Dec 19, 2024
  2. aam936 commented on Apr 6, 2026

    @aam936

    I will take this issue

  3. aam936 commented on Apr 28, 2026

    @aam936

    Are you saying that you want to change the joining method from intersect() to bmerge() , or something else?

  4. jangorecki commented on Apr 29, 2026

    @jangorecki
    Member

    It still needs to be intersect but .NATURAL keyword has to be unpacked early enough for joining to detect columns used

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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