padavan
padavan

Reputation: 875

Flink LEAD LAG functions in Table API

Hello i see in documentation that Flink support Lead Lag function https://nightlies.apache.org/flink/flink-docs-release-1.17/docs/dev/table/functions/systemfunctions/

But cant find how do apply in table api ?

  Table win = t
                .window(Over
                        .partitionBy($("userId"))
                        .orderBy($("userId"))
                        .as("w"))
                   .select($("userId"),  
                           $("count").lead(-1),  
                           $("count").lag(1));

enter image description here

Upvotes: 0

Views: 379

Answers (1)

Martijn Visser
Martijn Visser

Reputation: 2068

The documentation shows that there's a LEAD and LAG function in Flink SQL, but there is no implementation for them in the Table API. If you want to use these functions, you'll need to execute a SQL statement directly in your Table API application.

Something like:

tableEnv.executeSql(
  "INSERT INTO RubberOrders SELECT product, amount FROM Orders WHERE product LIKE '%Rubber%'");

But then with your necessary SQL statement of course :)

Upvotes: 1

Related Questions