Skip to content

tally() returns incorrect result on database table with n variable #3075

@JohnMount

Description

@JohnMount

dbplyr issue: dplyr::tally() results on database different than on data.frame. This is a very low priority for me as I do not use tally().

suppressPackageStartupMessages(library("dplyr"))
packageVersion("dplyr")
#> [1] '0.7.2.9000'
library("sparklyr")
packageVersion("sparklyr")
#> [1] '0.6.2'
packageVersion("dbplyr")
#> [1] '1.1.0.9000'
packageVersion("DBI")
#> [1] '0.7'

db <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")

dLocal <- data.frame(n = 1:3)
print(dLocal)
#>   n
#> 1 1
#> 2 2
#> 3 3

dRemote <- dplyr::copy_to(db, dLocal)
print(dRemote)
#> # Source:   table<dLocal> [?? x 1]
#> # Database: sqlite 3.19.3 [:memory:]
#>       n
#>   <int>
#> 1     1
#> 2     2
#> 3     3


tally(dLocal)
#> Using `n` as weighting variable
#>   nn
#> 1  6

tally(dRemote)
#> # Source:   lazy query [?? x 1]
#> # Database: sqlite 3.19.3 [:memory:]
#>      nn
#>   <int>
#> 1     3

DBI::dbDisconnect(db)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorverbs 🏃‍♀️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions