Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ArrowTypes/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ArrowTypes"
uuid = "31f734f8-188a-4ce0-8406-c8a06bd891cd"
authors = ["quinnj <quinn.jacobd@gmail.com>"]
version = "1.2.2"
version = "2.0.0"


[deps]
Expand Down
32 changes: 0 additions & 32 deletions src/ArrowTypes/src/ArrowTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 0 additions & 11 deletions src/arraytypes/arraytypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 1 addition & 5 deletions src/eltypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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", "")
Expand All @@ -57,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)
Expand Down
13 changes: 0 additions & 13 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 11 additions & 4 deletions test/dates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down