Expand description

Canonicalizes MFPs and performs common sub-expression elimination.

This transform takes a sequence of Maps, Filters, and Projects and canonicalizes it to a sequence like this: | Filter | Map | Filter | Project The filters before the map are those that can be pushed down through a map according the rules of [crate::projection_pushdown::ProjectionPushdown.push_filters_through_map()]. TODO: It would be nice to canonicalize it to just an MFP, but currently putting a filter after instead of before a Map can result in the loss of nullability information.

After canonicalizing, this transform looks at the Map-Filter-Project subsequence and identifies common ScalarExpr expressions across and within expressions that are arguments to the Map-Filter-Project. It reforms the Map-Filter-Project subsequence to build each distinct expression at most once and to re-use expressions instead of re-evaluating them.

The re-use policy at the moment is severe and re-uses everything. It may be worth considering relations of this if it results in more busywork and less efficiency, but the wins can be substantial when expressions re-use complex subexpressions.


Canonicalizes MFPs and performs common sub-expression elimination.