arrow-julia icon indicating copy to clipboard operation
arrow-julia copied to clipboard

Custom type cannot round trip (Colors.jl)

Open Moelf opened this issue 2 years ago • 1 comments

julia> using Colors, Arrow

julia> colors = fill(colorant"red", 10)
10-element Array{RGB{N0f8},1} with eltype RGB{FixedPointNumbers.N0f8}:
 RGB{N0f8}(1.0,0.0,0.0)
 RGB{N0f8}(1.0,0.0,0.0)
 RGB{N0f8}(1.0,0.0,0.0)
 RGB{N0f8}(1.0,0.0,0.0)
 RGB{N0f8}(1.0,0.0,0.0)
 RGB{N0f8}(1.0,0.0,0.0)
 RGB{N0f8}(1.0,0.0,0.0)
 RGB{N0f8}(1.0,0.0,0.0)
 RGB{N0f8}(1.0,0.0,0.0)
 RGB{N0f8}(1.0,0.0,0.0)

julia> ArrowTypes.JuliaType(::Val{:Color}) = RGB{Colors.N0f8}

julia> ArrowTypes.arrowname(::Type{RGB{Colors.N0f8}}) = :Color

julia> df = (c = colors,);

julia> a = tempname();

julia> Arrow.write(a, df)
"/tmp/jl_kVGtyjAbml"

julia> Arrow.Table(a)
Arrow.Table with 10 rows, 1 columns, and schema:
 :c  RGB{FixedPointNumbers.N0f8}

julia> Arrow.Table(a).c
10-element Arrow.Struct{RGB{FixedPointNumbers.N0f8}, Tuple{Arrow.Struct{@NamedTuple{i::UInt8}, Tuple{Arrow.Primitive{UInt8, Vector{UInt8}}}}, Arrow.Struct{@NamedTuple{i::UInt8}, Tuple{Arrow.Primitive{UInt8, Vector{UInt8}}}}, Arrow.Struct{@NamedTuple{i::UInt8}, Tuple{Arrow.Primitive{UInt8, Vector{UInt8}}}}}}:
Error showing value of type Arrow.Struct{RGB{FixedPointNumbers.N0f8}, Tuple{Arrow.Struct{@NamedTuple{i::UInt8}, Tuple{Arrow.Primitive{UInt8, Vector{UInt8}}}}, Arrow.Struct{@NamedTuple{i::UInt8}, Tuple{Arrow.Primitive{UInt8, Vector{UInt8}}}}, Arrow.Struct{@NamedTuple{i::UInt8}, Tuple{Arrow.Primitive{UInt8, Vector{UInt8}}}}}}:
ERROR: MethodError: no method matching RGB{FixedPointNumbers.N0f8}(::@NamedTuple{i::UInt8}, ::@NamedTuple{i::UInt8}, ::@NamedTuple{i::UInt8})

Closest candidates are:
  RGB{T}(::T, ::T, ::T) where T
   @ ColorTypes ~/.julia/packages/ColorTypes/1dGw6/src/types.jl:97
  RGB{T}(::Any) where T
   @ ColorTypes ~/.julia/packages/ColorTypes/1dGw6/src/types.jl:465

Stacktrace:
  [1] fromarrow(::Type{RGB{FixedPointNumbers.N0f8}}, ::@NamedTuple{i::UInt8}, ::@NamedTuple{i::UInt8}, ::@NamedTuple{i::UInt8})
    @ ArrowTypes ~/.julia/packages/ArrowTypes/Nb4EC/src/ArrowTypes.jl:168

Moelf avatar Aug 30 '23 14:08 Moelf

bump

Moelf avatar Feb 01 '24 21:02 Moelf