Skip to content

don't trust all.vars when its arguments contains get/eval#4982

Merged
mattdowle merged 4 commits intoRdatatable:masterfrom
IstraResearch:4981
May 9, 2021
Merged

don't trust all.vars when its arguments contains get/eval#4982
mattdowle merged 4 commits intoRdatatable:masterfrom
IstraResearch:4981

Conversation

@OfekShilon
Copy link
Copy Markdown
Contributor

@OfekShilon OfekShilon commented May 8, 2021

Closes #4873
Closes #4981
There are at least 2 other places in [.data.table that test for inclusion of get et.al. in an expression - I think they should use rapply too, but didn't touch it.

@codecov
Copy link
Copy Markdown

codecov bot commented May 8, 2021

Codecov Report

Merging #4982 (93247ec) into master (f5c6526) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #4982   +/-   ##
=======================================
  Coverage   99.45%   99.45%           
=======================================
  Files          73       73           
  Lines       14612    14615    +3     
=======================================
+ Hits        14532    14535    +3     
  Misses         80       80           
Impacted Files Coverage Δ
R/data.table.R 99.94% <100.00%> (+<0.01%) ⬆️

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 f5c6526...93247ec. Read the comment docs.

@OfekShilon
Copy link
Copy Markdown
Contributor Author

Note this solves #4873 too.

@mattdowle mattdowle added this to the 1.14.1 milestone May 9, 2021
@mattdowle mattdowle changed the title Fix #4981: don't trust all.vars when its arguments contains get/eval don't trust all.vars when its arguments contains get/eval May 9, 2021
@mattdowle
Copy link
Copy Markdown
Member

news item and addition to contributor list in 531be37

@mattdowle mattdowle merged commit e61905b into Rdatatable:master May 9, 2021
@mattdowle
Copy link
Copy Markdown
Member

@OfekShilon Many thanks. I invited you to be project member so amongst other things you can create branches in main repo in future. The invite is a button in your profile or projects page in github that you have to click to accept. Thanks again and welcome!

@jangorecki
Copy link
Copy Markdown
Member

There were no unit test for the second closed issue so I added them in follow up PR #4985

@OfekShilon
Copy link
Copy Markdown
Contributor Author

@mattdowle Thank you very much, I'll do my best to contribute. If I understand correctly - I'm not allowed to merge PRs, right? Also, what is the right place to ask such questions? (probably not in a PR comments)

@mattdowle
Copy link
Copy Markdown
Member

Just me (and Arun) who can merge currently, but that may expand to Jan and Michael in future.
Yes in PRs is fine to ask such questions. We like everything in public on GitHub wherever possible. The other option would be email.

Comment thread R/data.table.R
allbyvars = intersect(all.vars(bysub), names_x)
# Fix 4981: when the 'by' expression includes get/mget/eval, all.vars
# cannot be trusted to infer all used columns
bysub.elems <- rapply(as.list(bysub), as.character)
Copy link
Copy Markdown
Member

@mattdowle mattdowle May 9, 2021

Choose a reason for hiding this comment

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

This is failing R 3.1.0 with :

> af[, mean(a), by = "itime"]
Error in .Primitive("as.character")(list, ...) : 
  cannot coerce type 'builtin' to vector of type 'character'
Calls: [ -> [.data.table -> rapply
Execution halted

will fix ...

mattdowle added a commit that referenced this pull request May 9, 2021
@jangorecki jangorecki modified the milestones: 1.14.9, 1.15.0 Oct 29, 2023
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.

by sometimes fails when it invokes get get() in by and the inconsistent error

3 participants