Open
Description
This is coming up every now and then, and we'll get bug reports where a WHERE
command behaves unexpectedly in case of null
values in the fields. Most recently, this was raised in #129125.
I checked our docs and couldn't find an explanation of the ternary logic (true
, false
, null
) in our docs. The crux is that
- when an expression is
null
, combining withNOT
,AND
andOR
will still result innull
(forOR
: unless the other operand istrue
, forAND
: unless the other operand isfalse
)
and for a good reason:null
means "I don't know the value", and thus the output ofnull AND true
can only benull
.
I think it'd be nice to structure our docs in a way that boolean operators are grouped together and give each of them a 3x3 (resp. 3x1) table of how they evaluate in case of true
, false
and null
in each of their operands. Additionally, giving an example would be great - like the example from the linked issue:
WHERE process.name IS NULL AND NOT process.name == "svchost.exe"
(this evaluates toWHERE null
, which filters out all the rows - but this is expected, see my comment for an explanation)