In previous e-mails we have suggested a few new rewrite rules and I want to
get feedback on them.
---------
The first rewrite rule would merge two unnest child operations into a
single unnest operator.
UNNEST( $v2 : child($v1, "step2") )
UNNEST($v1 : child($v0, "step1") )
where $v1 is not used in the rest of the plan.
Options for solution:
1. UNNEST( $v2 : child(child($v0, "step1"), "step2") )
or
2. UNNEST( $v2 : child($v0, "step1/step2") )
First, is this optimization best placed in the rewrite rules space?
(consider the compiler, etc.)
Second, which of the solutions should we consider for implementation? Or do
you know something else?
---------
The second rewrite rule would merge unnest child into a data scan operation.
UNNEST( $v1 : child($v0, "step1") )
DATASCAN( collection( $source ), $v0 )
where $v0 is not used in the rest of the plan.
Options for solution:
DATASCAN( child(collection( $source ), "step1"), $v1 )
where the OperatorDescriptor for DATASCAN would understand the child of
collection.
-----------
The third rule searches for subplans that consume a single item input.
SUBPLAN {
AGGREGATE($v2 : sequence(%expression($v1)))
UNNEST($v1 : iterate($v0))
NESTED_TUPLE_SOURCE
}
if $v0 is a single item, not a sequence. Then rewrite to:
ASSIGN($v2 : %expression($v0))
First, does this rule look correct?
Second, is it worth putting this rule in place?