Merge pull request #30095 from taosdata/merge/mainto3.0
merge: from mainto 3.0 branch
This commit is contained in:
commit
4bddf29c7c
|
@ -145,20 +145,19 @@ Query OK, 10 row(s) in set (2.415961s)
|
|||
|
||||
In TDengine, you can use the window clause to perform aggregation queries by time window partitioning, which is particularly suitable for scenarios requiring analysis of large amounts of time-series data, such as smart meters collecting data every 10s but needing to query the average temperature every 1min.
|
||||
|
||||
The window clause allows you to partition the queried data set by windows and aggregate the data within each window, including:
|
||||
|
||||
- Time window (time window)
|
||||
- State window (status window)
|
||||
- Session window (session window)
|
||||
- Event window (event window)
|
||||
|
||||
The logic of window partitioning is shown in the following image:
|
||||
The window clause allows you to partition the queried data set by windows and aggregate the data within each window. The logic of window partitioning is shown in the following image:
|
||||
|
||||
<figure>
|
||||
<Image img={windowModel} alt="Windowing description"/>
|
||||
<figcaption>Figure 1. Windowing logic</figcaption>
|
||||
</figure>
|
||||
|
||||
- Time Window: Data is divided based on time intervals, supporting sliding and tumbling time windows, suitable for data aggregation over fixed time periods.
|
||||
- Status Window: Windows are divided based on changes in device status values, with data of the same status value grouped into one window, which closes when the status value changes.
|
||||
- Session Window: Sessions are divided based on the differences in record timestamps, with records having a timestamp interval less than the predefined value belonging to the same session.
|
||||
- Event Window: Windows are dynamically divided based on the start and end conditions of events, opening when the start condition is met and closing when the end condition is met.
|
||||
- Count Window: Windows are divided based on the number of data rows, with each window consisting of a specified number of rows for aggregation calculations.
|
||||
|
||||
The syntax for the window clause is as follows:
|
||||
|
||||
```sql
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 103 KiB |
Binary file not shown.
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 47 KiB |
Binary file not shown.
Before Width: | Height: | Size: 164 KiB After Width: | Height: | Size: 95 KiB |
|
@ -140,17 +140,16 @@ Query OK, 10 row(s) in set (2.415961s)
|
|||
|
||||
在 TDengine 中,你可以使用窗口子句来实现按时间窗口切分方式进行聚合结果查询,这种查询方式特别适用于需要对大量时间序列数据进行分析的场景,例如智能电表每 10s 采集一次数据,但需要查询每隔 1min 的温度平均值。
|
||||
|
||||
窗口子句允许你针对查询的数据集合按照窗口进行切分,并对每个窗口内的数据进行聚合,包含:
|
||||
- 时间窗口(time window)
|
||||
- 状态窗口(status window)
|
||||
- 会话窗口(session window)
|
||||
- 事件窗口(event window)
|
||||
- 计数窗口(count window)
|
||||
|
||||
窗口划分逻辑如下图所示:
|
||||
窗口子句允许你针对查询的数据集合按照窗口进行切分,并对每个窗口内的数据进行聚合。窗口划分逻辑如下图所示。
|
||||
|
||||
<img src={win} width="500" alt="常用窗口划分逻辑" />
|
||||
|
||||
- 时间窗口(time window):根据时间间隔划分数据,支持滑动时间窗口和翻转时间窗口,适用于按固定时间周期进行数据聚合。
|
||||
- 状态窗口(status window):基于设备状态值的变化划分窗口,相同状态值的数据归为一个窗口,状态值改变时窗口关闭。
|
||||
- 会话窗口(session window):根据记录的时间戳差异划分会话,时间戳间隔小于预设值的记录属于同一会话。
|
||||
- 事件窗口(event window):基于事件的开始条件和结束条件动态划分窗口,满足开始条件时窗口开启,满足结束条件时窗口关闭。
|
||||
- 计数窗口(count window):根据数据行数划分窗口,每达到指定行数即为一个窗口,并进行聚合计算。
|
||||
|
||||
窗口子句语法如下:
|
||||
|
||||
```sql
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue