Merge pull request #30095 from taosdata/merge/mainto3.0

merge: from mainto 3.0 branch
This commit is contained in:
Simon Guan 2025-03-10 14:53:39 +08:00 committed by GitHub
commit 4bddf29c7c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 804 additions and 815 deletions

View File

@ -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

View File

@ -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