-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Make /
behave in SQL as it does in R
#1862
Comments
This just feels like a step too far to me. I can't put it precisely into words, but my intuition tells me its the wrong thing to do. |
I think this XKCD applies here too. That is, this is perhaps best left as a matter of documentation in the databases vignette (e.g., > tbl(pg, sql("SELECT 3 AS a, 2 AS b")) %>% mutate(c=a/b)
Source: postgres 9.6.0 [igow@localhost:5432/crsp]
From: <derived table> [?? x 3]
a b c
(int) (int) (int)
1 3 2 1
.. ... ... ... |
I would expect at least the basic operators to behave identically in all backends. However, if we change the behavior now, it's a truly breaking change: It affects both the results and the data type of the output of a division, and also all operations that are based on the result. How about introducing and supporting a new |
I think this may just be a matter of dividing the world into SQL and non-SQL backends. In SQL,
(Note that Of course,
|
It's simply not possible for all operators to act identically - even basic things like mean and sum work differently. This is a delicate balancing act, but I just don't think it's worth it in this case. |
I thought it's possible at least for operators, but perhaps not. How about printing a message if a backend's behavior is |
I'm not sure even that's true - consider NA vs NaN vs NULL etc. Are the semantics always going to be identical? |
Correct roundtrip should be done by the DBI backends. There are still rough edges, but I think valid input should give correct output, or warn. With sum() and mean(): Here, a message could appear if the user doesn't explicitly state na.rm = TRUE, but that's probably overkill. |
See #1799 (now closed).
There we discussed the fact that
/
will behave differently in SQL from how it behaves in R. This breaks a nice feature ofdplyr
, which is that analysis can be moved from R to SQL as it proceeds with little or no changes to code. I suggested that/
should get translated so as to behave the same in both places:@hadley responded: "Hmmm, that's not a bad idea, but what should it get translated to?"
I suggested that translating
/
as%* 1.0 /%
might work:I'm not sure if it was intended to close this issue along with the original "too esoteric" issue from #1799, so I am making this a new one (perhaps to be closed again) just in case.
The text was updated successfully, but these errors were encountered: