Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method ambiguity in _promote when promoting x::T to T if T <: PooledVector #925

Closed
nickrobinson251 opened this issue Oct 4, 2021 · 1 comment

Comments

@nickrobinson251
Copy link
Collaborator

julia> using CSV

julia> aa = IOBuffer("""
       a,b
       a,2
       a,3
       """)
IOBuffer(data=UInt8[...], readable=true, writable=false, seekable=true, append=false, size=12, maxsize=Inf, ptr=1, mark=-1)

julia> bb = IOBuffer("""
       a,b
       ab,22
       ab,33
       """)
IOBuffer(data=UInt8[...], readable=true, writable=false, seekable=true, append=false, size=16, maxsize=Inf, ptr=1, mark=-1)

julia> CSV.File([aa, bb])
ERROR: MethodError: _promote(::Type{PooledArrays.PooledVector{String3, UInt32, Vector{UInt32}}}, ::PooledArrays.PooledVector{String3, UInt32, Vector{UInt32}}) is ambiguous. Candidates:
  _promote(::Type{A}, x::A) where A in CSV at /Users/nick/.julia/packages/CSV/owrEo/src/utils.jl:171
  _promote(::Type{PooledArrays.PooledVector{T, R, RA}}, x) where {T, R, RA} in CSV at /Users/nick/.julia/packages/CSV/owrEo/src/utils.jl:182
Possible fix, define
  _promote(::Type{PooledArrays.PooledVector{T, R, RA}}, ::PooledArrays.PooledVector{T, R, RA}) where {T, R, RA}
Stacktrace:
 [1] chaincolumns!(a::Any, b::Any)
   @ CSV ~/.julia/packages/CSV/owrEo/src/utils.jl:206
 [2] CSV.File(sources::Vector{IOBuffer}; source::Nothing, kw::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ CSV ~/.julia/packages/CSV/owrEo/src/file.jl:1010
 [3] CSV.File(sources::Vector{IOBuffer})
   @ CSV ~/.julia/packages/CSV/owrEo/src/file.jl:985
 [4] top-level scope
   @ REPL[19]:1

(jl_weYOTi) pkg> st
      Status `/private/var/folders/hx/1h0bbkfd18d4n1qrnwmrl4j00000gn/T/jl_weYOTi/Project.toml`
  [336ed68f] CSV v0.9.6
@nickrobinson251 nickrobinson251 changed the title Method ambiguity in _promote when both same PooledVector type Method ambiguity in _promote when promoting x::T to T if T <: PooledVector Oct 4, 2021
@nickrobinson251
Copy link
Collaborator Author

little reproducer

julia> b_col = PooledArray{String3}(["bb", "bb"]);

julia> CSV._promote(typeof(b_col), b_col)
ERROR: MethodError: _promote(::Type{PooledVector{String3, UInt32, Vector{UInt32}}}, ::PooledVector{String3, UInt32, Vector{UInt32}}) is ambiguous. Candidates:
...

we're hitting this branch:

CSV.jl/src/utils.jl

Lines 202 to 206 in 1f7a552

# both arrays are non-missing, but not same eltype, just need to promote
P = pooledtype(promote_types(eltype(a), eltype(b)))
end
px = _promote(P, a)
py = _promote(P, b)

i'll open a PR adding the missing method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant