An equality test against an absent value returns no rows, and negating it returns every row — why?
answer
- absence is a state, not a value
- compare it and you learn nothing
- false everywhere, or neither
- the format says unordered with itself
- a dedicated predicate, not an operator
basics
~20 sAbsence is a state, not a value to compare against. Where a design borrows the pattern the floating-point format reserves for a result with no numeric answer, equality is false on every row and its negation true on every row — neither isolates the holes. Use the dedicated absence test.
solid answer
~50 sNeither test can see absence, and they fail in opposite directions. Where a design encodes absence with the pattern the floating-point format reserves for a result with no numeric answer, the format specifies that the pattern compares unordered with everything, including a copy of itself: equality comes back false on every row, so the test selects nothing, while the not-equal form comes back true on every row, so it selects everything, absent cells included. Where a design instead carries its own typed absence marker under a logic with a third outcome besides true and false, both directions yield that third outcome, which has to be coerced somewhere before rows can be picked — and then both tests can come back empty. The portable answer is the dedicated cell-by-cell absence test these designs ship; the comparison operators are answering a different question.
go deeper
Know that finding the empty cells needs its own predicate. An equality comparison against absence never returns them, and negating that comparison does not return them either.
Explain both mechanisms: the reserved floating-point pattern that compares unordered with everything including itself, and the typed marker whose comparison yields a third outcome instead.
Demonstrate that you establish which behaviour is in force before relying on either, because a condition built on the wrong assumption returns a plausible result rather than an error.
The policy worth setting is whether raw comparisons against columns that may hold absence are allowed in shared code at all, or whether the absence test must be written out at every such boundary.
## Why comparison is the wrong instrument An equality test asks *are these two values the same*. Absence is not a value; it is the recorded fact that no value exists. Asking whether a cell's value equals the absence of a value is not a question the comparison machinery can answer honestly, and every design in this family declines it — but they decline it in different ways, and the difference is what the question is really probing. There are two mechanisms, and keeping them apart is the whole of the answer. ## Mechanism one: a reserved pattern inside the value Some designs write absence into the number itself, borrowing the bit pattern the floating-point format sets aside for a result with no numeric answer. That pattern is not a number, and the format specifies how it compares: it is **unordered** with respect to everything. The consequences follow mechanically: - `equals` is **false** for every row, including rows that do hold that very pattern — the pattern is not even equal to a copy of itself; - `less than`, `greater than` and their non-strict forms are **false** for every row, for the same reason; - the **not-equal** form is **true** for every row, because "not equal" is satisfied by "unordered" just as it is by "different". So the equality test selects nothing and its negation selects everything. Neither result is the set of holes, and the second one is the more dangerous of the two because it looks like a full table rather than an empty one. ## Mechanism two: a typed marker under a third outcome Other designs define their own absence marker and give comparison a **third outcome** alongside true and false. The comparison does not lie and does not guess; it declines to commit, because the value on one side is unknown and no claim about it can be justified. That third outcome then has to become a decision somewhere before rows are selected, and designs differ again on what they do: - coerce it to false, so the rows drop out of both the test and its negation; - refuse the selection outright when the condition contains it, which is the only loud behaviour; - carry it through into a result that is itself partly indeterminate. Negation does not rescue it. The negation of an outcome that is neither true nor false is still neither. ## The two side by side | | Reserved pattern inside the value | Typed marker with a third outcome | |---|---|---| | Equality against absence | False on every row | Neither true nor false | | Not-equal against absence | True on every row | Neither true nor false | | Absence compared with absence | Reported as unequal | Neither true nor false | | Rows the equality test returns | None | None, once coerced | | Rows the negated test returns | All of them | None, once coerced | The row that catches people out is the last one. A candidate who has only used one of these designs will state its behaviour as the rule, and be confidently wrong in front of someone who has used the other. ## What to write instead Every design here ships a **dedicated cell-by-cell absence test**: a predicate that asks, for each position, whether the cell holds a value at all. It does not compare contents; it inspects presence, which is the only question with an answer. 1. Use that predicate whenever the question is *is this cell empty* — never an equality or an inequality operator. 2. Use its complement when you want the present values, rather than negating a comparison and hoping. 3. When the condition column feeding a selection may contain absence, state explicitly what should happen to those rows instead of inheriting whichever coercion the surface applies. ## Why the designs do not simply make equality work It is tempting to ask why a tool does not define absence to compare equal to absence and be done with it. Two reasons, one per mechanism: - Under the reserved-pattern design, the unordered-comparison rule comes from the number format, not from the tool. Overriding it for one operator would make the column's arithmetic and its comparisons disagree about the same bit pattern. - Under the typed-marker design, saying that absence equals absence asserts that two unknown quantities are the same quantity. That is exactly the claim the design exists to refuse, and asserting it would silently merge two customers whose identifiers were both never recorded. Which sets up the genuinely surprising part, and the one seniors are expected to know: the surfaces that *group*, *de-duplicate*, *order* and *match on a key* often do treat all absences as one and the same key, in the same tool, in the same session. The scalar rule described here does not predict them.
- Under the borrowed floating-point pattern, what does comparing two absent cells with each other report?That they are not equal. The number format specifies the reserved pattern compares unordered with everything, and that includes another instance of itself, so two cells that both hold no value are reported as different. This is why the scalar rule cannot be used to predict what happens when those same two cells are used as a grouping or matching key, where the surface may well treat them as one.
- Why would a design not simply define absence to compare equal to absence?Because the claim is false. Two cells that were never recorded are two unknown quantities, and asserting they are the same quantity would merge records that have nothing in common but their gap. Under the reserved-pattern design there is a second reason: the unordered rule comes from the number format itself, so overriding it for one operator would make arithmetic and comparison disagree about the same bits.
saying these in an interview costs you the question
- Says the equality test returns the rows with no value
- Expects the negated test to isolate the rows with no value
- Believes the comparison behaves identically in every tool
- Thinks a comparison against absence raises an error
- Treats the third outcome as equivalent to false everywhere