From 388f9ecbb8f70d6a3a4dfd91d656c7539bd0ab42 Mon Sep 17 00:00:00 2001 From: Jarrett Revels Date: Thu, 16 Sep 2021 17:17:56 -0400 Subject: [PATCH 1/2] delete Arrow.jl v1.0 deprecations in preparation for v2.0 release --- src/ArrowTypes/Project.toml | 2 +- src/ArrowTypes/src/ArrowTypes.jl | 32 -------------------------------- src/arraytypes/arraytypes.jl | 11 ----------- src/eltypes.jl | 4 ---- src/utils.jl | 13 ------------- test/dates.jl | 15 +++++++++++---- 6 files changed, 12 insertions(+), 65 deletions(-) diff --git a/src/ArrowTypes/Project.toml b/src/ArrowTypes/Project.toml index 47c2e4f4..96012d83 100644 --- a/src/ArrowTypes/Project.toml +++ b/src/ArrowTypes/Project.toml @@ -1,7 +1,7 @@ name = "ArrowTypes" uuid = "31f734f8-188a-4ce0-8406-c8a06bd891cd" authors = ["quinnj "] -version = "1.2.2" +version = "2.0.0" [deps] diff --git a/src/ArrowTypes/src/ArrowTypes.jl b/src/ArrowTypes/src/ArrowTypes.jl index 386c7d49..61178966 100644 --- a/src/ArrowTypes/src/ArrowTypes.jl +++ b/src/ArrowTypes/src/ArrowTypes.jl @@ -356,36 +356,4 @@ Base.size(x::ToArrow) = (length(x.data),) Base.eltype(x::ToArrow{T, A}) where {T, A} = T Base.getindex(x::ToArrow{T}, i::Int) where {T} = toarrow(getindex(x.data, i)) -#### DEPRECATED -function arrowconvert end -arrowconvert(T, x) = convert(T, x) -arrowconvert(::Type{Union{T, Missing}}, x) where {T} = arrowconvert(T, x) -arrowconvert(::Type{Union{T, Missing}}, ::Missing) where {T} = missing - -const JULIA_TO_ARROW_TYPE_MAPPING = Dict{Type, Tuple{String, Type}}() - -istyperegistered(::Type{T}) where {T} = haskey(JULIA_TO_ARROW_TYPE_MAPPING, T) - -const ARROW_TO_JULIA_TYPE_MAPPING = Dict{String, Tuple{Type, Type}}() - -function extensiontype(f, meta) - if haskey(meta, "ARROW:extension:name") - typename = meta["ARROW:extension:name"] - if haskey(ARROW_TO_JULIA_TYPE_MAPPING, typename) - T = ARROW_TO_JULIA_TYPE_MAPPING[typename][1] - return f.nullable ? Union{T, Missing} : T - end - end - return nothing -end - -function registertype!(juliatype::Type, arrowtype::Type, arrowname::String=string("JuliaLang.", string(juliatype))) - msg = "Arrow.ArrowTypes.registertype! is deprecated in favor of defining `ArrowTypes.ArrowType`, `ArrowTypes.arrowname`, and `ArrowTypes.JuliaType`; see their docs for more information on how to migrate" - Base.depwarn(msg, :registertype!) - # TODO: validate that juliatype isn't already default arrow type - JULIA_TO_ARROW_TYPE_MAPPING[juliatype] = (arrowname, arrowtype) - ARROW_TO_JULIA_TYPE_MAPPING[arrowname] = (juliatype, arrowtype) - return -end - end # module ArrowTypes diff --git a/src/arraytypes/arraytypes.jl b/src/arraytypes/arraytypes.jl index beba66f3..c6aba0bd 100644 --- a/src/arraytypes/arraytypes.jl +++ b/src/arraytypes/arraytypes.jl @@ -84,17 +84,6 @@ end # now we check for ArrowType converions and dispatch on ArrowKind function arrowvector(::Type{S}, x, i, nl, fi, de, ded, meta; kw...) where {S} meta = _normalizemeta(meta) - # deprecated and will be removed - if ArrowTypes.istyperegistered(S) - arrowname, arrowtype = ArrowTypes.JULIA_TO_ARROW_TYPE_MAPPING[S] - meta = _arrowtypemeta(meta, arrowname, "") - if arrowtype === S - return arrowvector(ArrowKind(S), x, i, nl, fi, de, ded, meta; kw...) - else - return arrowvector(converter(arrowtype, x), i, nl, fi, de, ded, meta; kw...) - end - end - # end deprecation return arrowvector(ArrowKind(S), x, i, nl, fi, de, ded, meta; kw...) end diff --git a/src/eltypes.jl b/src/eltypes.jl index 0aa6d0bf..abf9f5a7 100644 --- a/src/eltypes.jl +++ b/src/eltypes.jl @@ -43,10 +43,6 @@ function juliaeltype(f::Meta.Field, meta::AbstractDict{String, String}, convert: TT = juliaeltype(f, convert) !convert && return TT T = finaljuliatype(TT) - # deprecated begin - TTT = ArrowTypes.extensiontype(f, meta) - TTT !== nothing && return TTT - # end deprecated if haskey(meta, "ARROW:extension:name") typename = meta["ARROW:extension:name"] metadata = get(meta, "ARROW:extension:metadata", "") diff --git a/src/utils.jl b/src/utils.jl index f5c052a3..f8051762 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -104,19 +104,6 @@ end # given a number of unique values; what dict encoding _index_ type is most appropriate encodingtype(n) = n < div(typemax(Int8), 2) ? Int8 : n < div(typemax(Int16), 2) ? Int16 : n < div(typemax(Int32), 2) ? Int32 : Int64 -# can be removed once we finish deprecating old registertype! machinery -struct Converter{T, A} <: AbstractVector{T} - data::A -end - -converter(::Type{T}, x::A) where {T, A} = Converter{eltype(A) >: Missing ? Union{T, Missing} : T, A}(x) -converter(::Type{T}, x::ChainedVector{A}) where {T, A} = ChainedVector([converter(T, x) for x in x.arrays]) - -Base.IndexStyle(::Type{<:Converter}) = Base.IndexLinear() -Base.size(x::Converter) = (length(x.data),) -Base.eltype(x::Converter{T, A}) where {T, A} = T -Base.getindex(x::Converter{T}, i::Int) where {T} = ArrowTypes.arrowconvert(T, getindex(x.data, i)) - maybemissing(::Type{T}) where {T} = T === Missing ? Missing : Base.nonmissingtype(T) withmissing(U::Union, S) = U >: Missing ? Union{Missing, S} : S withmissing(T, S) = T === Missing ? Union{Missing, S} : S diff --git a/test/dates.jl b/test/dates.jl index c706943d..ee1883f6 100644 --- a/test/dates.jl +++ b/test/dates.jl @@ -20,23 +20,30 @@ import TimeZones struct WrappedDate x::Dates.Date end -Arrow.ArrowTypes.registertype!(WrappedDate, WrappedDate) + +ArrowTypes.arrowname(::Type{WrappedDate}) = Symbol("JuliaLang.WrappedDate") +ArrowTypes.JuliaType(::Val{Symbol("JuliaLang.WrappedDate")}) = WrappedDate struct WrappedTime x::Dates.Time end -Arrow.ArrowTypes.registertype!(WrappedTime, WrappedTime) + +ArrowTypes.arrowname(::Type{WrappedTime}) = Symbol("JuliaLang.WrappedTime") +ArrowTypes.JuliaType(::Val{Symbol("JuliaLang.WrappedTime")}) = WrappedTime struct WrappedDateTime x::Dates.DateTime end -Arrow.ArrowTypes.registertype!(WrappedDateTime, WrappedDateTime) + +ArrowTypes.arrowname(::Type{WrappedDateTime}) = Symbol("JuliaLang.WrappedDateTime") +ArrowTypes.JuliaType(::Val{Symbol("JuliaLang.WrappedDateTime")}) = WrappedDateTime struct WrappedZonedDateTime x::TimeZones.ZonedDateTime end -Arrow.ArrowTypes.registertype!(WrappedZonedDateTime, WrappedZonedDateTime) +ArrowTypes.arrowname(::Type{WrappedZonedDateTime}) = Symbol("JuliaLang.WrappedZonedDateTime") +ArrowTypes.JuliaType(::Val{Symbol("JuliaLang.WrappedZonedDateTime")}) = WrappedZonedDateTime @testset "Date and time wrappers with missing" begin for T in (WrappedDate, WrappedTime, WrappedDateTime, WrappedZonedDateTime) From 4280ea9ace356421fd802222fa25fcd63179f919 Mon Sep 17 00:00:00 2001 From: Jarrett Revels Date: Thu, 16 Sep 2021 18:28:40 -0400 Subject: [PATCH 2/2] fix previously untested typo --- src/eltypes.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/eltypes.jl b/src/eltypes.jl index abf9f5a7..2969bc2f 100644 --- a/src/eltypes.jl +++ b/src/eltypes.jl @@ -53,7 +53,7 @@ function juliaeltype(f::Meta.Field, meta::AbstractDict{String, String}, convert: @warn "unsupported ARROW:extension:name type: \"$typename\", arrow type = $TT" maxlog=1 _id=hash((:juliaeltype, typename, TT)) end end - return something(TTT, T) + return something(TT, T) end function juliaeltype(f::Meta.Field, convert::Bool)