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

(some?) eval expressions have issues with := #1181

Closed
eantonya opened this issue Jun 17, 2015 · 2 comments · Fixed by #4361
Closed

(some?) eval expressions have issues with := #1181

eantonya opened this issue Jun 17, 2015 · 2 comments · Fixed by #4361
Labels
bug Low non-atomic column e.g. list columns, S4 vector columns programming parameterizing queries: get, mget, eval, env
Milestone

Comments

@eantonya
Copy link
Contributor

dt1 = data.table(a = 1, key = 'a')
dt2 = data.table(c = 1, fn = list(quote(5*a)), key = 'c')

# this works
dt1[, eval(dt2[a]$fn[[1]], .SD)]
[1] 5

# this doesn't
dt1[, n := eval(dt2[a]$fn[[1]], .SD)]
#Error in eval(expr, envir, enclos) : object 'a' not found

Relevant SO post - http://stackoverflow.com/a/30899285/817778

@arunsrinivasan arunsrinivasan added this to the v1.9.8 milestone Sep 22, 2015
@arunsrinivasan arunsrinivasan modified the milestones: v2.0.0, v1.9.8 Nov 17, 2015
@mattdowle mattdowle removed this from the Candidate milestone May 10, 2018
@jangorecki
Copy link
Member

This is very similar to #1180 but looks to be resolved already

dt1 = data.table(a = 1, key = 'a')
dt2 = data.table(c = 1, fn = list(quote(5*a)), key = 'c')
dt1[, n := eval(dt2[a]$fn[[1]], .SD)][] 
#       a     n
#1:     1     5

To be closed by adding unit test to prevent future regression.

@jangorecki jangorecki added this to the 1.12.9 milestone Mar 22, 2020
@jangorecki jangorecki added the programming parameterizing queries: get, mget, eval, env label Apr 5, 2020
jangorecki added a commit that referenced this issue Apr 7, 2020
@jangorecki jangorecki added the non-atomic column e.g. list columns, S4 vector columns label Apr 7, 2020
@mattdowle mattdowle modified the milestones: 1.13.1, 1.13.3 Oct 17, 2020
@mattdowle mattdowle modified the milestones: 1.14.1, v1.9.8 May 21, 2021
@mattdowle
Copy link
Member

mattdowle commented May 21, 2021

Thanks @eantonya. Bisect testing showed it was fixed in v1.9.8 (Nov 2016), likely bug fix 16 for #880 :

  1. DT[, LHS := RHS] with RHS is of the form eval(parse(text = foo[1])) referring to columns in DT is now handled properly. Closes #880. Thanks to tyner.

PR #4361 adds your example to the test suite for completeness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Low non-atomic column e.g. list columns, S4 vector columns programming parameterizing queries: get, mget, eval, env
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants