Module mz_transform::semijoin_idempotence
source Β· Expand description
Remove semijoins that are applied multiple times to no further effect.
Mechanically, this transform looks for instances of A join B
and replaces
B
with a simpler C
. It does this in the restricted setting that each join
would be a βsemijoinβ: a multiplicity preserving restriction.
The approach we use here is to restrict our attention to cases where
A
is a potentially filtered instance of someGet{id}
,A join B
equate columns ofA
to all columns ofB
,- The multiplicity of any record in
B
is at most one. - The values in these records are exactly
Get{id} join C
.
We find a candidate C
by descending B
looking for another semijoin between
Get{id}
and some other collection D
on the same columns as A
means to join B
.
Should we find such, allowing arbitrary filters of Get{id}
on the equated columns,
which we will transfer to the columns of D
thereby forming C
.
Structs§
- Replacement πA restricted form of a semijoin idempotence information.
- Remove redundant semijoin operators
Functions§
- as_
filtered_ πget Attempts to interpretexpr
as filters applied to aGet
. - Attempt to simplify the join using local information and let bindings.
- distinct_
on_ πkeys_ of True iff some unique key ofinput
is contained in the keys ofmap
. - list_
replacements πReturn a list of potential semijoin replacements forexpr
. - Return a list of potential semijoin replacements for
expr
. - semijoin_
bijection πDetermines bijection between equated columns of a binary join. - validate_
replacement πEvaluates the viability of acandidate
to drive the replacement atsemijoin
.