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

broken SQL translation for is.na #1695

Closed
piccolbo opened this issue Mar 8, 2016 · 1 comment
Closed

broken SQL translation for is.na #1695

piccolbo opened this issue Mar 8, 2016 · 1 comment
Milestone

Comments

@piccolbo
Copy link

piccolbo commented Mar 8, 2016

dplyr::translate_sql_q(quote(!is.na(if (w > 0) w)))

returns

<SQL> "!"
<SQL> CASE WHEN "w" > 0.0 THEN "w" ENDIS NULL

The keyword ENDIS is not part of any SQL dialect I know of and it seems like a space fell through the cracks.
Comparing the defs for is.na and is.null in base_scalar seems to confirm the hypothesis

Browse[2]> base_scalar$`is.na`
function (x) 
{
    build_sql(x, "IS NULL")
}
<environment: namespace:dplyr>
Browse[2]> base_scalar$`is.null`
function (x) 
{
    build_sql(x, " IS NULL")
}
<environment: namespace:dplyr>
@hadley hadley added the database label Mar 8, 2016
@hadley hadley added this to the 0.5 milestone Mar 8, 2016
@hadley hadley closed this as completed in ef923b6 Mar 9, 2016
@hadley
Copy link
Member

hadley commented Mar 9, 2016

I now get:

translate_sql(!is.na(if (x) y else z))
#> <SQL> NOT((CASE WHEN ("x") THEN ("y") ELSE ("z") END) IS NULL)

I think that's more likely to parse correctly.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants