You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

The rule InlineSubplanInputForNestedTupleSourceRule is to remove SubplanOperators containing DataScan, InnerJoin, LeftOuterJoin, UnionAll or Distinct. Given a qualified Subplan operator called S1, Let's call its input operator O1. We have the following rewritings:

 R1. Replace all NestedTupleSourceOperators in S1 with deep-copies the query plan rooted at O1;

 R2. Add a LeftOuterOperatorJoinOperator (let's call it LJ) between O1 and the SubplanOperator's

       root operator's input (let's call it SO1), where O1 is the left branch and SO1 is the right

       branch;

R3. The deep copy of the primary key variables in O1 should be preserved from an inlined

       NestedTupleSourceOperator to SO1. The join condition of LJ is the equality between

       the primary key variables in O1 and its deep copied version at SO1;

R4. A variable v indicating non-match tuples is assigned to TRUE between LJ and SO1;

R5. On top of the LJ, add a GroupByOperaptor in which the nested plan consists of the

       S1's root operator, i.e., an aggregate operator. Below the aggregate, there is a not-null-filter

       on variable v.

 

For special cases where:

a. there is a join (let's call it J1.) in the nested plan,

b. one input pipeline of J1 has a NestedTupleSource descendant (let's call it N1),

c. there is no tuple dropping from the N1 to the J1

 

Rewriting R2 is not necessary since before J1, all tuples from N1 are preserved. But rewriting R1' to R4' are needed:

R1'. Replace N1 by the O1 (no additional deep copy);

R2'. All inner joins on the path from N1 to J1 (including J1) are rewritten to a left-outer join with the same join condition;

R3'. If N1 resides in the right branch of a join (let's call it J2) in the path from N1 to J1, switch the left and right branches of J2;

R4'. On top of J1, a GroupByOperaptor G1 is added where the group-by key is the primary key of the subplan input operator and the nested query plan for aggregation is the nested pipeline on top of J1 (with a not-null-filter added).

R5'. All other NestedTupleSourceOperators in the subplan is inlined with a deep copy of the query plan rooted at O1.

 

  • No labels