Skip to content

Fix non-equi join error with equi + 2 inequality conditions (#7641)#7642

Merged
ben-schwen merged 2 commits intoRdatatable:masterfrom
tarun-t:fix-nonequi-join-rightcols-7641
Feb 18, 2026
Merged

Fix non-equi join error with equi + 2 inequality conditions (#7641)#7642
ben-schwen merged 2 commits intoRdatatable:masterfrom
tarun-t:fix-nonequi-join-rightcols-7641

Conversation

@tarun-t
Copy link
Contributor

@tarun-t tarun-t commented Feb 14, 2026

Summary

Fixes #7641. Non-equi joins combining an equality condition with two inequality conditions on the same column (e.g., on = .(id == id, val >= lo, val <= hi)) error on
1.18.0+ due to rightcols being overwritten by chmatchdup.

When rightcols has duplicates (same x column in multiple conditions), chmatchdup remaps them into the expanded result namespace nx. This overwrote rightcols,
causing downstream code (.shallow(x, rightcols) in .join_result_key) to reference columns beyond ncol(x).

Fix: Introduce ansrightcols for the remapped indices, keep rightcols as original column indices into x. Only icolsAns needs the remapped values; all other
downstream uses need the original x-relative indices.

Changes

  • R/data.table.R: Replace rightcols = chmatchdup(...) with ansrightcols = chmatchdup(...), use ansrightcols only for icolsAns
  • inst/tests/tests.Rraw: Regression test (1483.91)
  • NEWS.md: Bug fix entry

…le#7641)

When rightcols contains duplicates (same x column in multiple non-equi
conditions), chmatchdup remaps them into the expanded result namespace.
This overwrote rightcols, causing downstream code (e.g. .shallow(x, rightcols)
in .join_result_key) to reference columns beyond ncol(x).

Introduce ansrightcols for the remapped indices and keep rightcols as
original column indices into x. Only icolsAns needs the remapped values;
all other uses (xcols, names_x[rightcols], .join_result_key) need the
original x-relative indices.

Closes Rdatatable#7641
@codecov
Copy link

codecov bot commented Feb 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.02%. Comparing base (1bd88cb) to head (b8ba178).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7642   +/-   ##
=======================================
  Coverage   99.02%   99.02%           
=======================================
  Files          87       87           
  Lines       16896    16897    +1     
=======================================
+ Hits        16732    16733    +1     
  Misses        164      164           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ben-schwen
Copy link
Member

Basically LGTM. If you could thank yourself in the NEWS and add your name as contributor to DESCRIPTION, I can merge.

@aitap aitap added this to the 1.18.4 milestone Feb 18, 2026
Per reviewer request: thank reporter in NEWS.md and add
Tarun Thammisetty as contributor to DESCRIPTION.
@ben-schwen ben-schwen merged commit 67e7840 into Rdatatable:master Feb 18, 2026
11 of 12 checks passed
@ben-schwen
Copy link
Member

TY! @tarun-t I have invited you to become a project member of the Rdatatable organization. This makes feature PRs easier and also enables the atime jobs. Thank you for your contribution!

@tarun-t
Copy link
Contributor Author

tarun-t commented Feb 18, 2026

Thank you for the invite!

aitap pushed a commit that referenced this pull request Feb 18, 2026
* Fix non-equi join error with equi + 2 inequality conditions (#7641)

When rightcols contains duplicates (same x column in multiple non-equi
conditions), chmatchdup remaps them into the expanded result namespace.
This overwrote rightcols, causing downstream code (e.g. .shallow(x, rightcols)
in .join_result_key) to reference columns beyond ncol(x).

Introduce ansrightcols for the remapped indices and keep rightcols as
original column indices into x. Only icolsAns needs the remapped values;
all other uses (xcols, names_x[rightcols], .join_result_key) need the
original x-relative indices.

Closes #7641

* Add contributor credit in DESCRIPTION and NEWS

Per reviewer request: thank reporter in NEWS.md and add
Tarun Thammisetty as contributor to DESCRIPTION.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Non-equi join with equi + 2 inequality conditions errors on 1.18.0+ (worked on 1.17.x)

3 participants

Comments