Tabulation has an instance of AltTable, which is intended to uphold the following law:
fromQuery a <|>: fromQuery b = fromQuery (a <|>: b)
The previous implementation was not actually defined in terms of Query's <|>: (i.e., UNION ALL), because not every Tabulation can be safely toQuery'd. Instead it used a combination of alignWith, catNonEmptyTable and some that worked even on "magic" Tabulations.
However, using unsafePeekQuery, we can actually "statically" determine if a Tabulation is "magic" or not, which means we can selectively switch the implementation to use Query's <|>: where possible. This produces a simpler and usually faster query.
Tabulation
has an instance ofAltTable
, which is intended to uphold the following law:The previous implementation was not actually defined in terms of
Query
's<|>:
(i.e.,UNION ALL
), because not everyTabulation
can be safelytoQuery
'd. Instead it used a combination ofalignWith
,catNonEmptyTable
andsome
that worked even on "magic"Tabulation
s.However, using
unsafePeekQuery
, we can actually "statically" determine if aTabulation
is "magic" or not, which means we can selectively switch the implementation to useQuery
's<|>:
where possible. This produces a simpler and usually faster query.