Skip to content

duplicate colnames gives uninformative error when joining with tibbles  #3243

Description

@EdwinTh

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions