-
Notifications
You must be signed in to change notification settings - Fork 182
Closed
Labels
bugan unexpected problem or unintended behavioran unexpected problem or unintended behaviorfunc trans 🌍Translation of individual functions to SQLTranslation of individual functions to SQLwipwork in progresswork in progress
Description
I'm running into an issue when using mutate and ifelse (or if) on a SQL Server backend. The following sample query:
df <- tbl(con, in_schema("schema", "table_name")) %>%
mutate(field = ifelse(field %in% c('test1', 'test2', 'test3'), 'string1', 'string2') %>%
collect()
... will give the following translation:
SELECT CASE WHEN (("field" IN ('test1', 'test2', 'test3')) = 'TRUE') THEN ('string1')
WHEN (("field" IN ('test1', 'test2', 'test3')) = 'FALSE') THEN ('string2')
END AS "field"
Which will return an error. The correct translation should be:
SELECT CASE WHEN ("field" IN ('test1', 'test2', 'test3')) THEN 'string1'
WHEN ("field" NOT IN ('test1', 'test2', 'test3')) THEN 'string2'
END AS "field"
Will correcting this in the mssql_if function create any issues in other queries, or is there a better way to do mutate(ifelse()) in mssql?
Line 225 in 477480e
mssql_sql_if <- function(cond, if_true, if_false = NULL) { |
Metadata
Metadata
Assignees
Labels
bugan unexpected problem or unintended behavioran unexpected problem or unintended behaviorfunc trans 🌍Translation of individual functions to SQLTranslation of individual functions to SQLwipwork in progresswork in progress