diff --git a/R/backend-dbplyr__duckdb_connection.R b/R/backend-dbplyr__duckdb_connection.R index 6c4f390c4..32a4e07e0 100644 --- a/R/backend-dbplyr__duckdb_connection.R +++ b/R/backend-dbplyr__duckdb_connection.R @@ -79,6 +79,12 @@ duckdb_grepl <- function(pattern, x, ignore.case = FALSE, perl = FALSE, fixed = duckdb_n_distinct <- function(..., na.rm = FALSE) { sql <- pkg_method("sql", "dbplyr") + check_dots_unnamed <- pkg_method("check_dots_unnamed", "rlang") + + if (missing(...)) { + stop("`...` is absent, but must be supplied.") + } + check_dots_unnamed() if (!identical(na.rm, FALSE)) { stop("Parameter `na.rm = TRUE` in n_distinct() is currently not supported in DuckDB backend.", call. = FALSE) diff --git a/tests/testthat/test-backend-dbplyr__duckdb_connection.R b/tests/testthat/test-backend-dbplyr__duckdb_connection.R index 7254dba81..4db5c6eef 100644 --- a/tests/testthat/test-backend-dbplyr__duckdb_connection.R +++ b/tests/testthat/test-backend-dbplyr__duckdb_connection.R @@ -284,6 +284,7 @@ test_that("n_distinct() computations are correct", { on.exit(dbDisconnect(con, shutdown = TRUE)) tbl <- dplyr::tbl summarize <- dplyr::summarize + mutate <- dplyr::mutate pull <- dplyr::pull duckdb_register(con, "df", data.frame(x = c(1, 1, 2, 2), y = c(1, 2, 2, 2))) @@ -318,6 +319,11 @@ test_that("n_distinct() computations are correct", { pull(summarize(df_na, n = n_distinct(x, y)), n), 5 ) + + expect_equal( + pull(mutate(df_na, n = n_distinct(x, y)), n), + rep(5, 5) + ) })