# Query.@join with repeated names

**URL:** <https://discourse.julialang.org/t/query-join-with-repeated-names/23474>\
**Category:** Data\
**Tags:** query\
**Created:** [April 24, 2019, 2:05pm UTC](https://discourse.julialang.org/t/query-join-with-repeated-names/23474 "2019-04-24T14:05:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)\
**Post date:** [April 24, 2019, 2:05pm UTC](https://discourse.julialang.org/t/query-join-with-repeated-names/23474/1 "2019-04-24T14:05:04Z")

</div>

Say I have this:

```julia
julia> df1 = DataFrame(id=[1,2,3,4], a=[1.,2.,3.,4.])
4×2 DataFrame
│ Row │ id │ a │
│ │ Int64 │ Float64 │
├─────┼───────┼─────────┤
│ 1 │ 1 │ 1.0 │
│ 2 │ 2 │ 2.0 │
│ 3 │ 3 │ 3.0 │
│ 4 │ 4 │ 4.0 │

julia> df2 = DataFrame(id=[1,3,4], b=["one", "thre","four"])
3×2 DataFrame
│ Row │ id │ b │
│ │ Int64 │ String │
├─────┼───────┼────────┤
│ 1 │ 1 │ one │
│ 2 │ 3 │ thre │
│ 3 │ 4 │ four │

```

I can join them with Query.jl as follows:

```julia
julia> df1 |> @join(df2, _.id, _.id, {_.id, _.a, __.b}) |> DataFrame
3×3 DataFrame
│ Row │ id │ a │ b │
│ │ Int64 │ Float64 │ String │
├─────┼───────┼─────────┼────────┤
│ 1 │ 1 │ 1.0 │ one │
│ 2 │ 3 │ 3.0 │ thre │
│ 3 │ 4 │ 4.0 │ four │

```

But if in `df2` the last column bears the same names as `df1` — i.e. `a`, this does not work because the names are repeated. This is managed by `DataFrames.join` with the keyword argument `makeunique`, such that with that new `df2` I get:

```julia
julia> join(df1, df2, on=:id, makeunique=true)
3×3 DataFrame
│ Row │ id │ a │ a_1 │
│ │ Int64 │ Float64 │ String │
├─────┼───────┼─────────┼────────┤
│ 1 │ 1 │ 1.0 │ one │
│ 2 │ 3 │ 3.0 │ thre │
│ 3 │ 4 │ 4.0 │ four │

```

However I like the possibility of selecting columns provided by `Query.@join`. Is there something similar in Query to handle repeated column names?

---

<div class="post-metadata">

**Author:** ![mcabbott](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcabbott/32/6603_2.png) [@mcabbott](https://discourse.julialang.org/u/mcabbott)\
**Post date:** [April 24, 2019, 5:39pm UTC](https://discourse.julialang.org/t/query-join-with-repeated-names/23474/2 "2019-04-24T17:39:04Z")

</div>

This would be nice, I made an issue for this: [https://github.com/queryverse/Query.jl/issues/250](https://github.com/queryverse/Query.jl/issues/250)
