Class PushExpressionsToFieldLoad


public class PushExpressionsToFieldLoad extends ParameterizedRule<LogicalPlan,LogicalPlan,LocalLogicalOptimizerContext>
Replaces Expressions that can be pushed to field loading with a field attribute that calculates the expression during value loading. See BlockLoaderExpression for more about how these loads are implemented and why we do this.

This rule runs in one downward (aka output-to-read) pass, making four sorts of transformations:

  • When we see a use of a new pushable function we build an attribute for the function, record that attribute, and discard it after use. For example, EVAL l = LENGTH(message) becomes EVAL l = $$message$LENGTH$1324$$ | DROP $$message$LENGTH$1324$$ . We need the DROP so we don't change the output schema.
  • When we see a use of pushable function for which we already have an attribute we just use it. This looks like the l attribute in EVAL l = LENGTH(message) | EVAL l2 = LENGTH(message)
  • When we see a PROJECT, add any new attributes to the projection so we can use them on previously visited nodes. So KEEP foo | EVAL l = LENGTH(message) becomes
    
               | KEEP foo, $$message$LENGTH$1324$$
               | EVAL l = $$message$LENGTH$1324$$
               | DROP $$message$LENGTH$1324$$
             }
  • When we see a relation, add the attribute to it.