This phase merges nested nodes of types Bind, Filter, GroupBy, SortBy, Take, Drop,
CollectionCast and Distinct to Comprehension nodes. Nodes can be merged if they occur in the
following order:
[Source] -> Filter (where) -> GroupBy -> SortBy / (Distinct | Filter (having)) -> Take / Drop
Aliasing Binds and CollectionCasts are allowed everywhere in the chain. Any out of order
operation starts a new chain with a subquery as the source.
Merge the common operations Bind, Filter and CollectionCast into an existing Comprehension.
This method is used at different stages of the pipeline. If the Comprehension already contains
a Distinct clause, it is pushed into a subquery.
Merge the common operations Bind, Filter and CollectionCast into an existing Comprehension.
This method is used at different stages of the pipeline. If the Comprehension already contains
a Distinct clause, it is pushed into a subquery.