Class RewriteFirstValueLastValueRule

java.lang.Object
org.apache.calcite.plan.RelOptRule
org.apache.druid.sql.calcite.rule.RewriteFirstValueLastValueRule
All Implemented Interfaces:
org.apache.calcite.rel.rules.SubstitutionRule, org.apache.calcite.rel.rules.TransformationRule

public class RewriteFirstValueLastValueRule extends org.apache.calcite.plan.RelOptRule implements org.apache.calcite.rel.rules.SubstitutionRule
Rewrites exotic cases of FIRST_VALUE/LAST_VALUE to simpler plans. LAST_VALUE(x) OVER (ORDER BY Y) implicitly means: LAST_VALUE(x) OVER (ORDER BY Y RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) which is equiv to LAST_VALUE(x) OVER (ORDER BY Y ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) since it will take the last value from the window; the value of the window will be: X at the CURRENT ROW. This rule does this and a symmetric one for FIRST_VALUE.
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.apache.calcite.plan.RelOptRule

    org.apache.calcite.plan.RelOptRule.ConverterRelOptRuleOperand
  • Field Summary

    Fields inherited from class org.apache.calcite.plan.RelOptRule

    description, operands, relBuilderFactory
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    onMatch(org.apache.calcite.plan.RelOptRuleCall call)
     

    Methods inherited from class org.apache.calcite.plan.RelOptRule

    any, convert, convert, convert, convert, convertList, convertOperand, convertOperand, equals, equals, getOperand, getOperands, getOutConvention, getOutTrait, hashCode, matches, none, operand, operand, operand, operand, operand, operandJ, operandJ, some, toString, unordered

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.apache.calcite.rel.rules.SubstitutionRule

    autoPruneOld
  • Constructor Details

    • RewriteFirstValueLastValueRule

      public RewriteFirstValueLastValueRule()
  • Method Details

    • onMatch

      public void onMatch(org.apache.calcite.plan.RelOptRuleCall call)
      Specified by:
      onMatch in class org.apache.calcite.plan.RelOptRule