You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
julia> Legolas.@schema"example" Example
julia> Legolas.@version ExampleV1 begin id::Union{UUID,Missing}end
julia> Legolas.accepted_field_type(ExampleV1SchemaVersion(), UUID)
Union{UUID, UInt128}
julia> Legolas.accepted_field_type(ExampleV1SchemaVersion(), Union{UUID,Missing})
Union{Missing, UUID}
I have to explicitly overload accepted_field_type for Union{UUID,Missing} if I want to capture the UUID -> Union{UUID,UInt128} fallback
Though it's not incorrect at all, needing to do this is annoying and unintuitive
It'd be nice to have an accepted_field_type fallback that automatically splits union types, applies the accepted_field_type transform to each constituent type, and then re-unions the constituents
The text was updated successfully, but these errors were encountered:
I wonder whether it's also worth implementing a similar fallback for eltypes of Arrow.jl-supported container types (Vector, Tuple, etc.) which basically exhibit this same issue
@omus called out (or, i inferred some code he wrote 😁 ) that invoke may also be useful here in some cases, e.g.:
function accepted_field_type(sv::Legolas.SchemaVersion, ::Type{T}) where T >: Missing
A = accepted_field_type(sv, nonmissingtype(T))
return Union{A,Missing}
end
the fully generic one might require general union-splitting though
I have to explicitly overload
accepted_field_type
forUnion{UUID,Missing}
if I want to capture theUUID
->Union{UUID,UInt128}
fallbackThough it's not incorrect at all, needing to do this is annoying and unintuitive
It'd be nice to have an
accepted_field_type
fallback that automatically splits union types, applies theaccepted_field_type
transform to each constituent type, and then re-unions the constituentsThe text was updated successfully, but these errors were encountered: