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 Classes
    Modifier and Type
    Class
    Description
    static class 
    Generic accumulator for representing state.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Generic runtime function that will be called with different kind of instances for input depending on actual call in the query.
     
    org.apache.flink.table.types.inference.TypeInference
    getTypeInference(org.apache.flink.table.catalog.DataTypeFactory typeFactory)
    Declares the TypeInference of this function.
    org.apache.flink.types.Row
     

    Methods inherited from class org.apache.flink.table.functions.AggregateFunction

    getKind

    Methods inherited from class org.apache.flink.table.functions.ImperativeAggregateFunction

    getAccumulatorType, getResultType

    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
  • 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 the TypeInference of this function. It specifies:
      • which argument types are supported when calling this function,
      • which DataType.getConversionClass() should be used when calling the JVM method accumulate(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:
      getTypeInference in interface org.apache.flink.table.functions.FunctionDefinition
      Overrides:
      getTypeInference in class org.apache.flink.table.functions.AggregateFunction<org.apache.flink.types.Row,LastDatedValueFunction.Accumulator<T>>
    • createAccumulator

      public LastDatedValueFunction.Accumulator<T> createAccumulator()
      Specified by:
      createAccumulator in class org.apache.flink.table.functions.ImperativeAggregateFunction<org.apache.flink.types.Row,LastDatedValueFunction.Accumulator<T>>
    • accumulate

      public void accumulate(LastDatedValueFunction.Accumulator<T> acc, T input, LocalDate date)
      Generic runtime function that will be called with different kind of instances for input depending on actual call in the query.
    • getValue

      public org.apache.flink.types.Row getValue(LastDatedValueFunction.Accumulator<T> acc)
      Specified by:
      getValue in class org.apache.flink.table.functions.AggregateFunction<org.apache.flink.types.Row,LastDatedValueFunction.Accumulator<T>>