跳到主要内容
版本: Dev

CTF

介绍

CTF 意指: Create Temporal Function, 用于在 FlinkSQL 中定义临时函数.

CREATE TEMPORAL FUNCTION 实现在sql中定义Defining a Temporal Table Function 功能,语法结构如下:

CREATE TEMPORAL [TEMPORARY|TEMPORARY SYSTEM] FUNCTION  
[IF NOT EXISTS] [catalog_name.][db_name.]function_name
AS SELECT update_time, target FROM tableName

其中update_time列为版本时间属性列,target 是一个或多个键值列, talbeName表示版本表名。

create temporal temporary function 
IF NOT EXISTS rates
as select update_time, currency from currency_rates;

该语句等价table API示例:

    TemporalTableFunction rates = tEnv
.from("currency_rates")
.createTemporalTableFunction("update_time", "currency");

tEnv.createTemporarySystemFunction("rates", rates);