Class LastDatedValueFunction<T>
java.lang.Object
org.apache.flink.table.functions.UserDefinedFunction
org.apache.flink.table.functions.ImperativeAggregateFunction<T,ACC>
org.apache.flink.table.functions.AggregateFunction<org.apache.flink.types.Row,LastDatedValueFunction.Accumulator<T>>
org.apache.flink.table.examples.java.functions.LastDatedValueFunction<T>
- Type Parameters:
T- input value
- All Implemented Interfaces:
Serializable,org.apache.flink.table.functions.FunctionDefinition
public final class LastDatedValueFunction<T>
extends org.apache.flink.table.functions.AggregateFunction<org.apache.flink.types.Row,LastDatedValueFunction.Accumulator<T>>
Implementation of an
AggregateFunction that returns a row containing the latest non-null
value with its corresponding date.
The function uses a custom TypeInference and thus disables any of the default
reflection-based logic. It has a generic parameter T which will result in Object
(due to type erasure) during runtime. The TypeInference will provide the necessary
information how to call accumulate(...) for the given call in the query.
For code readability, we might use some internal utility methods that should rarely change. Implementers can copy those if they don't want to rely on non-official API.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classGeneric accumulator for representing state. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaccumulate(LastDatedValueFunction.Accumulator<T> acc, T input, LocalDate date) Generic runtime function that will be called with different kind of instances forinputdepending on actual call in the query.org.apache.flink.table.types.inference.TypeInferencegetTypeInference(org.apache.flink.table.catalog.DataTypeFactory typeFactory) Declares theTypeInferenceof this function.org.apache.flink.types.RowMethods inherited from class org.apache.flink.table.functions.AggregateFunction
getKindMethods inherited from class org.apache.flink.table.functions.ImperativeAggregateFunction
getAccumulatorType, getResultTypeMethods inherited from class org.apache.flink.table.functions.UserDefinedFunction
close, functionIdentifier, open, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.flink.table.functions.FunctionDefinition
getRequirements, isDeterministic, supportsConstantFolding
-
Constructor Details
-
LastDatedValueFunction
public LastDatedValueFunction()
-
-
Method Details
-
getTypeInference
public org.apache.flink.table.types.inference.TypeInference getTypeInference(org.apache.flink.table.catalog.DataTypeFactory typeFactory) Declares theTypeInferenceof this function. It specifies:- which argument types are supported when calling this function,
- which
DataType.getConversionClass()should be used when calling the JVM methodaccumulate(Accumulator, Object, LocalDate)during runtime, - a similar strategy how to derive an accumulator type,
- and a similar strategy how to derive the output type.
- Specified by:
getTypeInferencein interfaceorg.apache.flink.table.functions.FunctionDefinition- Overrides:
getTypeInferencein classorg.apache.flink.table.functions.AggregateFunction<org.apache.flink.types.Row,LastDatedValueFunction.Accumulator<T>>
-
createAccumulator
- Specified by:
createAccumulatorin classorg.apache.flink.table.functions.ImperativeAggregateFunction<org.apache.flink.types.Row,LastDatedValueFunction.Accumulator<T>>
-
accumulate
Generic runtime function that will be called with different kind of instances forinputdepending on actual call in the query. -
getValue
- Specified by:
getValuein classorg.apache.flink.table.functions.AggregateFunction<org.apache.flink.types.Row,LastDatedValueFunction.Accumulator<T>>
-