gpt4 book ai didi

azure - 流分析:When using a TUMBLING WINDOW is the start time of the window start based on the earliest time in the stream or start time of the job?

转载 作者:行者123 更新时间:2023-12-03 02:15:42 29 4
gpt4 key购买 nike

上下文

我一直在阅读有关如何将 TUMBLINGWINDOW 函数与 TIMSTAMP BY 子句一起使用的文档,但似乎找不到有关如何计算包含 TUMBLING WINDOW 和 TIMESTAMP BY 字段的查询的开始日期的明确解释(如果它存在于某个地方,那么一定是错过了)。

以下是我一直在查看的文档的链接:

我在 TUMBLING WINDOW LINK 中的“时间考虑因素”部分下面引用(这是引起我的问​​题的主要来源)

Time Consideration

"Every window operation outputs event at the end of the window. The windows of Azure Stream Analytics are opened at the window start time and closed at the window end time. For example, if you have a 5 minute window from 12:00 AM to 12:05 AM all events with timestamp greater than 12:00 AM and up to timestamp 12:05 AM inclusive will be included within this window. The output of the window will be a single event based on the aggregate function used with a timestamp equal to the window end time. The timestamp of the output event of the window can be projected in the SELECT statement using the System.Timestamp() property using an alias."

它提到了 5 分钟的窗口,但似乎没有详细说明为什么此时启动 5 分钟的窗口,以及最重要的是这将如何概括。

注意:我知道这一点可能超出了本文档的范围,但我也没有在其他地方找到对此的明确解释。

问题

假设我有以下代码(从文档复制并进行了少量修改)

SELECT System.Timestamp() AS WindowEnd, TollId, COUNT(*)  
FROM Input TIMESTAMP BY EntryTime
GROUP BY TumblingWindow(Duration(day, 1)), TollId
  • 如果我有数据流,我创建的窗口的开始日期时间是如何选择的?
    • 它是否基于 EntryTime 中的最早时间(这是我选择的字段时间戳),然后从该时间逻辑上形成一个初始窗口来包含 它是否取决于我开始运行流作业的时间(从作业开始时及之后创建窗口)?
  • 在它取决于我何时启动流作业的情况下,确保启动窗口的最佳方法是什么,以便它包含初始(和后续)窗口中所需的所有数据(在我的场景中,按实际聚合)全天,例如从 2022-02-22 T00:00:00 开始到 2022-02-23 T00:00:00) ?
    • 是否可以将开始时间设置为自定义并选择在一天的开始时开始?例如,我将作业设置为在 2022 年 2 月 22 日 T00:00:00 开始,这样它将在此时启动窗口,以便第一个滚动窗口(以及后续窗口)将包含从 2022 年 2 月 2 日开始的全天数据-22 T00:00:00 按天计算。

想法

到目前为止,我一直假设我在 TIMESTAMP BY 子句中选择的任何字段(例如上面代码片段中的 EntryTime)都会定义创建窗口的字段,然后取决于所选的 TUMBLINGWINDOW 函数参数(例如上面的代码片段中的按天计算)将处理所选时间戳字段如何“加窗”或切片。然后,流分析将根据作业开始时源时间字段中存在的最早日期来处理窗口创建(例如,即使我在 2022 年 2 月 22 日 T09:00:00 UTC 开始作业,如果数据存在)对于 2022-02-21 天,那么查询将输出该天的数据 2022-02-21T00:00:00 UTC 到 2022-02-22T00:00:00 UTC,因为此时已经过去了,并且当前窗口(2022-02-22T00:00:00 到 2022-02-23T00:00:00)将在该窗口完成后填充。

最佳答案

来自此处的文档:https://learn.microsoft.com/en-us/stream-analytics-query/windowing-azure-stream-analytics#understanding-windows

Every window operation outputs event at the end of the window. The windows of Azure Stream Analytics are opened at the window start time and closed at the window end time. For example, if you have a 5 minute window from 12:00 AM to 12:05 AM all events with timestamp greater than 12:00 AM and up to timestamp 12:05 AM inclusive will be included within this window. The output of the window will be a single event based on the aggregate function used with a timestamp equal to the window end time. The timestamp of the output event of the window can be projected in the SELECT statement using the System.Timestamp() property using an alias. Every window automatically aligns itself to the zeroth hour. For example, a 5 minute tumbling window will align itself to (12:00-12:05] , (12:05-12:10], ..., and so on.

如果您有想要输出的历史数据,您可以将自定义查询开始时间设置为流媒体源的最大缓存(通常为 7 天)之前的任意点,或者设置为查询上次停止的时间点,这样您就不会在维护时段内丢失任何数据。

但是,查询将仅输出时间戳晚于查询开始时间的数据。

因此,假设您的第一个数据的时间戳为 2022-02-20 01:23:00,第二个数据的时间戳为 2022-02-21 15:08:00 。您于 2022-02-21 14:00:00 开始流式传输作业,因此您的 10 分钟窗口以 21 日午夜为基础,然后从那里开始在 10 分钟窗口中进行。在 21 日的 15:00 - 15:10 窗口之前,查询不会输出任何内容,因为这是第一个发布查询开始时间并包含数据的窗口。在这种情况下,您可以了解窗口的工作原理以及为什么不会输出带有 2022-02-20 01:23:00 时间戳的数据。

关于azure - 流分析:When using a TUMBLING WINDOW is the start time of the window start based on the earliest time in the stream or start time of the job?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71227679/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com