水印是基于处理时间还是事件时间或两者?
Is watermark based on processing time or event time or both?
Structured Streaming 中的水印是否总是使用处理时间或事件时间或两者设置?
在 Structured Streaming 2.2 中,流水印是根据 Dataset.withWatermark 运算符中的 eventTime
列定义的事件时间来跟踪的。
withWatermark Defines an event time watermark for this Dataset. A watermark tracks a point in time before which we assume no more late data is going to arrive.
默认情况下为您提供事件时间水印。
但是您的初始数据集一开始可能没有事件时间列,因此您可以在处理时使用 current_date
或 current_timestamp
函数或其他方式自动生成一个。这将为您提供处理时间水印(基于自定义生成的列)。
在最通用的解决方案中使用 KeyValueGroupedDataset.flatMapGroupsWithState, you can pre-define the strategies or write a custom one. That's why they call it a solution for Arbitrary Stateful Aggregations in Structured Streaming。
flatMapGroupsWithState Applies the given function to each group of data, while maintaining a user-defined per-group state.
Structured Streaming 中的水印是否总是使用处理时间或事件时间或两者设置?
在 Structured Streaming 2.2 中,流水印是根据 Dataset.withWatermark 运算符中的 eventTime
列定义的事件时间来跟踪的。
withWatermark Defines an event time watermark for this Dataset. A watermark tracks a point in time before which we assume no more late data is going to arrive.
默认情况下为您提供事件时间水印。
但是您的初始数据集一开始可能没有事件时间列,因此您可以在处理时使用 current_date
或 current_timestamp
函数或其他方式自动生成一个。这将为您提供处理时间水印(基于自定义生成的列)。
在最通用的解决方案中使用 KeyValueGroupedDataset.flatMapGroupsWithState, you can pre-define the strategies or write a custom one. That's why they call it a solution for Arbitrary Stateful Aggregations in Structured Streaming。
flatMapGroupsWithState Applies the given function to each group of data, while maintaining a user-defined per-group state.