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

Fixing bug on assigning with 0 row matches #2860

Merged
merged 4 commits into from
May 12, 2018
Merged

Conversation

MarkusBonsch
Copy link
Contributor

Closes #2829.
assign.c was modified to only throw error on 0 length RHS if >0 rows are to be updated.

  • No existing tests modified
  • 1 test added

@MarkusBonsch MarkusBonsch requested a review from mattdowle May 10, 2018 17:20
@codecov-io
Copy link

codecov-io commented May 10, 2018

Codecov Report

Merging #2860 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2860      +/-   ##
==========================================
+ Coverage   93.46%   93.47%   +<.01%     
==========================================
  Files          61       61              
  Lines       12352    12355       +3     
==========================================
+ Hits        11545    11549       +4     
+ Misses        807      806       -1
Impacted Files Coverage Δ
src/assign.c 94.48% <100%> (+0.17%) ⬆️
src/fread.c 97.95% <0%> (ø) ⬆️

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 c6fe8e0...46a4512. Read the comment docs.

@mattdowle mattdowle added this to the 1.11.4 milestone May 10, 2018
NEWS.md Outdated
@@ -4,7 +4,7 @@
### Changes in v1.11.3 (in development)

#### BUG FIXES

1. Fixed bug where assignment with 0 matching rows threw error [#2829](https://github.com/Rdatatable/data.table/issues/2829). Thanks to @cguill95 for reporting and to @MarkusBonsch for fixing.
Copy link
Member

Choose a reason for hiding this comment

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

How about this to reflect the nuance : "Empty RHS of := is no longer an error when the i clause returns no rows to assign to anyway, [#2829]..."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perfect, thanks! I have changed it in my latest commit.

src/assign.c Outdated
if (coln+1 <= oldncol) {
error("RHS of assignment to existing column '%s' is zero length but not NULL. If you intend to delete the column use NULL. Otherwise, the RHS must have length > 0; e.g., NA_integer_. If you are trying to change the column type to be an empty list column then, as with all column type changes, provide a full length RHS vector such as vector('list',nrow(DT)); i.e., 'plonk' in the new column.", CHAR(STRING_ELT(names,coln)));
if (coln+1 <= oldncol) {
if(numToDo > 0){ //fixes #2829
Copy link
Member

@mattdowle mattdowle May 11, 2018

Choose a reason for hiding this comment

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

It took me a while to grok numToDo, but yes. Looks good. Could it be one if rather than two?
if (coln+1<=oldncol && numToDo>0) { // numToDo fixes #2829. See test 1911

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It can be changed, but then the else if statement below needs modification: else if(coln+1 > oldncol && TYPEOF(thisvalue)!=VECSXP). I think, this makes sense and have implemented it in the latest commit.

@MarkusBonsch
Copy link
Contributor Author

AppVeyor complains about memory exhausted at test 1879.6. I guess this has nothing to do with my PR, but I don't know, how to retrigger the tests.

@jangorecki
Copy link
Member

@MarkusBonsch you have to access appveyor, when creating account and using authentication with github you should have permission to restart builds.

Copy link
Member

@jangorecki jangorecki left a comment

Choose a reason for hiding this comment

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

Only formatting related comments, looks good.

src/assign.c Outdated
error("RHS of assignment to existing column '%s' is zero length but not NULL. If you intend to delete the column use NULL. Otherwise, the RHS must have length > 0; e.g., NA_integer_. If you are trying to change the column type to be an empty list column then, as with all column type changes, provide a full length RHS vector such as vector('list',nrow(DT)); i.e., 'plonk' in the new column.", CHAR(STRING_ELT(names,coln)));
} else if (TYPEOF(thisvalue)!=VECSXP) { // list() is ok for new columns
if (coln+1 <= oldncol && numToDo > 0) { // numToDo > 0 fixes #2829, see test 1911
error("RHS of assignment to existing column '%s' is zero length but not NULL. If you intend to delete the column use NULL. Otherwise, the RHS must have length > 0; e.g., NA_integer_. If you are trying to change the column type to be an empty list column then, as with all column type changes, provide a full length RHS vector such as vector('list',nrow(DT)); i.e., 'plonk' in the new column.", CHAR(STRING_ELT(names,coln)));
Copy link
Member

Choose a reason for hiding this comment

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

we use 2 spaces indention

NEWS.md Outdated
@@ -4,6 +4,7 @@
### Changes in v1.11.3 (in development)

#### BUG FIXES
1. Empty RHS of := is no longer an error when the i clause returns no rows to assign to anyway, [#2829](https://github.com/Rdatatable/data.table/issues/2829). Thanks to @cguill95 for reporting and to @MarkusBonsch for fixing.
Copy link
Member

Choose a reason for hiding this comment

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

empty line should separate header and first item

@mattdowle mattdowle merged commit acca623 into master May 12, 2018
@MarkusBonsch MarkusBonsch deleted the emptyIassignBug branch October 4, 2018 23:15
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.

4 participants