Skip to content

Commit f4db95f

Browse files
authored
Remove type parameters in DataFrameJoiner (#2503)
1 parent e160eb7 commit f4db95f

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

src/abstractdataframe/join.jl

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ const OnType = Union{SymbolOrString, NTuple{2,Symbol}, Pair{Symbol,Symbol},
1010
Pair{<:AbstractString, <:AbstractString}}
1111

1212
# helper structure for DataFrames joining
13-
struct DataFrameJoiner{DF1<:AbstractDataFrame, DF2<:AbstractDataFrame}
14-
dfl::DF1
15-
dfr::DF2
16-
dfl_on::DF1
17-
dfr_on::DF2
13+
struct DataFrameJoiner
14+
dfl::AbstractDataFrame
15+
dfr::AbstractDataFrame
16+
dfl_on::AbstractDataFrame
17+
dfr_on::AbstractDataFrame
1818
left_on::Vector{Symbol}
1919
right_on::Vector{Symbol}
2020

21-
function DataFrameJoiner{DF1, DF2}(dfl::DF1, dfr::DF2,
22-
on::Union{<:OnType, AbstractVector}) where {DF1, DF2}
21+
function DataFrameJoiner(dfl::AbstractDataFrame, dfr::AbstractDataFrame,
22+
on::Union{<:OnType, AbstractVector})
2323
on_cols = isa(on, AbstractVector) ? on : [on]
2424
left_on = Symbol[]
2525
right_on = Symbol[]
@@ -45,10 +45,6 @@ struct DataFrameJoiner{DF1<:AbstractDataFrame, DF2<:AbstractDataFrame}
4545
end
4646
end
4747

48-
DataFrameJoiner(dfl::DF1, dfr::DF2, on::Union{<:OnType, AbstractVector}) where
49-
{DF1<:AbstractDataFrame, DF2<:AbstractDataFrame} =
50-
DataFrameJoiner{DF1,DF2}(dfl, dfr, on)
51-
5248
# helper map between the row indices in original and joined table
5349
struct RowIndexMap
5450
"row indices in the original table"

src/dataframerow/utils.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ end
345345

346346
# Find index of a row in gd that matches given row by content, 0 if not found
347347
function findrow(gd::RowGroupDict,
348-
df::DataFrame,
348+
df::AbstractDataFrame,
349349
gd_cols::Tuple{Vararg{AbstractVector}},
350350
df_cols::Tuple{Vararg{AbstractVector}},
351351
row::Int)
@@ -370,7 +370,7 @@ end
370370
# Find indices of rows in 'gd' that match given row by content.
371371
# return empty set if no row matches
372372
function findrows(gd::RowGroupDict,
373-
df::DataFrame,
373+
df::AbstractDataFrame,
374374
gd_cols::Tuple{Vararg{AbstractVector}},
375375
df_cols::Tuple{Vararg{AbstractVector}},
376376
row::Int)

test/join.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,4 +887,15 @@ end
887887
@test_throws ArgumentError join(df1, df2, on=:id, kind=:inner)
888888
end
889889

890+
@testset "join mixing DataFrame and SubDataFrame" begin
891+
df1 = DataFrame(a=[1, 2, 3], b=[4, 5, 6])
892+
df1_copy = df1[df1.a .> 1, :]
893+
df1_view1 = @view df1[df1.a .> 1, :]
894+
df1_view2 = @view df1[df1.a .> 1, 1:2]
895+
df2 = DataFrame(a=[1, 2, 3], c=[7, 8, 9])
896+
@test innerjoin(df1_copy, df2, on=:a) ==
897+
innerjoin(df1_view1, df2, on=:a) ==
898+
innerjoin(df1_view2, df2, on=:a)
899+
end
900+
890901
end # module

0 commit comments

Comments
 (0)