From 7e7d96ac3899e84b22a3a6ec320705b754079e7b Mon Sep 17 00:00:00 2001 From: Iblis Lin Date: Sun, 2 May 2021 16:14:20 +0800 Subject: [PATCH 1/4] Add `join` family without default definition close https://github.com/JuliaData/Tables.jl/issues/238 --- src/DataAPI.jl | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/src/DataAPI.jl b/src/DataAPI.jl index 8f602ad..a2360c8 100644 --- a/src/DataAPI.jl +++ b/src/DataAPI.jl @@ -183,4 +183,102 @@ default definition. function unwrap end unwrap(x) = x +""" + innerjoin(x, y, zs...) + +Perform an inner join of two or more objects. + +See also: [`outerjoin`](@ref), + [`leftjoin`](@ref), + [`rightjoin`](@ref), + [`semijoin`](@ref), + [`antijoin`](@ref), + [`crossjoin`](@ref). +""" +function innerjoin end + +""" + outerjoin(x, y, zs...) + +Perform an outer join of two or more objects. + +See also: [`innerjoin`](@ref), + [`leftjoin`](@ref), + [`rightjoin`](@ref), + [`semijoin`](@ref), + [`antijoin`](@ref), + [`crossjoin`](@ref). +""" +function outerjoin end + +""" + rightjoin(x, y) + +Perform a right join on two objects. + +See also: [`innerjoin`](@ref), + [`outerjoin`](@ref), + [`leftjoin`](@ref), + [`semijoin`](@ref), + [`antijoin`](@ref), + [`crossjoin`](@ref). +""" +function rightjoin end + +""" + leftjoin(x, y) + +Perform a left join of two objects. + +See also: [`innerjoin`](@ref), + [`outerjoin`](@ref), + [`rightjoin`](@ref), + [`semijoin`](@ref), + [`antijoin`](@ref), + [`crossjoin`](@ref). +""" +function leftjoin end + +""" + semijoin(x, y) + +Perform a semi join of two objects. + +See also: [`innerjoin`](@ref), + [`outerjoin`](@ref), + [`leftjoin`](@ref), + [`rightjoin`](@ref), + [`antijoin`](@ref), + [`crossjoin`](@ref). +""" +function semijoin end + +""" + antijoin(x, y) + +Perform an anti join of two objects. + +See also: [`innerjoin`](@ref), + [`outerjoin`](@ref), + [`leftjoin`](@ref), + [`rightjoin`](@ref), + [`semijoin`](@ref), + [`crossjoin`](@ref). +""" +function antijoin end + +""" + crossjoin(x, y, zs...) + +Perform a cross join of two or more objects. + +See also: [`innerjoin`](@ref), + [`outerjoin`](@ref), + [`leftjoin`](@ref), + [`rightjoin`](@ref), + [`semijoin`](@ref), + [`antijoin`](@ref). +""" +function crossjoin end + end # module From 2e4f2c3bba38e89a34fc2f0c82cdb9621d50aced Mon Sep 17 00:00:00 2001 From: Iblis Lin Date: Sun, 2 May 2021 21:20:39 +0800 Subject: [PATCH 2/4] drop zs --- src/DataAPI.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/DataAPI.jl b/src/DataAPI.jl index a2360c8..11e0dcc 100644 --- a/src/DataAPI.jl +++ b/src/DataAPI.jl @@ -184,7 +184,7 @@ function unwrap end unwrap(x) = x """ - innerjoin(x, y, zs...) + innerjoin(x, y) Perform an inner join of two or more objects. @@ -198,7 +198,7 @@ See also: [`outerjoin`](@ref), function innerjoin end """ - outerjoin(x, y, zs...) + outerjoin(x, y) Perform an outer join of two or more objects. @@ -268,7 +268,7 @@ See also: [`innerjoin`](@ref), function antijoin end """ - crossjoin(x, y, zs...) + crossjoin(x, y) Perform a cross join of two or more objects. From 4ee4eb7d5f1b08202b52115d20092d13de1756d6 Mon Sep 17 00:00:00 2001 From: Iblis Lin Date: Sun, 2 May 2021 22:46:03 +0800 Subject: [PATCH 3/4] comments --- src/DataAPI.jl | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/src/DataAPI.jl b/src/DataAPI.jl index 11e0dcc..7935478 100644 --- a/src/DataAPI.jl +++ b/src/DataAPI.jl @@ -183,10 +183,18 @@ default definition. function unwrap end unwrap(x) = x +const _joindoc = """ +The implementation specific arguments, like the join key or equality rule, +can be designed as the additional keyword arguments. +""" + """ innerjoin(x, y) -Perform an inner join of two or more objects. +Perform a database-style inner join of two tabular objects and return a tabular +object containing the result. + +$_joindoc See also: [`outerjoin`](@ref), [`leftjoin`](@ref), @@ -200,7 +208,10 @@ function innerjoin end """ outerjoin(x, y) -Perform an outer join of two or more objects. +Perform a database-style outer join of two tabular objects and return a tabular +object containing the result. + +$_joindoc See also: [`innerjoin`](@ref), [`leftjoin`](@ref), @@ -214,7 +225,10 @@ function outerjoin end """ rightjoin(x, y) -Perform a right join on two objects. +Perform a database-style right join on two tabular objects and return a tabular +object containing the result. + +$_joindoc See also: [`innerjoin`](@ref), [`outerjoin`](@ref), @@ -228,7 +242,10 @@ function rightjoin end """ leftjoin(x, y) -Perform a left join of two objects. +Perform a database-style left join of two tabular objects and return a tabular +object containing the result. + +$_joindoc See also: [`innerjoin`](@ref), [`outerjoin`](@ref), @@ -242,7 +259,10 @@ function leftjoin end """ semijoin(x, y) -Perform a semi join of two objects. +Perform a database-style semi join of two tabular objects and return a tabular +object containing the result. + +$_joindoc See also: [`innerjoin`](@ref), [`outerjoin`](@ref), @@ -256,7 +276,10 @@ function semijoin end """ antijoin(x, y) -Perform an anti join of two objects. +Perform a database-style anti join of two tabular objects and return a tabular +object containing the result. + +$_joindoc See also: [`innerjoin`](@ref), [`outerjoin`](@ref), @@ -270,7 +293,10 @@ function antijoin end """ crossjoin(x, y) -Perform a cross join of two or more objects. +Perform a database-style cross join of two tabular objects and return a tabular +object containing the result. + +$_joindoc See also: [`innerjoin`](@ref), [`outerjoin`](@ref), From c4d6089b63d35606948a63862a582f78342977d8 Mon Sep 17 00:00:00 2001 From: Iblis Lin Date: Sun, 2 May 2021 23:07:00 +0800 Subject: [PATCH 4/4] remove docstring but add some code comments --- src/DataAPI.jl | 120 ++----------------------------------------------- 1 file changed, 4 insertions(+), 116 deletions(-) diff --git a/src/DataAPI.jl b/src/DataAPI.jl index 7935478..7fbbd29 100644 --- a/src/DataAPI.jl +++ b/src/DataAPI.jl @@ -183,128 +183,16 @@ default definition. function unwrap end unwrap(x) = x -const _joindoc = """ -The implementation specific arguments, like the join key or equality rule, -can be designed as the additional keyword arguments. -""" - -""" - innerjoin(x, y) - -Perform a database-style inner join of two tabular objects and return a tabular -object containing the result. - -$_joindoc - -See also: [`outerjoin`](@ref), - [`leftjoin`](@ref), - [`rightjoin`](@ref), - [`semijoin`](@ref), - [`antijoin`](@ref), - [`crossjoin`](@ref). -""" +# The database-style join methods for tabular data type. +# The common interface is `*join(x, y; ...)` and use the keyword arguments +# for the join criteria. +# See the design of DataFrames.jl also. function innerjoin end - -""" - outerjoin(x, y) - -Perform a database-style outer join of two tabular objects and return a tabular -object containing the result. - -$_joindoc - -See also: [`innerjoin`](@ref), - [`leftjoin`](@ref), - [`rightjoin`](@ref), - [`semijoin`](@ref), - [`antijoin`](@ref), - [`crossjoin`](@ref). -""" function outerjoin end - -""" - rightjoin(x, y) - -Perform a database-style right join on two tabular objects and return a tabular -object containing the result. - -$_joindoc - -See also: [`innerjoin`](@ref), - [`outerjoin`](@ref), - [`leftjoin`](@ref), - [`semijoin`](@ref), - [`antijoin`](@ref), - [`crossjoin`](@ref). -""" function rightjoin end - -""" - leftjoin(x, y) - -Perform a database-style left join of two tabular objects and return a tabular -object containing the result. - -$_joindoc - -See also: [`innerjoin`](@ref), - [`outerjoin`](@ref), - [`rightjoin`](@ref), - [`semijoin`](@ref), - [`antijoin`](@ref), - [`crossjoin`](@ref). -""" function leftjoin end - -""" - semijoin(x, y) - -Perform a database-style semi join of two tabular objects and return a tabular -object containing the result. - -$_joindoc - -See also: [`innerjoin`](@ref), - [`outerjoin`](@ref), - [`leftjoin`](@ref), - [`rightjoin`](@ref), - [`antijoin`](@ref), - [`crossjoin`](@ref). -""" function semijoin end - -""" - antijoin(x, y) - -Perform a database-style anti join of two tabular objects and return a tabular -object containing the result. - -$_joindoc - -See also: [`innerjoin`](@ref), - [`outerjoin`](@ref), - [`leftjoin`](@ref), - [`rightjoin`](@ref), - [`semijoin`](@ref), - [`crossjoin`](@ref). -""" function antijoin end - -""" - crossjoin(x, y) - -Perform a database-style cross join of two tabular objects and return a tabular -object containing the result. - -$_joindoc - -See also: [`innerjoin`](@ref), - [`outerjoin`](@ref), - [`leftjoin`](@ref), - [`rightjoin`](@ref), - [`semijoin`](@ref), - [`antijoin`](@ref). -""" function crossjoin end end # module