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

fix incorrect key when one and only one NA is at the beginning #3443

Merged
merged 3 commits into from
Mar 6, 2019

Conversation

jangorecki
Copy link
Member

@jangorecki jangorecki commented Mar 5, 2019

closes #3441.
Adds some overhead to C isOrderedSubset function which is called in few places, so best to confirm there is no faster way. And that it is the proper way to solve that at all.

@jangorecki jangorecki added this to the 1.12.2 milestone Mar 5, 2019
R/data.table.R Outdated
if (keylen && (ichk || is.logical(i) || (.Call(CisOrderedSubset, irows, nrow(x)) && ((roll == FALSE) || length(irows) == 1L)))) # see #1010. don't set key when i has no key, but irows is ordered and roll != FALSE
if (keylen && (
ichk || is.logical(i) || (
.Call(CisOrderedSubset, irows, nrow(x)) && !missingroll && ( # !missingroll fix for #3441
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might not be clear due to reformatting... only !missingroll has been added here

@jangorecki jangorecki changed the title join retain key, roll branch only when non missing roll arg, closes #… [WIP] join retain key, roll branch only when non missing roll arg, closes #… Mar 5, 2019
@@ -1248,17 +1248,21 @@ SEXP isOrderedSubset(SEXP x, SEXP nrow)
// specialized for use in [.data.table only
// Ignores 0s but heeds NAs and any out-of-range (which result in NA)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what was designed behaviour for NA based on that comment? it it will return FALSE for any NA, which solves the issue, and does not break any tests

Copy link
Member

@mattdowle mattdowle Mar 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The behaviour intended was to heed NAs; meaning NAs anywhere should return FALSE. It was getting it wrong then when there is one NA at the beginning. Good spot and fix.

@jangorecki jangorecki changed the title [WIP] join retain key, roll branch only when non missing roll arg, closes #… do not retain key when should not Mar 5, 2019
@codecov
Copy link

codecov bot commented Mar 5, 2019

Codecov Report

Merging #3443 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3443      +/-   ##
==========================================
+ Coverage   95.11%   95.13%   +0.02%     
==========================================
  Files          65       65              
  Lines       12310    12303       -7     
==========================================
- Hits        11709    11705       -4     
+ Misses        601      598       -3
Impacted Files Coverage Δ
src/forder.c 99.71% <100%> (-0.01%) ⬇️
R/test.data.table.R 97.81% <0%> (+2.06%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0bf0e33...87b9233. Read the comment docs.

@mattdowle mattdowle changed the title do not retain key when should not fix incorrect key when one and only one NA is at the beginning Mar 5, 2019
@mattdowle mattdowle merged commit aa0d85c into master Mar 6, 2019
@mattdowle mattdowle deleted the join-key-edge-case-fix branch March 6, 2019 00:09
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.

Joining a keyed table on a non-keyed table is not working sometimes
2 participants