Closed
Description
There is an issue when slice_*
calls are translated to SQL when the order_by
parameter uses .data$
notation rather than a bare symbol name. The generated SQL erroneously prefixes .data to the order by clause, which causes the query to fail.
# Expected behaviour (using local df)
mtcars %>%
group_by(.data$cyl) %>%
slice_max(.data$mpg)
# Returns 1 row per group, ordered by MPG
# Observed behaviour (fails)
rem_mtcars <- copy_to(connection, mtcars)
rem_mtcars %>%
group_by(.data$cyl) %>%
slice_max(.data$mpg)
# This works
rem_mtcars %>%
group_by(.data$cyl) %>%
slice_max(mpg)
An example of the generated SQL is
ROW_NUMBER() OVER (PARTITION BY "cyl" ORDER BY ".data"."mpg" DESC)
The translation works fine when using arrange
, it is only for the window functions I have observed the issue.
I've tested this with Redshift and SQLite with the same output.
Metadata
Metadata
Assignees
Labels
No labels