score:1

Accepted answer

the error message is really not clear, although what's going on is a clash between the java syntax and the scala syntax for the tumbling window expression.

this is the java syntax for a tumbling window, and doesn't seem to be accepted by the scala api:

// this does not work in scala:
//  val result = table.window(tumble.over(lit(4).second()).on($"pt").as("w"))

somehow when called from scala the "4" seems to end up wrapped one time too many and fails to be converted into the "4 seconds" duration,

this scala syntax solves it:

import org.apache.flink.table.api._

...
// this works in scala:
table.window(tumble.over(4.second()).on($"pt").as("w"))

in both cases it's the same second() function that gets called, although in the second case its argument is having the expected type.

note that you can also have fun with this kind of syntax:

val result = table.window(tumble over 4.second on $"pt" as "w")

Related Query

More Query from same tag