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

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

Closed
sverchkov opened this issue Sep 6, 2018 · 6 comments
Milestone

Comments

@sverchkov
Copy link
Contributor

@sverchkov sverchkov commented Sep 6, 2018

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".

@edgararuiz

This comment was marked as resolved.

Copy link
Collaborator

@edgararuiz edgararuiz commented Sep 20, 2018

Hi @sverchkov , what is the difference between this issue and #161?

@sverchkov

This comment was marked as resolved.

Copy link
Contributor Author

@sverchkov sverchkov commented Sep 21, 2018

No difference.

@hadley hadley added this to the v1.4.0 milestone Jan 9, 2019
@hadley

This comment has been minimized.

Copy link
Member

@hadley hadley commented Jan 10, 2019

Needs dplyr:::distinct_vars() to be exported first

@hadley

This comment has been minimized.

Copy link
Member

@hadley hadley commented Mar 13, 2019

Now called distinct_prepare(). Will need bump to dplyr 0.8.0.

@hadley

This comment has been minimized.

Copy link
Member

@hadley hadley commented Mar 14, 2019

Nope, not worth it — distinct_prepare() assumes too much about the data frame, and it'll be easiest to reimplement in dbplyr.

@hadley hadley closed this in 3bfecdf Mar 14, 2019
@hadley

This comment has been minimized.

Copy link
Member

@hadley hadley commented Mar 14, 2019

The fix is suspiciously simple, but seems to work 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.