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

duplicate colnames gives uninformative error when joining with tibbles #3243

Closed
EdwinTh opened this issue Dec 7, 2017 · 1 comment
Closed
Labels

Comments

@EdwinTh
Copy link

@EdwinTh EdwinTh commented Dec 7, 2017

Tibbles don't allow for duplicate column names at creation:

> data_frame(x = 1:2, x = 3:4)
Error: Column `x` must have a unique name

The _join functions throw informative errors when join key is duplicate and x is a regular data.frame

> x <- data.frame(x = 1:2, x = 3:4)
> colnames(x) <- c("x", "x")
> inner_join(x, data.frame(x = 1:2))
Error: Column `x` must have a unique name

However, via the same back door the column names of a tibble can get duplicated. When trying to join then the error is no longer informative.

> x <- data_frame(x = 1:2, x2 = 3:4 )
> colnames(x) <- c("x", "x")
> inner_join(x, data_frame(x = 1:2))
Joining, by = "x"
Error in inner_join_impl(x, y, by$x, by$y, suffix$x, suffix$y, check_na_matches(na_matches)) : 
   Column `` is unknown

If possible, I think the best option here is close the back door route and throw an error at the second line of the last code block. Otherwise an informative error seems desired.

@krlmlr
Copy link
Member

@krlmlr krlmlr commented Dec 12, 2017

Thanks. I think we should check our inputs more stringently, and stop if we encounter a data frame with duplicate names. (We can't entirely prohibit the creation of data frames with duplicate column names.) But this breaking will require some time and planning. In the meantime, I agree that this particular error message should be improved.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants