Subqueries have a neat optimization in PushDownFilterAndLimitIntoUnionAll where we pushdown filters and limit to subqueries.
For example:
* Filter (pushable predicates)
* UnionAll
* Project
* Eval (optional)
* Limit
* EsRelation
* Project
* Eval (optional)
* Limit
* Subquery
becomes:
* UnionAll
* Project
* Eval (optional)
* Limit
* Filter (pushable predicates)
* EsRelation
* Project
* Eval (optional)
* Limit
* Filter (pushable predicates)
* Subquery
There's no reason not to make this generic so that it applies for FORK too.
There's one aspect with the attributes being pushdown past the implicit LIMIT, that can make the results of FORK different. However we want to remove this implicit LIMIT, so we should be good with adding this optimization for FORK too.
Subqueries have a neat optimization in
PushDownFilterAndLimitIntoUnionAllwhere we pushdown filters and limit to subqueries.For example:
becomes:
There's no reason not to make this generic so that it applies for FORK too.
There's one aspect with the attributes being pushdown past the implicit LIMIT, that can make the results of FORK different. However we want to remove this implicit LIMIT, so we should be good with adding this optimization for FORK too.