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
,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 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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LeadLagAggFunction.BooleanLeadLagAggFunction
BooleanLeadLagAggFunction.static class
LeadLagAggFunction.ByteLeadLagAggFunction
ByteLeadLagAggFunction.static class
LeadLagAggFunction.CharLeadLagAggFunction
CharLeadLagAggFunction.static class
LeadLagAggFunction.DateLeadLagAggFunction
DateLeadLagAggFunction.static class
LeadLagAggFunction.DecimalLeadLagAggFunction
DecimalLeadLagAggFunction.static class
LeadLagAggFunction.DoubleLeadLagAggFunction
DoubleLeadLagAggFunction.static class
LeadLagAggFunction.FloatLeadLagAggFunction
FloatLeadLagAggFunction.static class
LeadLagAggFunction.IntLeadLagAggFunction
IntLeadLagAggFunction.static class
LeadLagAggFunction.LongLeadLagAggFunction
LongLeadLagAggFunction.static class
LeadLagAggFunction.ShortLeadLagAggFunction
ShortLeadLagAggFunction.static class
LeadLagAggFunction.StringLeadLagAggFunction
StringLeadLagAggFunction.static class
LeadLagAggFunction.TimeLeadLagAggFunction
TimeLeadLagAggFunction.static class
LeadLagAggFunction.TimestampLeadLagAggFunction
TimestampLeadLagAggFunction.
-
Constructor Summary
Constructors Constructor Description LeadLagAggFunction(int operandCount)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Expression[]
accumulateExpressions()
Expressions for accumulating the mutable aggregation buffer based on an input row.UnresolvedReferenceExpression[]
aggBufferAttributes()
All fields of the aggregate buffer.DataType[]
getAggBufferTypes()
All types of the aggregate buffer.Expression
getValueExpression()
An expression which returns the final value for this aggregate function.Expression[]
initialValuesExpressions()
Expressions for initializing empty aggregation buffers.Expression[]
mergeExpressions()
A sequence of expressions for merging two aggregation buffers together.int
operandCount()
How many operands your function will deal with.Expression[]
retractExpressions()
Expressions for retracting the mutable aggregation buffer based on an input row.-
Methods inherited from class org.apache.flink.table.functions.DeclarativeAggregateFunction
getKind, getResultType, getTypeInference, mergeOperand, mergeOperands, operand, operands
-
Methods inherited from class org.apache.flink.table.functions.UserDefinedFunction
close, functionIdentifier, open, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.flink.table.functions.FunctionDefinition
getRequirements, isDeterministic, supportsConstantFolding
-
-
-
-
Method Detail
-
operandCount
public int operandCount()
Description copied from class:DeclarativeAggregateFunction
How many operands your function will deal with.- Specified by:
operandCount
in classDeclarativeAggregateFunction
-
aggBufferAttributes
public UnresolvedReferenceExpression[] aggBufferAttributes()
Description copied from class:DeclarativeAggregateFunction
All fields of the aggregate buffer.- Specified by:
aggBufferAttributes
in classDeclarativeAggregateFunction
-
getAggBufferTypes
public DataType[] getAggBufferTypes()
Description copied from class:DeclarativeAggregateFunction
All types of the aggregate buffer.- Specified by:
getAggBufferTypes
in classDeclarativeAggregateFunction
-
initialValuesExpressions
public Expression[] initialValuesExpressions()
Description copied from class:DeclarativeAggregateFunction
Expressions for initializing empty aggregation buffers.- Specified by:
initialValuesExpressions
in classDeclarativeAggregateFunction
-
accumulateExpressions
public Expression[] accumulateExpressions()
Description copied from class:DeclarativeAggregateFunction
Expressions for accumulating the mutable aggregation buffer based on an input row.- Specified by:
accumulateExpressions
in classDeclarativeAggregateFunction
-
retractExpressions
public Expression[] retractExpressions()
Description copied from class:DeclarativeAggregateFunction
Expressions for retracting the mutable aggregation buffer based on an input row.- Specified by:
retractExpressions
in classDeclarativeAggregateFunction
-
mergeExpressions
public Expression[] mergeExpressions()
Description copied from class:DeclarativeAggregateFunction
A sequence of expressions for merging two aggregation buffers together. When defining these expressions, you can use the syntaxattributeName
andmergeOperand(attributeName)
to refer to the attributes corresponding to each of the buffers being merged.- Specified by:
mergeExpressions
in classDeclarativeAggregateFunction
-
getValueExpression
public Expression getValueExpression()
Description copied from class:DeclarativeAggregateFunction
An expression which returns the final value for this aggregate function.- Specified by:
getValueExpression
in classDeclarativeAggregateFunction
-
-