两种temporal join方式,首选哪一种
Two ways to do temporal join,which one is preferred
读书
它正在使用语法 JOIN ... FOR SYSTEM_TIME AS OF
进行时间连接,如下所示
SELECT
o.amount, o.currency, r.rate, o.amount * r.rate
FROM
Orders AS o
JOIN LatestRates FOR SYSTEM_TIME AS OF o.proctime AS r
ON r.currency = o.currency
还有另一种方法可以做到 temporal join
,那就是使用 TemporalTableFunction
val latestRates = rateTable.createTemporalTableFunction("ps", "currency");
tableEnv.registerFunction("LatestRates ", latestRates );
val result = tableEnv
.sqlQuery("""select o.amount, o.currency, r.rate, o.amount * r.rate from Orders as o Lateral table (LatestRates (o.ps)) d where o.currency =d.currency""");
我会问哪个是首选,在我看来第一个是首选,因为它遵循 SQL 标准来表达 Temporal table
第一种方法,使用 JOIN ... FOR SYSTEM_TIME AS OF
是首选方法。 Table#createTemporalTableFunction(...)
在 Flink 1.12 中添加了这种更好的方法时被弃用(有关详细信息,请参阅 FLIP-132 Temporal Table DDL and Temporal Table Join)。
它正在使用语法 JOIN ... FOR SYSTEM_TIME AS OF
进行时间连接,如下所示
SELECT
o.amount, o.currency, r.rate, o.amount * r.rate
FROM
Orders AS o
JOIN LatestRates FOR SYSTEM_TIME AS OF o.proctime AS r
ON r.currency = o.currency
还有另一种方法可以做到 temporal join
,那就是使用 TemporalTableFunction
val latestRates = rateTable.createTemporalTableFunction("ps", "currency");
tableEnv.registerFunction("LatestRates ", latestRates );
val result = tableEnv
.sqlQuery("""select o.amount, o.currency, r.rate, o.amount * r.rate from Orders as o Lateral table (LatestRates (o.ps)) d where o.currency =d.currency""");
我会问哪个是首选,在我看来第一个是首选,因为它遵循 SQL 标准来表达 Temporal table
第一种方法,使用 JOIN ... FOR SYSTEM_TIME AS OF
是首选方法。 Table#createTemporalTableFunction(...)
在 Flink 1.12 中添加了这种更好的方法时被弃用(有关详细信息,请参阅 FLIP-132 Temporal Table DDL and Temporal Table Join)。