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

n_distinct with group_by produces incorrect SQL for MSSQL #1366

Closed
carlganz opened this issue Sep 18, 2023 · 1 comment · Fixed by #1431
Closed

n_distinct with group_by produces incorrect SQL for MSSQL #1366

carlganz opened this issue Sep 18, 2023 · 1 comment · Fixed by #1431
Labels
backend 🕺 bug an unexpected problem or unintended behavior func trans 🌍 Translation of individual functions to SQL

Comments

@carlganz
Copy link

library(dbplyr)

con_test <- simulate_mssql()

translate_sql(n_distinct(y), con = con_test, vars_group = "x")

Use of DISTINCT is not allowed with the OVER clause in MSSQL.

@hadley
Copy link
Member

hadley commented Nov 2, 2023

Minimal reprex:

library(dbplyr)

translate_sql(n_distinct(y), con = simulate_mssql(), vars_group = "x")
#> <SQL> COUNT(DISTINCT `y`) OVER (PARTITION BY `x`)

Created on 2023-11-02 with reprex v2.0.2

Not clear what we can do here except throw a clearer error message.

@hadley hadley added bug an unexpected problem or unintended behavior func trans 🌍 Translation of individual functions to SQL backend 🕺 labels Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend 🕺 bug an unexpected problem or unintended behavior func trans 🌍 Translation of individual functions to SQL
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants