You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some SQL engines (namely Oracle) do not support currently generated SQL for window functions where more partitions or order by expressions are used, for example:
win_test <- data.frame(A = c('a', 'a', 'b', 'b', 'c', 'c'),
B = c('d', 'd', 'd', 'e', 'e', 'e'),
C = c(1:6)
)
copy_to(my_db, win_test, name = 'WIN_TEST')
win_test_ora <- tbl(my_db, from = 'WIN_TEST')
x <- mutate(group_by(win_test_ora, A, B),
leadf = order_by(c(A, C), lead(A, 1, 'x'))
)
This generates SQL:
<SQL>
SELECT "A", "B", "C", "leadf"
FROM (SELECT "A", "B", "C", LEAD("A", 1.0, 'x') OVER (PARTITION BY ("A", "B") ORDER BY ("A", "C") AS "leadf"
FROM "WIN_TEST") "_W17"
The only issue is that parentheses are used to enclose each set of expressions. This performed by sql_vector function.
The text was updated successfully, but these errors were encountered:
Greenplum acts the same way. My current approach is to fork dplyr on github and modify the sql_vector() to parens=FALSE for the partition and order vectors. As you mention this seems to be the only issue. Not ideal but I've not been able to find a better temporary fix. Also, Greenplum is built off of Postgres so I'm a bit surprised that the syntax is different. Would postgres work without the parentheses?
mtcars2 <- copy_to(src_postgres(), mtcars)
Test <- group_by(mtcars2,cyl,gear) %>%
arrange(mpg) %>%
mutate(low=first(mpg))
Test$query
Test
But if I add parens=FALSE via fixInNamespace(over,'dplyr') the following runs as expected.
Some SQL engines (namely Oracle) do not support currently generated SQL for window functions where more partitions or order by expressions are used, for example:
This generates SQL:
The only issue is that parentheses are used to enclose each set of expressions. This performed by
sql_vector
function.The text was updated successfully, but these errors were encountered: