-
Notifications
You must be signed in to change notification settings - Fork 13.9k
[FLINK-39436][table] Allow late data in PTFs #27935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,6 +50,7 @@ | |
| import org.apache.flink.table.planner.plan.nodes.exec.stream.ProcessTableFunctionTestUtils.PojoStateFunction; | ||
| import org.apache.flink.table.planner.plan.nodes.exec.stream.ProcessTableFunctionTestUtils.PojoStateTimeFunction; | ||
| import org.apache.flink.table.planner.plan.nodes.exec.stream.ProcessTableFunctionTestUtils.PojoWithDefaultStateFunction; | ||
| import org.apache.flink.table.planner.plan.nodes.exec.stream.ProcessTableFunctionTestUtils.RequiredTimeFunction; | ||
| import org.apache.flink.table.planner.plan.nodes.exec.stream.ProcessTableFunctionTestUtils.RowSemanticTableFunction; | ||
| import org.apache.flink.table.planner.plan.nodes.exec.stream.ProcessTableFunctionTestUtils.RowSemanticTablePassThroughFunction; | ||
| import org.apache.flink.table.planner.plan.nodes.exec.stream.ProcessTableFunctionTestUtils.ScalarArgsFunction; | ||
|
|
@@ -1075,8 +1076,8 @@ public class ProcessTableFunctionTestPrograms { | |
| "+I[Bob, {Processing input row +I[Bob, 4, 1970-01-01T00:00:00.004Z] at time 4 watermark null}, 1970-01-01T00:00:00.004Z]", | ||
| "+I[Bob, {Processing input row +I[Bob, 5, 1970-01-01T00:00:00.005Z] at time 5 watermark null}, 1970-01-01T00:00:00.005Z]", | ||
| "+I[Bob, {Processing input row +I[Bob, 6, 1970-01-01T00:00:00.006Z] at time 6 watermark null}, 1970-01-01T00:00:00.006Z]", | ||
| "+I[Bob, {Timer timeout2 fired at time 2 watermark 9223372036854775807}, 1970-01-01T00:00:00.002Z]", | ||
| "+I[Bob, {Clearing all timers at time 2 watermark 9223372036854775807}, 1970-01-01T00:00:00.002Z]") | ||
| "+I[Bob, {Timer timeout2 fired at time 5 watermark 9223372036854775807}, 1970-01-01T00:00:00.005Z]", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice, this is basically the bugfix, right? We were incorrectly firing timeout2 at 2 and now we fire corrently at 5
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not really a bug fix. It's an artifact of allowing late timer registration. |
||
| "+I[Bob, {Clearing all timers at time 5 watermark 9223372036854775807}, 1970-01-01T00:00:00.005Z]") | ||
| .build()) | ||
| .runSql( | ||
| "INSERT INTO sink SELECT * FROM f(r => TABLE t PARTITION BY name, on_time => DESCRIPTOR(ts))") | ||
|
|
@@ -1115,35 +1116,61 @@ public class ProcessTableFunctionTestPrograms { | |
| public static final TableTestProgram PROCESS_LATE_EVENTS = | ||
| TableTestProgram.of( | ||
| "process-late-events", | ||
| "test that late events are dropped in both input and when registering timers") | ||
| "test that late events enter PTF (eval and timer registration)") | ||
| .setupTemporarySystemFunction("f", LateTimersFunction.class) | ||
| .setupTableSource(TIMED_SOURCE_LATE_EVENTS) | ||
| .setupTableSink( | ||
| SinkTestStep.newBuilder("sink") | ||
| .addSchema(KEYED_TIMED_BASE_SINK_SCHEMA) | ||
| .consumedValues( | ||
| "+I[Bob, {Processing input row +I[Bob, 1, 1970-01-01T00:00:00Z] at time 0 watermark null}, 1970-01-01T00:00:00Z]", | ||
| "+I[Bob, {Registering timer t for 0 at time 0 watermark null}, 1970-01-01T00:00:00Z]", | ||
| "+I[Bob, {Registering timer bob for 0 at time 0 watermark null}, 1970-01-01T00:00:00Z]", | ||
| "+I[Bob, {Registering timer for 0 at time 0 watermark null}, 1970-01-01T00:00:00Z]", | ||
| "+I[Alice, {Processing input row +I[Alice, 1, 1970-01-01T00:00:00.001Z] at time 1 watermark -1}, 1970-01-01T00:00:00.001Z]", | ||
| "+I[Alice, {Registering timer t for 0 at time 1 watermark -1}, 1970-01-01T00:00:00.001Z]", | ||
| "+I[Alice, {Registering timer for 0 at time 1 watermark -1}, 1970-01-01T00:00:00.001Z]", | ||
| "+I[Alice, {Registering timer alice for 1 at time 1 watermark -1}, 1970-01-01T00:00:00.001Z]", | ||
| "+I[Bob, {Timer null fired at time 0 watermark 0}, 1970-01-01T00:00:00Z]", | ||
| "+I[Bob, {Registering timer again for 0 at time 0 watermark 0}, 1970-01-01T00:00:00Z]", | ||
| "+I[Alice, {Timer null fired at time 0 watermark 0}, 1970-01-01T00:00:00Z]", | ||
| "+I[Alice, {Registering timer again for 0 at time 0 watermark 0}, 1970-01-01T00:00:00Z]", | ||
| "+I[Bob, {Timer t fired at time 0 watermark 0}, 1970-01-01T00:00:00Z]", | ||
| "+I[Bob, {Registering timer again for 0 at time 0 watermark 0}, 1970-01-01T00:00:00Z]", | ||
| "+I[Alice, {Timer t fired at time 0 watermark 0}, 1970-01-01T00:00:00Z]", | ||
| "+I[Alice, {Registering timer again for 0 at time 0 watermark 0}, 1970-01-01T00:00:00Z]", | ||
| "+I[Bob, {Timer bob fired at time 0 watermark 0}, 1970-01-01T00:00:00Z]", | ||
| "+I[Bob, {Processing input row +I[Bob, 2, 1970-01-01T00:01:39.999Z] at time 99999 watermark 0}, 1970-01-01T00:01:39.999Z]", | ||
| "+I[Bob, {Registering timer t for 0 at time 99999 watermark 0}, 1970-01-01T00:01:39.999Z]", | ||
| "+I[Bob, {Registering timer for 0 at time 99999 watermark 0}, 1970-01-01T00:01:39.999Z]") | ||
| "+I[Bob, {Registering timer bob for 0 at time 99999 watermark 0}, 1970-01-01T00:01:39.999Z]", | ||
| "+I[Bob, {Registering timer for 0 at time 99999 watermark 0}, 1970-01-01T00:01:39.999Z]", | ||
| "+I[Bob, {Timer null fired at time 0 watermark 99998}, 1970-01-01T00:00:00Z]", | ||
| "+I[Bob, {Timer bob fired at time 0 watermark 99998}, 1970-01-01T00:00:00Z]", | ||
| "+I[Alice, {Timer alice fired at time 1 watermark 99998}, 1970-01-01T00:00:00.001Z]", | ||
| "+I[Alice, {Registering timer alice-again for 0 at time 1 watermark 99998}, 1970-01-01T00:00:00.001Z]", | ||
| "+I[Alice, {Timer alice-again fired at time 0 watermark 99998}, 1970-01-01T00:00:00Z]", | ||
| "+I[Bob, {Processing input row +I[Bob, 3, 1970-01-01T00:00:00.003Z] at time 3 watermark 99998}, 1970-01-01T00:00:00.003Z]", | ||
| "+I[Bob, {Registering timer bob for 0 at time 3 watermark 99998}, 1970-01-01T00:00:00.003Z]", | ||
| "+I[Bob, {Registering timer for 0 at time 3 watermark 99998}, 1970-01-01T00:00:00.003Z]", | ||
| "+I[Bob, {Processing input row +I[Bob, 4, 1970-01-01T00:00:00.004Z] at time 4 watermark 99998}, 1970-01-01T00:00:00.004Z]", | ||
| "+I[Bob, {Registering timer bob for 0 at time 4 watermark 99998}, 1970-01-01T00:00:00.004Z]", | ||
| "+I[Bob, {Registering timer for 0 at time 4 watermark 99998}, 1970-01-01T00:00:00.004Z]", | ||
| "+I[Bob, {Timer null fired at time 0 watermark 9223372036854775807}, 1970-01-01T00:00:00Z]", | ||
| "+I[Bob, {Timer bob fired at time 0 watermark 9223372036854775807}, 1970-01-01T00:00:00Z]") | ||
| .build()) | ||
| .runSql( | ||
| "INSERT INTO sink SELECT * FROM f(r => TABLE t PARTITION BY name, on_time => DESCRIPTOR(ts))") | ||
| .build(); | ||
|
|
||
| public static final TableTestProgram PROCESS_ROW_LATE_EVENTS = | ||
| TableTestProgram.of( | ||
| "process-row-late-events", | ||
| "test that late events enter a PTF with row semantics") | ||
| .setupTemporarySystemFunction("f", RequiredTimeFunction.class) | ||
| .setupTableSource(TIMED_SOURCE_LATE_EVENTS) | ||
| .setupTableSink( | ||
| SinkTestStep.newBuilder("sink") | ||
| .addSchema(TIMED_BASE_SINK_SCHEMA) | ||
| .consumedValues( | ||
| "+I[{+I[Bob, 1, 1970-01-01T00:00:00Z]}, 1970-01-01T00:00:00Z]", | ||
| "+I[{+I[Alice, 1, 1970-01-01T00:00:00.001Z]}, 1970-01-01T00:00:00.001Z]", | ||
| "+I[{+I[Bob, 2, 1970-01-01T00:01:39.999Z]}, 1970-01-01T00:01:39.999Z]", | ||
| "+I[{+I[Bob, 3, 1970-01-01T00:00:00.003Z]}, 1970-01-01T00:00:00.003Z]", | ||
| "+I[{+I[Bob, 4, 1970-01-01T00:00:00.004Z]}, 1970-01-01T00:00:00.004Z]") | ||
| .build()) | ||
| .runSql( | ||
| "INSERT INTO sink SELECT * FROM f(r => TABLE t, on_time => DESCRIPTOR(ts))") | ||
| .build(); | ||
|
|
||
| public static final TableTestProgram PROCESS_SCALAR_ARGS_TIME = | ||
| TableTestProgram.of( | ||
| "process-scalar-args-time", | ||
|
|
@@ -1187,29 +1214,33 @@ public class ProcessTableFunctionTestPrograms { | |
| public static final TableTestProgram PROCESS_OPTIONAL_ON_TIME = | ||
| TableTestProgram.of( | ||
| "process-optional-on-time", | ||
| "test optional time attribute, fire once for constant timer") | ||
| "test optional time attribute, re-fires timer for constant timer registration after time passed") | ||
| .setupTemporarySystemFunction("f", OptionalOnTimeFunction.class) | ||
| .setupTableSource(TIMED_SOURCE) | ||
| .setupTableSink( | ||
| SinkTestStep.newBuilder("sink") | ||
| .addSchema(KEYED_BASE_SINK_SCHEMA) | ||
| .consumedValues( | ||
| "+I[Bob, {Processing input row +I[Bob, 1, 1970-01-01T00:00:00Z] at time null watermark null}]", | ||
| "+I[Bob, {Registering timer t for 2 at time null watermark null}]", | ||
| "+I[Bob, {Registering timer t for 1 at time null watermark null}]", | ||
| "+I[Alice, {Processing input row +I[Alice, 1, 1970-01-01T00:00:00.001Z] at time null watermark -1}]", | ||
| "+I[Alice, {Registering timer t for 2 at time null watermark -1}]", | ||
| "+I[Alice, {Registering timer t for 1 at time null watermark -1}]", | ||
| "+I[Bob, {Processing input row +I[Bob, 2, 1970-01-01T00:00:00.002Z] at time null watermark 0}]", | ||
| "+I[Bob, {Registering timer t for 2 at time null watermark 0}]", | ||
| "+I[Bob, {Registering timer t for 1 at time null watermark 0}]", | ||
| "+I[Alice, {Timer t fired at time 1 watermark 1}]", | ||
| "+I[Bob, {Timer t fired at time 1 watermark 1}]", | ||
| "+I[Bob, {Processing input row +I[Bob, 3, 1970-01-01T00:00:00.003Z] at time null watermark 1}]", | ||
| "+I[Bob, {Registering timer t for 2 at time null watermark 1}]", | ||
| "+I[Alice, {Timer t fired at time 2 watermark 2}]", | ||
| "+I[Bob, {Timer t fired at time 2 watermark 2}]", | ||
| "+I[Bob, {Processing input row +I[Bob, 4, 1970-01-01T00:00:00.004Z] at time null watermark 2}]", | ||
| "+I[Bob, {Registering timer t for 2 at time null watermark 2}]", | ||
| "+I[Bob, {Registering timer t for 3 at time null watermark 2}]", | ||
| "+I[Bob, {Timer t fired at time 3 watermark 3}]", | ||
| "+I[Bob, {Processing input row +I[Bob, 5, 1970-01-01T00:00:00.005Z] at time null watermark 3}]", | ||
| "+I[Bob, {Registering timer t for 2 at time null watermark 3}]", | ||
| "+I[Bob, {Registering timer t for 4 at time null watermark 3}]", | ||
| "+I[Bob, {Timer t fired at time 4 watermark 4}]", | ||
| "+I[Bob, {Processing input row +I[Bob, 6, 1970-01-01T00:00:00.006Z] at time null watermark 4}]", | ||
| "+I[Bob, {Registering timer t for 2 at time null watermark 4}]") | ||
| "+I[Bob, {Registering timer t for 5 at time null watermark 4}]", | ||
| "+I[Bob, {Timer t fired at time 5 watermark 5}]") | ||
| .build()) | ||
| .runSql("INSERT INTO sink SELECT * FROM f(r => TABLE t PARTITION BY name)") | ||
| .build(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copy this to the Chinese docs as well