Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If we do this, it will fix #1968
NULL fields are a problem
For booleans, especially for boolean dimensions which are filters, a very common pattern in Malloy, you end up creating expressions which contain nonsense data because any column with a boolean might be null. Null is falsey, but because SQL is null infecting (all computations involving null result in null) ...
NOT x
isnull
whenx
isnull
so it looks falsey when it should be truthyx != y
is null whenx
ory
is null so it looks falsey when it should be truthyx = y
is null whenx
andy
are null so it looks falsey when it should be truthyx or y
is null whenx
ory
is null so it looks falsey when it should be truthyWe know for sure we want to protect
not
, we sort of half protected equality comparisons, and now we are in a weird no man's land we need to get out of.I would like to offer two possible solutions
Proposal One: The Malloy Null Safe Truth Tables
Boolean Operations
not x
true
false
true
x or y
y
x
y
Non null to nullable
x = 0
false
x != 0
true
x ~ 'a'
false
x !~ 'a'
true
x ~ r'a'
false
x !~ r'a'
true
Compare two nullable
x = y
true
x != y
false
x ~ y
true
x !~ y
false
Proposal Two: ==
In this proposal, we do null protect
not
andor
, but don't null protect the equality operators, and we add a null protected equality operator suite, sort of like typescript does ...Boolean Operations
not x
true
false
true
x or y
y
x
y
Non null to nullable
x == 0
false
x !== 0
true
x ~~ 'a'
false
x !~~ 'a'
true
x ~~ r'a'
false
x !~~ r'a'
true
Compare two nullable
x == y
true
x !== y
false
x ~~ y
true
x !~~ y
false
Variant Proposals
Do nothing
This is to leave us where we are today which is we protect some ...
.. but not all
Invert ==
Do not protect equality
Because equality protect translates to
pick false when a = null and b = null else a=b ?? null
this is going to break many query optimizers, don't protect equality, but protect everything else.Only Protect NOT