A database stores more than numbers - it stores integers, text, and the absence of a value. Today you build the single tagged value type that every row, expression, and result in the engine is made of.
Represent an integer, a text, and a null value in one type, and compare two values for equality.
Every cell in a table holds a value, and a value carries a type - an
integer, a string of text, or NULL, the explicit absence of data. The trick
that makes the rest of the engine simple is representing all three with one type
that tags which shape it currently holds, so a row is just a list of these and
nothing downstream has to special-case “what kind of thing is this.”
Equality is where the type tag earns its keep: the integer 42 and the text
"42" print the same but are not the same value, because comparing them must
check the kind before the contents. Get this one comparison right and filtering,
joining, and grouping all inherit it for free later.
// one value, three shapes: tag says whichtype Kind intconst ( KindInt Kind = iota; KindText; KindNull )type Value struct { Kind Kind; Int int64; Text string }// Equal compares Kind first, then the matching payload