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

Support row_number() on Snowflake #1332

Closed
fh-mthomson opened this issue Jul 8, 2023 · 0 comments · Fixed by #1331
Closed

Support row_number() on Snowflake #1332

fh-mthomson opened this issue Jul 8, 2023 · 0 comments · Fixed by #1331

Comments

@fh-mthomson
Copy link
Contributor

Currently, simple row_number() queries (commonly used to filter/order by groups on remote tables) fail on Snowflake:

library(dplyr)
library(dbplyr)
mf <- lazy_frame(x = c(1:5), y = c(rep("A", 2), rep("A", 3)), con = simulate_snowflake())

mf %>% 
  mutate(rown = row_number())
#> <SQL>
#> SELECT `df`.*, ROW_NUMBER() OVER () AS `rown`
#> FROM `df`

mf %>% 
  filter(row_number() == 1)
#> <SQL>
#> SELECT `x`, `y`
#> FROM (
#>   SELECT `df`.*, ROW_NUMBER() OVER () AS `col01`
#>   FROM `df`
#> ) AS `q01`
#> WHERE (`col01` = 1.0)

Created on 2023-07-08 with reprex v2.0.2

On a live database:

> mf %>% 
+   filter(row_number() == 1)
Error in `collect()`:
! Failed to collect lazy table.
Caused by error:
! nanodbc/nanodbc.cpp:1526: 00000: SQL compilation error:
Window function type [ROW_NUMBER] requires ORDER BY in window specification. 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant