Module mz_transform::canonicalize_mfp

source ·
Expand description

Canonicalizes MFPs, e.g., performs CSE on the scalar expressions, eliminates identity MFPs.

Also calls canonicalize_predicates through fusion::filter.

This transform takes a sequence of Maps, Filters, and Projects and canonicalizes it to a sequence like this: | Map | Filter | Project

As part of 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.

Structs§

  • Canonicalizes MFPs and performs common sub-expression elimination.