Class ToTimestampLtzFunction

java.lang.Object
org.apache.flink.table.functions.UserDefinedFunction
org.apache.flink.table.functions.ScalarFunction
org.apache.flink.table.runtime.functions.scalar.BuiltInScalarFunction
org.apache.flink.table.runtime.functions.scalar.ToTimestampLtzFunction
All Implemented Interfaces:
Serializable, org.apache.flink.table.functions.FunctionDefinition

@Internal public class ToTimestampLtzFunction extends BuiltInScalarFunction
Implementation of BuiltInFunctionDefinitions.TO_TIMESTAMP_LTZ.

A function that converts various time formats to TIMESTAMP_LTZ type.

Supported function signatures:

  • TO_TIMESTAMP_LTZ(numeric) -> TIMESTAMP_LTZ(3)
    Converts numeric epoch time in milliseconds to timestamp with local timezone
  • TO_TIMESTAMP_LTZ(numeric, precision) -> TIMESTAMP_LTZ(precision)
    Converts numeric epoch time to timestamp with specified precision (0 as seconds, 3 as milliseconds)
  • TO_TIMESTAMP_LTZ(timestamp) -> TIMESTAMP_LTZ(3)
    Parses string timestamp using default format 'yyyy-MM-dd HH:mm:ss'
  • TO_TIMESTAMP_LTZ(timestamp, format) -> TIMESTAMP_LTZ(3)
    Parses string timestamp using input string of format
  • TO_TIMESTAMP_LTZ(timestamp, format, timezone) -> TIMESTAMP_LTZ(3)
    Parses string timestamp using input strings of format and timezone

Example:


 TO_TIMESTAMP_LTZ('2023-01-01 10:00:00')  // Parses string using default format
 TO_TIMESTAMP_LTZ(1234567890123)  // Converts epoch milliseconds
 TO_TIMESTAMP_LTZ(1234567890, 0)     // Converts epoch seconds
 TO_TIMESTAMP_LTZ(1234567890123, 3)  // Converts epoch milliseconds
 TO_TIMESTAMP_LTZ('2023-01-01 10:00:00')  // Parses string using default format
 TO_TIMESTAMP_LTZ('2023-01-01T10:00:00', 'yyyy-MM-dd\'T\'HH:mm:ss') // Parses string using input format
 TO_TIMESTAMP_LTZ('2023-01-01 10:00:00', 'yyyy-MM-dd HH:mm:ss', 'UTC') // Parses string using input format and timezone
 
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    ToTimestampLtzFunction(org.apache.flink.table.functions.SpecializedFunction.SpecializedContext context)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.apache.flink.table.data.TimestampData
    eval(Number epoch)
     
    org.apache.flink.table.data.TimestampData
    eval(Number epoch, Integer precision)
     
    org.apache.flink.table.data.TimestampData
    eval(org.apache.flink.table.data.DecimalData epoch)
     
    org.apache.flink.table.data.TimestampData
    eval(org.apache.flink.table.data.DecimalData epoch, Integer precision)
     
    org.apache.flink.table.data.TimestampData
    eval(org.apache.flink.table.data.StringData timestamp)
     
    org.apache.flink.table.data.TimestampData
    eval(org.apache.flink.table.data.StringData timestamp, org.apache.flink.table.data.StringData format)
     
    org.apache.flink.table.data.TimestampData
    eval(org.apache.flink.table.data.StringData dateStr, org.apache.flink.table.data.StringData format, org.apache.flink.table.data.StringData timezone)
     

    Methods inherited from class org.apache.flink.table.runtime.functions.scalar.BuiltInScalarFunction

    getArgumentDataTypes, getOutputDataType, getRequirements, getTypeInference, isDeterministic

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

    getKind, getParameterTypes, 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

    supportsConstantFolding
  • Constructor Details

    • ToTimestampLtzFunction

      public ToTimestampLtzFunction(org.apache.flink.table.functions.SpecializedFunction.SpecializedContext context)
  • Method Details

    • eval

      @Nullable public org.apache.flink.table.data.TimestampData eval(Number epoch, Integer precision)
    • eval

      @Nullable public org.apache.flink.table.data.TimestampData eval(org.apache.flink.table.data.DecimalData epoch, Integer precision)
    • eval

      @Nullable public org.apache.flink.table.data.TimestampData eval(Number epoch)
    • eval

      @Nullable public org.apache.flink.table.data.TimestampData eval(org.apache.flink.table.data.DecimalData epoch)
    • eval

      @Nullable public org.apache.flink.table.data.TimestampData eval(org.apache.flink.table.data.StringData timestamp)
    • eval

      @Nullable public org.apache.flink.table.data.TimestampData eval(org.apache.flink.table.data.StringData timestamp, org.apache.flink.table.data.StringData format)
    • eval

      @Nullable public org.apache.flink.table.data.TimestampData eval(org.apache.flink.table.data.StringData dateStr, org.apache.flink.table.data.StringData format, org.apache.flink.table.data.StringData timezone)