-
Notifications
You must be signed in to change notification settings - Fork 982
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
"nomatch is ignored with :=" warning is misleading #2180
Comments
Do you have a better example? Using I'm just chiming in because I like seeing that warning and don't see any convincing reason to scrap it (by taking out the key "not relevant" and "ignoring" parts). Maybe something could be added to it, but it's not clear to me what that might be. |
Sure, that was just a minimal reproducible example of the difference between the two; I agree it doesn't make any sense. Here are three examples of what I imagine are real use-cases.
Unnecessary cycles:
Dangerous hidden bug:
|
@rballentine Ok, I get it now, thanks. I would lean more towards saying Side note:
is a risky operation, since when there are multiple matches of X to a single row of DT, only one match can be selected (apparently the final match is used right now). For example:
or the same thing is seen when it's all done inside |
I am uncertain if this relates to the topic, but have been confused why adding the nomatch argument in conjunction with an anti-join produces errors unstead of warnings. Examples:
For situation (1) at worst isn't nomatch = 0 merely redundent? Additionally, is there an argument to be made that situation (2)' nomatch = NA should actually return all the matched 'X' within 'DT' without any joined columns from 'X'? Really, my only issue is with (1) because it slows down interactive programming. |
Starting in v1.9.8 this warning appears when using := with nomatch=0:
However, when I removed all the nomatch=0 from := calls in my code it caused me some issues. So I thought it was worth pointing out that the warning is not strictly true (nomatch might still be relevant in := calls; nomatch is not ignored). An illustrative example run on v1.10.4:
Above, the resulting data.table is the same, but nomatch controls whether the elimination of unmatched rows occurs in j or only on assignment. This can be relevant: it caused problems in my code when I used vectors in j that weren't in either data.table (x or i). For example:
Thus there remains a use case for using nomatch=0 with :=, and I don't think users should be told that it is not relevant (and definitely shouldn't be told that it is ignored). Could lead to hard-to-find problems if people assume, like I did, that there are no possible repercussions to removing nomatch=0 where := appears in their code.
The text was updated successfully, but these errors were encountered: