-
Notifications
You must be signed in to change notification settings - Fork 13.8k
[FLINK-19317] Make EventTime the default TimeCharacteristic #13509
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
[FLINK-19317] Make EventTime the default TimeCharacteristic #13509
Conversation
|
Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community Automated ChecksLast check on commit a0a68de (Fri Feb 19 07:32:33 UTC 2021) Warnings:
Mention the bot in a comment to re-run the automated checks. Review Progress
Please see the Pull Request Review Guide for a full explanation of the review process. DetailsThe Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required Bot commandsThe @flinkbot bot supports the following commands:
|
dawidwys
left a comment
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.
Overall looks good!
Shall we remove also references to timeWindow from docs? There are quite a few of them.
Side note: have you tried removing the setTimeCharacteristics? Basically the same experiment as you did for timeWindow? I'd be curious, how easy it would, because we are deprecating the TimeCharacteristics.
...amples-streaming/src/main/java/org/apache/flink/streaming/examples/async/AsyncIOExample.java
Show resolved
Hide resolved
| // build new model on every second of new data | ||
| val trainingData: DataStream[Int] = env.addSource(new FiniteTrainingDataSource) | ||
| val newData: DataStream[Int] = env.addSource(new FiniteNewDataSource) | ||
| val trainingData: DataStream[Integer] = env.addSource(new FiniteTrainingDataSource) |
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.
Why did we have to change to java classes here?
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.
The reason is that the explicit window assigners are usually a WindowAssigner<Object, TimeWindow>. This doesn't work for Scala Int, Long, etc. because they don't extend from Object but from AnyVal, so the Scala compiler will not allow it. It's not pretty, but I think the example is pretty artificial and in any real-world use case we would never have a DataStream of primitives.
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.
I see. Thanks for the explanation.
| * The time characteristic defines how the system determines time for time-dependent order and | ||
| * operations that depend on time (such as time windows). | ||
| * | ||
| * @deprecated In Flink 1.12 the default stream time characteristic has been changed to {@link |
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.
nit: I am not entirely sure, but I think 1.12 is the first release with python DataStream API. If that's the case I think we don't need to mention the change of the default value here.
It doesn't harm though, therefore I am fine with either.
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.
Why do you mention Python here?
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.
Sorry, my bad. Before this class there were python files and I somehow confused this with the python equivalent.
BTW, do you think we should deprecate the setStreamTimeCharacteristic in python as well (or even remove it, as it was added in 1.12?)
|
BTW, I forgot to mention I really liked commit messages! |
|
@aljoscha I am looking at the PR now, but I was wondering if we can deprecate the |
kl0u
left a comment
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.
I had some minor comments on the PR. I cannot spot any serious problem so feel free to integrate as many of my comments as you think and merge after Azure gives green.
| * TimeCharacteristic#EventTime}, thus you don't need to call this method for enabling | ||
| * event-time support anymore. Explicitly using processing-time windows and timers works in | ||
| * event-time mode. If you need to disable watermarks, please use {@link | ||
| * ExecutionConfig#setAutoWatermarkInterval(long)}. If you are using {@link |
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.
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.
Good point! I would update the Javadoc of setAutoWatermarkInterval() to mention that setting it to 0 will disable it. I'm reluctant to add it here because the message is already very long. WDYT?
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.
I forgot to say that the
else {
getConfig().setAutoWatermarkInterval(200);
}
is not strictly needed anymore, as 200 is the new default value.
|
|
||
| private boolean forceAvro = false; | ||
| private long autoWatermarkInterval = 0; | ||
| private long autoWatermarkInterval = 200; |
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.
nit: Make the 200 a static var with a descriptive name instead of a "magic" number.
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.
I can add a static final DEFAULT_WATERMARK_INTERVAL but then it would basically be
private static final long DEFAULT_WATERMARK_INTERVAL = 200;
private long autoWatermarkInterval = DEFAULT_WATERMARK_INTERVAL;
except that we might but the default at the top. If you think it would help I can do it.
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.
I do not think it contributes to anything for now. It is just that if in the future someone, for whatever reason, wants to do a check like: if (interval == DEFAULT) ..., or he/she wants to reset the interval to the default, the literal 200 would be a bit obscure instead of a DEFAULT_WM_INTERVAL. But again, it does not add any value for now.
| * In a real use case you should use proper timestamps and an appropriate {@link | ||
| * WatermarkStrategy}. | ||
| */ | ||
| private static class IngestionTimeWatermarkStrategy<T> implements WatermarkStrategy<T> { |
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.
This WatermarkStrategy seems to be used extensively in the tests. Couldn't we extract it somewhere and make it reusable?
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.
I had this in the commit message:
I removed calls to set IngestionTime and replaced them by an explicit
IngestionTimeWatermarkStrategy. I duplicated the same
IngestionTimeWatermarkStrategy in all the examples/tests because I
explicitly didn't want to add an IngestionTimeWatermarkStrategy in one
of the core packages so that it is not discoverable because I think we
shouldn't encourage users to use ingestion time.
what do you think?
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.
I was thinking more of a testing module, like the MockSource, but I think you are right to not expose it even there.
|
Thanks for the reviews! @dawidwys I didn't try removing
@kl0u I'm also torn on deprecating |
|
@aljoscha My only point was that I think that the message to the user to not set the time characteristic is sent by deprecating the |
This is part of the FLIP-134 (Batch execution for the DataStream API) work. Event time is the only sensible time characteristic for batch processing. We therefore change the default value of the TimeCharacteristic from ProcessingTime to EventTime. This means the DataStream API programs that were using event time before now just work without manually changing this setting. Processing-time programs will also still work, because using processing-time timers is not dependent on the TimeCharacteristic. DataStream programs that don't set a TimestampAssigner or WatermarkStrategy will also still work if they don't use operations that don't rely on (event-time) timestamps. This is true for both BATCH and STREAMING execution mode. With this change, users don't need to call setStreamTimeCharacteristic(EventTime) anymore. We will make sure they learn of this by deprecating the method in a follow-up commit. The only real user-visible change of this is that programs that used the KeyedStream.timeWindow()/DataStream.timeWindow() operation, which is dependent on the TimeCharacteristic will now use event time by default. We don't think this operation is useful because the behaviour can be surprising. We recommend users always use an explicit processing-time window or event-time window. We also change the default watermark interval from 0 (disabled) to 200 to match the previous behaviour of calling setStreamTimeCharacteristic(EventTime).
… (java) I'm just removing calls the set EventTime because that's the new default now. I'm also removing most calls to set ProcessingTime because it's not needed for making processing-time timers/windows work. I only left it for some tests that check specific failure behavior. I removed calls to set IngestionTime and replaced them by an explicit IngestionTimeWatermarkStrategy. I duplicated the same IngestionTimeWatermarkStrategy in all the examples/tests because I explicitly didn't want to add an IngestionTimeWatermarkStrategy in one of the core packages so that it is not discoverable because I think we shouldn't encourage users to use ingestion time.
… (scala) I'm just removing calls the set EventTime because that's the new default now. I'm also removing most calls to set ProcessingTime because it's not needed for making processing-time timers/windows work. I only left it for some tests that check specific failure behavior. I removed calls to set IngestionTime and replaced them by an explicit IngestionTimeWatermarkStrategy. I duplicated the same IngestionTimeWatermarkStrategy in all the examples/tests because I explicitly didn't want to add an IngestionTimeWatermarkStrategy in one of the core packages so that it is not discoverable because I think we shouldn't encourage users to use ingestion time.
I remove most usages where EventTime is set and remove copy that talks about the default. In general, we should discourage using the stream time characteristic as much as possible.
…eristic After FLINK-19317 and FLINK-19318 we don't need this setting anymore. Using (explicit) processing-time windows and processing-time timers work fine in a program that has EventTime set as a time characteristic and once we deprecate timeWindow() there are not other operations that change behaviour depending on the time characteristic so there's no need to ever change from the new default of event-time. Similarly, the IngestionTime setting can be achieved in the future by providing an ingestion-time WatermarkStrategy.
bc7bf58 to
a0a68de
Compare
|
Regarding |
|
Thanks for the reviews! I merged. |
What is the purpose of the change
This is part of http://s.apache.org/FLIP-134 (Batch execution for the DataStream API).
Brief change log
Please look at each commit message which describes in detail what is happening.
In commit no 1 I also change all usage of
timeWindow()to use explicit processing-time or event-time windows. For this, I temporarily removedtimeWindow()from the API and made sure everything compiles afterward. You can follow the process because I still left the removal and the revert of the removal in the commits.timeWindow()setStreamTimeCharacteristic(java). I'm removing almost all calls because we're planning to deprecate/remove the methodsetStreamTimeCharacteristic(scala)setStreamTimeCharacteristic, this also adds a good deprecation messageVerifying this change
Existing tests cover the changes.
Does this pull request potentially affect one of the following parts:
@Public(Evolving): yesDocumentation
I fix the javadocs, introduce a good deprecation text for
setStreamTimeCharacteristic()and update the docs.