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
The second one is extremely surprising to me, and I would say, incorrect.
Firstly, because I expect an OR expression to be true if any side is true, regardless of whether the other is false, absent, null or whatnot. Secondly, I expect an OR expression to produce the same truth value regardless of the order of the operands.
Finally, because even after taking time to read the doc, I still don't understand why this would be correct.
The doc on absent values [1] says
boolean operators with both operands being absent evaluate to absent
But here we only have one absent operand, not both
Arithmetic operators with one absent operand return the other operand
I would expect the same of ||, but granted I would not expect it from &&
If you're interested in a formal description of how empty and absent fields participate in arithmetic, here's a table for plus (other arithmetic/boolean/bitwise operators are similar)
The table seems perfectly symmetrical, so I would expect the same symmetry for operands of ||
johnkerl
changed the title
Absent variable on left side of boolean OR (||) expression makes it absent
Absent variable on left side of boolean OR (||) expression should make it absent
Dec 2, 2023
This is largely the same for && and || as it is with + with notable exceptions. In particular, true-or-error must be true, and false-and-error must be false, because of the short-circuiting guarantee -- we could only determine the right-hand side is error by evaluating it, but we must not evaluate the right-hand side in these cases, in order to satisfy the guarantee of short-circuiting semantics.
Compare these filter expressions:
The second one is extremely surprising to me, and I would say, incorrect.
Firstly, because I expect an OR expression to be true if any side is true, regardless of whether the other is false, absent, null or whatnot. Secondly, I expect an OR expression to produce the same truth value regardless of the order of the operands.
Finally, because even after taking time to read the doc, I still don't understand why this would be correct.
The doc on absent values [1] says
But here we only have one absent operand, not both
I would expect the same of
||
, but granted I would not expect it from&&
The table seems perfectly symmetrical, so I would expect the same symmetry for operands of
||
[1] https://miller.readthedocs.io/en/latest/reference-main-null-data/
The text was updated successfully, but these errors were encountered: