Skip to content

distinct ignores rhs when there is a lhs (renaming result columns) #154

@sverchkov

Description

@sverchkov
library( dplyr, warn.conflicts = F )

df_tib <- tibble( a=c(1,1,2,2), b=c(1,2,1,2) )
df_sql <- dbplyr::memdb_frame( a=c(1,1,2,2), b=c(1,2,1,2) )

df_tib %>% distinct( x = a )
#> # A tibble: 2 x 1
#>       x
#>   <dbl>
#> 1     1
#> 2     2

res <- df_sql %>% distinct( x = a )
res %>% show_query()
#> <SQL>
#> SELECT `x`
#> FROM `bigofxlnjv`
#> GROUP BY `x`
res
#> Error in result_create(conn@ptr, statement): no such column: x

Created on 2018-09-06 by the reprex
package
(v0.2.0).

I think the correct translation is SELECT DISTINCT "a" AS "x".

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviordplyr verbs 🤖Translation of dplyr verbs to SQL

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions