-
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
pmin and pmax fail in mutate connected to SQL Server #3227
Comments
You're correct, |
@edgararuiz, You guys could take the approach I used for Access. It only works for two columns, but that is the most common case. # pmin/pmax for 2 columns
pmin = function(x, y) {
sql_expr(iif(UQ(x) <= UQ(y), !!x, !!y))
},
pmax = function(x, y) {
sql_expr(iif(UQ(x) <= UQ(y), !!y, !!x))
}, |
@DavisVaughan: Macro expansion is a slippery slope, what if Out of curiosity: Which databases actually support pairwise |
You're right, we would enable it only for those who support it. I believe can also do |
For completeness, Postgres and MySQL have Docs for Postgres at the bottom here Docs for MySQL here A stack overflow Q/A confirming the equivalence of Postgres |
Let's remove it from the default translation, and add to Postgres, MySQL, and SQLite. Is it worth making the default translation an error? |
If we don't translate |
This issue was moved by krlmlr to tidyverse/dbplyr/issues/118. |
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/ |
Occasionally, I will need to use pmin or pmax to replace values above or below a threshold, for instance:
However, when I use dbplyr to try and do this using a SQL Server table, I get the following error:
As you can see, the SQL code generator assumes that I want to do a pairwise MAX, however SQL Server does not support that (only taking the maximum over a single column).
A cursory Stack Overflow search suggests that to do this operation a case statement could be used. I think either the SQL code generator should either be updated to do this, or an error should be generated at the time of calling the mutate.
The text was updated successfully, but these errors were encountered: