From 34b0ecb06cff32789582bcb00dd95469501960ec Mon Sep 17 00:00:00 2001 From: W1y1r <2730956796@qq.com> Date: Tue, 20 May 2025 11:25:38 +0800 Subject: [PATCH] Multi device downsampling alignment query --- .../Master/Table/Basic-Concept/Query-Data.md | 29 ++++++++++++++++++- .../Master/Table/SQL-Manual/Nested-Queries.md | 2 +- .../latest-Table/Basic-Concept/Query-Data.md | 28 +++++++++++++++++- .../latest-Table/SQL-Manual/Nested-Queries.md | 2 +- .../Master/Table/Basic-Concept/Query-Data.md | 29 ++++++++++++++++++- .../Master/Table/SQL-Manual/Nested-Queries.md | 2 +- .../latest-Table/Basic-Concept/Query-Data.md | 29 ++++++++++++++++++- .../latest-Table/SQL-Manual/Nested-Queries.md | 2 +- 8 files changed, 115 insertions(+), 8 deletions(-) diff --git a/src/UserGuide/Master/Table/Basic-Concept/Query-Data.md b/src/UserGuide/Master/Table/Basic-Concept/Query-Data.md index 007ecfba9..6f8707401 100644 --- a/src/UserGuide/Master/Table/Basic-Concept/Query-Data.md +++ b/src/UserGuide/Master/Table/Basic-Concept/Query-Data.md @@ -140,6 +140,33 @@ Total line number = 7 It costs 0.106s ``` +**Example 3:Multi device time aligned query** + +```SQL +IoTDB> SELECT date_bin_gapfill(1d, TIME) AS a_time, + device_id, + AVG(temperature) AS avg_temp + FROM table1 + WHERE TIME >= 2024-11-26 13:00:00 + AND TIME <= 2024-11-27 17:00:00 + GROUP BY 1, device_id FILL METHOD PREVIOUS; +``` + +**Result**: + +```SQL ++-----------------------------+---------+--------+ +| a_time|device_id|avg_temp| ++-----------------------------+---------+--------+ +|2024-11-26T08:00:00.000+08:00| 100| 90.0| +|2024-11-27T08:00:00.000+08:00| 100| 90.0| +|2024-11-26T08:00:00.000+08:00| 101| 90.0| +|2024-11-27T08:00:00.000+08:00| 101| 85.0| ++-----------------------------+---------+--------+ +Total line number = 4 +It costs 0.048s +``` + ### 3.3 Aggregation Query **Example**: Calculate the average, maximum, and minimum temperature for each `device_id` within a specific time range. @@ -213,7 +240,7 @@ IoTDB> SELECT device_id,date_bin(1d ,time) as day_time, AVG(temperature) as avg_ Total line number = 5 It costs 0.066s ``` -### 3.6 Multi sequence downsampling query with misaligned timestamps +### 3.6 Multi device downsampling alignment query #### 3.6.1 Sampling Frequency is the Same, but Time is Different diff --git a/src/UserGuide/Master/Table/SQL-Manual/Nested-Queries.md b/src/UserGuide/Master/Table/SQL-Manual/Nested-Queries.md index d0fa7cb47..89f9124d1 100644 --- a/src/UserGuide/Master/Table/SQL-Manual/Nested-Queries.md +++ b/src/UserGuide/Master/Table/SQL-Manual/Nested-Queries.md @@ -878,4 +878,4 @@ Note: **Example:** -* Downsampling queries for multiple sequences with misaligned timestamps. For detailed examples, see: [Example](../Basic-Concept/Query-Data.md#36-multi-sequence-downsampling-query-with-misaligned-timestamps) +* * Multi device downsampling alignment query. For detailed examples, see: [Example](../Basic-Concept/Query-Data.md#36-multi-device-downsampling-alignment-query) diff --git a/src/UserGuide/latest-Table/Basic-Concept/Query-Data.md b/src/UserGuide/latest-Table/Basic-Concept/Query-Data.md index 007ecfba9..2a450e734 100644 --- a/src/UserGuide/latest-Table/Basic-Concept/Query-Data.md +++ b/src/UserGuide/latest-Table/Basic-Concept/Query-Data.md @@ -139,6 +139,32 @@ IoTDB> SELECT time, temperature, humidity Total line number = 7 It costs 0.106s ``` +**Example 3:Multi device time aligned query** + +```SQL +IoTDB> SELECT date_bin_gapfill(1d, TIME) AS a_time, + device_id, + AVG(temperature) AS avg_temp + FROM table1 + WHERE TIME >= 2024-11-26 13:00:00 + AND TIME <= 2024-11-27 17:00:00 + GROUP BY 1, device_id FILL METHOD PREVIOUS; +``` + +**Result**: + +```SQL ++-----------------------------+---------+--------+ +| a_time|device_id|avg_temp| ++-----------------------------+---------+--------+ +|2024-11-26T08:00:00.000+08:00| 100| 90.0| +|2024-11-27T08:00:00.000+08:00| 100| 90.0| +|2024-11-26T08:00:00.000+08:00| 101| 90.0| +|2024-11-27T08:00:00.000+08:00| 101| 85.0| ++-----------------------------+---------+--------+ +Total line number = 4 +It costs 0.048s +``` ### 3.3 Aggregation Query @@ -213,7 +239,7 @@ IoTDB> SELECT device_id,date_bin(1d ,time) as day_time, AVG(temperature) as avg_ Total line number = 5 It costs 0.066s ``` -### 3.6 Multi sequence downsampling query with misaligned timestamps +### 3.6 Multi device downsampling alignment query #### 3.6.1 Sampling Frequency is the Same, but Time is Different diff --git a/src/UserGuide/latest-Table/SQL-Manual/Nested-Queries.md b/src/UserGuide/latest-Table/SQL-Manual/Nested-Queries.md index b564c8780..490799e30 100644 --- a/src/UserGuide/latest-Table/SQL-Manual/Nested-Queries.md +++ b/src/UserGuide/latest-Table/SQL-Manual/Nested-Queries.md @@ -878,4 +878,4 @@ Note: **Example:** -* Downsampling queries for multiple sequences with misaligned timestamps. For detailed examples, see: [Example](../Basic-Concept/Query-Data.md#36-multi-sequence-downsampling-query-with-misaligned-timestamps) \ No newline at end of file +* Multi device downsampling alignment query. For detailed examples, see: [Example](../Basic-Concept/Query-Data.md#36-multi-device-downsampling-alignment-query) \ No newline at end of file diff --git a/src/zh/UserGuide/Master/Table/Basic-Concept/Query-Data.md b/src/zh/UserGuide/Master/Table/Basic-Concept/Query-Data.md index 3ceb09703..415d62e57 100644 --- a/src/zh/UserGuide/Master/Table/Basic-Concept/Query-Data.md +++ b/src/zh/UserGuide/Master/Table/Basic-Concept/Query-Data.md @@ -141,6 +141,33 @@ Total line number = 7 It costs 0.106s ``` +**示例4:多设备按时间对齐查询** + +```SQL +IoTDB> SELECT date_bin_gapfill(1d, TIME) AS a_time, + device_id, + AVG(temperature) AS avg_temp + FROM table1 + WHERE TIME >= 2024-11-26 13:00:00 + AND TIME <= 2024-11-27 17:00:00 + GROUP BY 1, device_id FILL METHOD PREVIOUS; +``` + +执行结果如下: + +```SQL ++-----------------------------+---------+--------+ +| a_time|device_id|avg_temp| ++-----------------------------+---------+--------+ +|2024-11-26T08:00:00.000+08:00| 100| 90.0| +|2024-11-27T08:00:00.000+08:00| 100| 90.0| +|2024-11-26T08:00:00.000+08:00| 101| 90.0| +|2024-11-27T08:00:00.000+08:00| 101| 85.0| ++-----------------------------+---------+--------+ +Total line number = 4 +It costs 0.048s +``` + ### 3.3 聚合查询 **示例:查询计算了在指定时间范围内,每个`device_id`的平均温度、最高温度和最低温度。** @@ -215,7 +242,7 @@ Total line number = 5 It costs 0.066s ``` -### 3.6 时间戳不对齐的多序列降采样查询 +### 3.6 多设备降采样对齐查询 #### 3.6.1 采样频率相同,时间不同 diff --git a/src/zh/UserGuide/Master/Table/SQL-Manual/Nested-Queries.md b/src/zh/UserGuide/Master/Table/SQL-Manual/Nested-Queries.md index f989585ff..4f44b43ba 100644 --- a/src/zh/UserGuide/Master/Table/SQL-Manual/Nested-Queries.md +++ b/src/zh/UserGuide/Master/Table/SQL-Manual/Nested-Queries.md @@ -877,4 +877,4 @@ IoTDB> SELECT s1 <= **示例:** -* 时间戳不对齐的多序列降采样查询,详细示例可见:[示例](../Basic-Concept/Query-Data.md#36-时间戳不对齐的多序列降采样查询) \ No newline at end of file +* 多设备降采样对齐查询,详细示例可见:[示例](../Basic-Concept/Query-Data.md#36-多设备降采样对齐查询) \ No newline at end of file diff --git a/src/zh/UserGuide/latest-Table/Basic-Concept/Query-Data.md b/src/zh/UserGuide/latest-Table/Basic-Concept/Query-Data.md index 3ceb09703..415d62e57 100644 --- a/src/zh/UserGuide/latest-Table/Basic-Concept/Query-Data.md +++ b/src/zh/UserGuide/latest-Table/Basic-Concept/Query-Data.md @@ -141,6 +141,33 @@ Total line number = 7 It costs 0.106s ``` +**示例4:多设备按时间对齐查询** + +```SQL +IoTDB> SELECT date_bin_gapfill(1d, TIME) AS a_time, + device_id, + AVG(temperature) AS avg_temp + FROM table1 + WHERE TIME >= 2024-11-26 13:00:00 + AND TIME <= 2024-11-27 17:00:00 + GROUP BY 1, device_id FILL METHOD PREVIOUS; +``` + +执行结果如下: + +```SQL ++-----------------------------+---------+--------+ +| a_time|device_id|avg_temp| ++-----------------------------+---------+--------+ +|2024-11-26T08:00:00.000+08:00| 100| 90.0| +|2024-11-27T08:00:00.000+08:00| 100| 90.0| +|2024-11-26T08:00:00.000+08:00| 101| 90.0| +|2024-11-27T08:00:00.000+08:00| 101| 85.0| ++-----------------------------+---------+--------+ +Total line number = 4 +It costs 0.048s +``` + ### 3.3 聚合查询 **示例:查询计算了在指定时间范围内,每个`device_id`的平均温度、最高温度和最低温度。** @@ -215,7 +242,7 @@ Total line number = 5 It costs 0.066s ``` -### 3.6 时间戳不对齐的多序列降采样查询 +### 3.6 多设备降采样对齐查询 #### 3.6.1 采样频率相同,时间不同 diff --git a/src/zh/UserGuide/latest-Table/SQL-Manual/Nested-Queries.md b/src/zh/UserGuide/latest-Table/SQL-Manual/Nested-Queries.md index f989585ff..4f44b43ba 100644 --- a/src/zh/UserGuide/latest-Table/SQL-Manual/Nested-Queries.md +++ b/src/zh/UserGuide/latest-Table/SQL-Manual/Nested-Queries.md @@ -877,4 +877,4 @@ IoTDB> SELECT s1 <= **示例:** -* 时间戳不对齐的多序列降采样查询,详细示例可见:[示例](../Basic-Concept/Query-Data.md#36-时间戳不对齐的多序列降采样查询) \ No newline at end of file +* 多设备降采样对齐查询,详细示例可见:[示例](../Basic-Concept/Query-Data.md#36-多设备降采样对齐查询) \ No newline at end of file