Class LeadLagAggFunction

java.lang.Object
org.apache.flink.table.functions.UserDefinedFunction
org.apache.flink.table.functions.DeclarativeAggregateFunction
org.apache.flink.table.planner.functions.aggfunctions.LeadLagAggFunction
All Implemented Interfaces:
Serializable, org.apache.flink.table.functions.FunctionDefinition
Direct Known Subclasses:
LeadLagAggFunction.BooleanLeadLagAggFunction, LeadLagAggFunction.ByteLeadLagAggFunction, LeadLagAggFunction.CharLeadLagAggFunction, LeadLagAggFunction.DateLeadLagAggFunction, LeadLagAggFunction.DecimalLeadLagAggFunction, LeadLagAggFunction.DoubleLeadLagAggFunction, LeadLagAggFunction.FloatLeadLagAggFunction, LeadLagAggFunction.IntLeadLagAggFunction, LeadLagAggFunction.LongLeadLagAggFunction, LeadLagAggFunction.ShortLeadLagAggFunction, LeadLagAggFunction.StringLeadLagAggFunction, LeadLagAggFunction.TimeLeadLagAggFunction, LeadLagAggFunction.TimestampLeadLagAggFunction

public abstract class LeadLagAggFunction extends org.apache.flink.table.functions.DeclarativeAggregateFunction
LEAD and LAG aggregate functions return the value of given expression evaluated at given offset. The functions only are used by over window.

LAG(input, offset, default) - Returns the value of `input` at the `offset`th row before the current row in the window. The default value of `offset` is 1 and the default value of `default` is null. If the value of `input` at the `offset`th row is null, null is returned. If there is no such offset row (e.g., when the offset is 1, the first row of the window does not have any previous row), `default` is returned.

LEAD(input, offset, default) - Returns the value of `input` at the `offset`th row after the current row in the window. The default value of `offset` is 1 and the default value of `default` is null. If the value of `input` at the `offset`th row is null, null is returned. If there is no such an offset row (e.g., when the offset is 1, the last row of the window does not have any subsequent row), `default` is returned.

These two aggregate functions are special, and only are used by over window. So here the concrete implementation is closely related to OffsetOverFrame.

See Also:
  • Constructor Details

    • LeadLagAggFunction

      public LeadLagAggFunction(int operandCount)
  • Method Details

    • operandCount

      public int operandCount()
      Specified by:
      operandCount in class org.apache.flink.table.functions.DeclarativeAggregateFunction
    • aggBufferAttributes

      public org.apache.flink.table.expressions.UnresolvedReferenceExpression[] aggBufferAttributes()
      Specified by:
      aggBufferAttributes in class org.apache.flink.table.functions.DeclarativeAggregateFunction
    • getAggBufferTypes

      public org.apache.flink.table.types.DataType[] getAggBufferTypes()
      Specified by:
      getAggBufferTypes in class org.apache.flink.table.functions.DeclarativeAggregateFunction
    • initialValuesExpressions

      public org.apache.flink.table.expressions.Expression[] initialValuesExpressions()
      Specified by:
      initialValuesExpressions in class org.apache.flink.table.functions.DeclarativeAggregateFunction
    • accumulateExpressions

      public org.apache.flink.table.expressions.Expression[] accumulateExpressions()
      Specified by:
      accumulateExpressions in class org.apache.flink.table.functions.DeclarativeAggregateFunction
    • retractExpressions

      public org.apache.flink.table.expressions.Expression[] retractExpressions()
      Specified by:
      retractExpressions in class org.apache.flink.table.functions.DeclarativeAggregateFunction
    • mergeExpressions

      public org.apache.flink.table.expressions.Expression[] mergeExpressions()
      Specified by:
      mergeExpressions in class org.apache.flink.table.functions.DeclarativeAggregateFunction
    • getValueExpression

      public org.apache.flink.table.expressions.Expression getValueExpression()
      Specified by:
      getValueExpression in class org.apache.flink.table.functions.DeclarativeAggregateFunction