Skip to content

Commit

Permalink
Matchmissing == :notequal
Browse files Browse the repository at this point in the history
Not documented, available for testing purpose
  • Loading branch information
pstorozenko committed Apr 17, 2021
1 parent a671a3b commit 3b85d02
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions src/join/composer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ struct DataFrameJoiner

function DataFrameJoiner(dfl::AbstractDataFrame, dfr::AbstractDataFrame,
on::Union{<:OnType, AbstractVector},
matchmissing::Symbol)
matchmissing::Symbol,
kind::Symbol)
on_cols = isa(on, AbstractVector) ? on : [on]
left_on = Symbol[]
right_on = Symbol[]
Expand Down Expand Up @@ -55,6 +56,42 @@ struct DataFrameJoiner
"when matchmissing == :error"))
end
end
elseif matchmissing === :notequal_copy
if kind in [:left, :semi, :anti]
dfr = dropmissing(dfr, right_on)
dfr_on = select(dfr, right_on, copycols = false)
elseif kind === :right
dfl = dropmissing(dfl, left_on)
dfl_on = select(dfl, left_on, copycols = false)
elseif kind === :inner
@show kind, matchmissing
dfl = dropmissing(dfl, left_on)
dfl_on = select(dfl, left_on, copycols = false)
dfr = dropmissing(dfr, right_on)
dfr_on = select(dfr, right_on, copycols = false)
elseif kind === :outer
throw(ArgumentError("matchmissing == :notequal with kind == :outer not allowed"))
else
throw("matchmissing == :notequal not implemented for kind == $kind")
end
elseif matchmissing === :notequal_view
if kind in [:left, :semi, :anti]
dfr = dropmissing(dfr, right_on, view = true)
dfr_on = select(dfr, right_on)
elseif kind === :right
dfl = dropmissing(dfl, left_on, view = true)
dfl_on = select(dfl, left_on)
elseif kind === :inner
@show kind, matchmissing
dfl = dropmissing(dfl, left_on, view = true)
dfl_on = select(dfl, left_on)
dfr = dropmissing(dfr, right_on, view = true)
dfr_on = select(dfr, right_on)
elseif kind === :outer
throw(ArgumentError("matchmissing == :notequal with kind == :outer not allowed"))
else
throw("matchmissing == :notequal not implemented for kind == $kind")
end
elseif matchmissing !== :equal
throw(ArgumentError("matchmissing allows only :error or :equal"))
end
Expand Down Expand Up @@ -302,7 +339,7 @@ function _join(df1::AbstractDataFrame, df2::AbstractDataFrame;
throw(ArgumentError("Missing join argument 'on'."))
end

joiner = DataFrameJoiner(df1, df2, on, matchmissing)
joiner = DataFrameJoiner(df1, df2, on, matchmissing, kind)

# Check merge key validity
left_invalid = validate[1] ? any(nonunique(joiner.dfl, joiner.left_on)) : false
Expand Down

0 comments on commit 3b85d02

Please sign in to comment.