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

Comparisons between Nullable and non-Nullable #79

Closed
mkborregaard opened this issue Jan 25, 2017 · 1 comment
Closed

Comparisons between Nullable and non-Nullable #79

mkborregaard opened this issue Jan 25, 2017 · 1 comment

Comments

@mkborregaard
Copy link

mkborregaard commented Jan 25, 2017

I am seeing some strange behaviour from Query.jl (v. 0.3.0) when comparing Nullables to non-Nullables.
e.g.

# This first bit just illustrates that the issues derive from Query
julia> using DataFrames

julia> 3 < Nullable(4)
ERROR: MethodError: no method matching isless(::Int64, ::Nullable{Int64})
Closest candidates are:
  isless(::Nullable{Union{}}, ::Nullable{T}) at /Users/michael/.julia/v0.5/NullableArrays/src/operators.jl:161
  isless(::Real, ::AbstractFloat) at operators.jl:41
  isless(::Real, ::Real) at operators.jl:75
  ...
 in <(::Int64, ::Nullable{Int64}) at ./operators.jl:63

julia> using Query
WARNING: Method definition require(Symbol) in module Base at loading.jl:345 overwritten in module Query at /Users/michael/.julia/v0.5/Requires/src/require.jl:12.
WARNING: Method definition ==(Base.Nullable{#T<:Any}, Base.Nullable{Union{}}) in module NullableArrays at /Users/michael/.julia/v0.5/NullableArrays/src/operators.jl:140 overwritten in module Query at /Users/michael/.julia/v0.5/Query/src/operators.jl:8.
WARNING: Method definition ==(Base.Nullable{Union{}}, Base.Nullable{#T<:Any}) in module NullableArrays at /Users/michael/.julia/v0.5/NullableArrays/src/operators.jl:139 overwritten in module Query at /Users/michael/.julia/v0.5/Query/src/operators.jl:9.
WARNING: Method definition ==(Base.Nullable{#T1<:Any}, Base.Nullable{#T2<:Any}) in module NullableArrays at /Users/michael/.julia/v0.5/NullableArrays/src/operators.jl:130 overwritten in module Query at /Users/michael/.julia/v0.5/Query/src/operators.jl:77.

# This is the behaviour I find strange
julia> 3 < Nullable(4)
true
julia> 3 < Nullable()
false

The scalar boolean return value may be necessary for type stability, but I am thinking this may cause issues (I would expect the last expression to return Null).

@davidanthoff
Copy link
Member

The next version of Query will no longer engage in this kind of type piracy, i.e. it will no longer overwrite comparison operators for Nullable. Instead, Query will use a custom type for missing data values within queries (probably called DataValue). For that type, 3 < DataValue() will still return false. For Query to work, predicates need to return Bool values, and that really seems the only way to do that right now.

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

2 participants