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.
General Cases
We have the following rewritings for general cases:
...
In the plan, v_lc_1, ..., v_lc_n are live "covering" variables at InputOp, while v_rc_1, ..., v_rc_n are their corresponding variables populated from the deepcopy of InputOp. "Covering" variables form a set of variables that can imply all live variables. v_l1, ....v_ln in the decoration part of the added group-by operator are all live variables at InputOp except the covering variables v_lc_1, ..., v_lc_n. In the current implementation, we use "covering" variables as primary key variables. In the next version, we will use the real primary key variables, which will fix ASTERIXDB-1168.
Here is a concrete example of the general case rewriting (optimizerts/queries/nested_loj4.aql).
...
Here is a concrete example (optimizerts/queries/nested_loj2.aql). .
Before plan (nested_loj2):
distribute result [%0->$$17] -- |UNPARTITIONED|
...
left outer join (function-call: algebricks:eq, Args:[%0->$$22, %0->$$18]) -- |UNPARTITIONED|
data-scan []<-[$$18, $$0] <- tpch:Customers -- |UNPARTITIONED|
empty-tuple-source -- |UNPARTITIONED|
assign [$$28] <- [TRUE] -- |UNPARTITIONED|
...