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

Sql server count big #1501

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

* `across(everything())` doesn't select grouping columns created via `.by` in
`summarise()` (@mgirlich, #1493).
* Use `COUNT_BIG` instead of `COUNT` for SQL server so that `tally()` and
`count()` work regardless of size of the data (@edward-burn, #1498).

* New translations of clock function `date_count_between()` for SQL server, Redshift, Snowflake, Postgres, and Spark (@edward-burn, #1495).

Expand Down
1 change: 1 addition & 0 deletions R/backend-mssql.R
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ simulate_mssql <- function(version = "15.0") {
sql_variant(
mssql_scalar,
sql_translator(.parent = base_odbc_agg,
n = function() sql("COUNT_BIG(*)"),
sd = sql_aggregate("STDEV", "sd"),
var = sql_aggregate("VAR", "var"),
str_flatten = function(x, collapse = "") sql_expr(string_agg(!!x, !!collapse)),
Expand Down
32 changes: 32 additions & 0 deletions tests/testthat/_snaps/backend-mssql.md
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,38 @@
FROM `df`
ORDER BY `y`

# count_big

Code
dplyr::count(mf)
Output
<SQL>
SELECT COUNT_BIG(*) AS `n`
FROM `df`

---

Code
dplyr::tally(mf)
Output
<SQL>
SELECT COUNT_BIG(*) AS `n`
FROM `df`

# can copy_to() and compute() with temporary tables (#438)

Code
db <- copy_to(con, df, name = unique_table_name(), temporary = TRUE)
Message
Created a temporary table named #dbplyr_{tmp}

---

Code
db2 <- db %>% mutate(y = x + 1) %>% compute()
Message
Created a temporary table named #dbplyr_{tmp}

# add prefix to temporary table

Code
Expand Down
Loading