Merge branch '3.0' of github.com:taosdata/TDengine into szhou/python-udf

This commit is contained in:
slzhou 2023-03-08 13:51:47 +08:00
commit 0deeff333c
12 changed files with 94 additions and 16 deletions

View File

@ -2,7 +2,7 @@
IF (DEFINED VERNUMBER) IF (DEFINED VERNUMBER)
SET(TD_VER_NUMBER ${VERNUMBER}) SET(TD_VER_NUMBER ${VERNUMBER})
ELSE () ELSE ()
SET(TD_VER_NUMBER "3.0.2.6") SET(TD_VER_NUMBER "3.0.3.0")
ENDIF () ENDIF ()
IF (DEFINED VERCOMPATIBLE) IF (DEFINED VERCOMPATIBLE)

View File

@ -2,7 +2,7 @@
# taos-tools # taos-tools
ExternalProject_Add(taos-tools ExternalProject_Add(taos-tools
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
GIT_TAG 0111c66 GIT_TAG d4b3967
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools" SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
BINARY_DIR "" BINARY_DIR ""
#BUILD_IN_SOURCE TRUE #BUILD_IN_SOURCE TRUE

View File

@ -32,15 +32,15 @@ The most common usage of PARTITION BY is partitioning the data in subtables by t
## Windowed Queries ## Windowed Queries
Aggregation by time window is supported in TDengine. For example, in the case where temperature sensors report the temperature every seconds, the average temperature for every 10 minutes can be retrieved by performing a query with a time window. Window related clauses are used to divide the data set to be queried into subsets and then aggregation is performed across the subsets. There are three kinds of windows: time window, status window, and session window. There are two kinds of time windows: sliding window and flip time/tumbling window. The query syntax is as follows: Aggregation by time window is supported in TDengine. For example, in the case where temperature sensors report the temperature every seconds, the average temperature for every 10 minutes can be retrieved by performing a query with a time window. Window related clauses are used to divide the data set to be queried into subsets and then aggregation is performed across the subsets. There are four kinds of windows: time window, status window, session window, and event window. There are two kinds of time windows: sliding window and flip time/tumbling window. The syntax of window clause is as follows:
```sql ```sql
SELECT select_list FROM tb_name window_clause: {
[WHERE where_condition] SESSION(ts_col, tol_val)
[SESSION(ts_col, tol_val)] | STATE_WINDOW(col)
[STATE_WINDOW(col)] | INTERVAL(interval [, offset]) [SLIDING sliding] [FILL({NONE | VALUE | PREV | NULL | LINEAR | NEXT})]
[INTERVAL(interval [, offset]) [SLIDING sliding]] | EVENT_WINDOW START WITH start_trigger_condition END WITH end_trigger_condition
[FILL({NONE | VALUE | PREV | NULL | LINEAR | NEXT})] }
``` ```
The following restrictions apply: The following restrictions apply:
@ -146,6 +146,26 @@ If the time interval between two continuous rows are within the time interval sp
SELECT COUNT(*), FIRST(ts) FROM temp_tb_1 SESSION(ts, tol_val); SELECT COUNT(*), FIRST(ts) FROM temp_tb_1 SESSION(ts, tol_val);
``` ```
### Event Window
Event window is determined according to the window start condition and the window close condition. The window is started when `start_trigger_condition` is evaluated to true, the window is closed when `end_trigger_condition` is evaluated to true. `start_trigger_condition` and `end_trigger_condition` can be any conditional expressions supported by TDengine and can include multiple columns.
There may be only one row of data in an event window, when a row meets both the `start_trigger_condition` and the `end_trigger_condition`.
The window is treated as invalid or non-existing if the `end_trigger_condition` can't be met. There will be no output in case that a window can't be closed.
If the event window query is performed on a super table, TDengine consolidates all the data of all child tables into a single timeline then perform event window based query.
If you want to perform event window based query on the result set of a sub-query, the result set of the sub-query should be arranged in the order of timestamp and include the column of timestamp.
For example, the diagram below illustrates the event windows generated by the query below:
```sql
select _wstart, _wend, count(*) from t start with c1 > 0 end with c2 < 10
```
![Event Window Illustration](./event_window.webp)
### Examples ### Examples
A table of intelligent meters can be created by the SQL statement below A table of intelligent meters can be created by the SQL statement below

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 KiB

View File

@ -210,6 +210,9 @@ taosBenchmark -A INT,DOUBLE,NCHAR,BINARY\(16\)
- **-z/--trying-interval <NUMBER\>** : - **-z/--trying-interval <NUMBER\>** :
Specify interval between keep trying insert. Valid value is a positive number. Only valid when keep trying be enabled. Available with v3.0.9+. Specify interval between keep trying insert. Valid value is a positive number. Only valid when keep trying be enabled. Available with v3.0.9+.
- **-v/--vgroups <NUMBER\>** :
Specify vgroups number for creating a database, only valid with daemon version 3.0+
- **-V/--version** : - **-V/--version** :
Show version information only. Users should not use it with other parameters. Show version information only. Users should not use it with other parameters.
@ -241,6 +244,14 @@ The parameters listed in this section apply to all function modes.
- ** trying_interval ** : Specify interval between keep trying insert. Valid value is a positive number. Only valid when keep trying be enabled. Available with v3.0.9+. - ** trying_interval ** : Specify interval between keep trying insert. Valid value is a positive number. Only valid when keep trying be enabled. Available with v3.0.9+.
- ** childtable_from and childtable_to ** : specify the child table range to create. The range is [childtable_from, childtable_to).
 
- ** continue_if_fail ** : allow the user to specify the reaction if the insertion failed.
- "continue_if_fail" : "no" // means taosBenchmark will exit if it fails to insert as default reaction behavior.
- "continue_if_fail" : "yes" // means taosBenchmark will warn the user if it fails to insert but continue to insert the next record.
- "continue_if_fail": "smart" // means taosBenchmark will try to create the non-existent child table if it fails to insert.
#### Database related configuration parameters #### Database related configuration parameters
The parameters related to database creation are configured in `dbinfo` in the json configuration file, as follows. The other parameters correspond to the database parameters specified when `create database` in [../../taos-sql/database]. The parameters related to database creation are configured in `dbinfo` in the json configuration file, as follows. The other parameters correspond to the database parameters specified when `create database` in [../../taos-sql/database].

View File

@ -10,6 +10,10 @@ For TDengine 2.x installation packages by version, please visit [here](https://w
import Release from "/components/ReleaseV3"; import Release from "/components/ReleaseV3";
## 3.0.3.0
<Release type="tdengine" version="3.0.3.0" />
## 3.0.2.6 ## 3.0.2.6
<Release type="tdengine" version="3.0.2.6" /> <Release type="tdengine" version="3.0.2.6" />

View File

@ -10,6 +10,10 @@ For other historical version installers, please visit [here](https://www.taosdat
import Release from "/components/ReleaseV3"; import Release from "/components/ReleaseV3";
## 2.4.8
<Release type="tools" version="2.4.8" />
## 2.4.6 ## 2.4.6
<Release type="tools" version="2.4.6" /> <Release type="tools" version="2.4.6" />

View File

@ -31,15 +31,17 @@ select max(current) from meters partition by location interval(10m)
## 窗口切分查询 ## 窗口切分查询
TDengine 支持按时间窗口切分方式进行聚合结果查询,比如温度传感器每秒采集一次数据,但需查询每隔 10 分钟的温度平均值。这种场景下可以使用窗口子句来获得需要的查询结果。窗口子句用于针对查询的数据集合按照窗口切分成为查询子集并进行聚合窗口包含时间窗口time window、状态窗口status window、会话窗口session window三种窗口。其中时间窗口又可划分为滑动时间窗口和翻转时间窗口。窗口切分查询语法如下 TDengine 支持按时间窗口切分方式进行聚合结果查询,比如温度传感器每秒采集一次数据,但需查询每隔 10 分钟的温度平均值。这种场景下可以使用窗口子句来获得需要的查询结果。窗口子句用于针对查询的数据集合按照窗口切分成为查询子集并进行聚合窗口包含时间窗口time window、状态窗口status window、会话窗口session window、条件窗口event window四种窗口。其中时间窗口又可划分为滑动时间窗口和翻转时间窗口。
窗口子句语法如下:
```sql ```sql
SELECT select_list FROM tb_name window_clause: {
[WHERE where_condition] SESSION(ts_col, tol_val)
[SESSION(ts_col, tol_val)] | STATE_WINDOW(col)
[STATE_WINDOW(col)] | INTERVAL(interval_val [, interval_offset]) [SLIDING (sliding_val)] [FILL(fill_mod_and_val)]
[INTERVAL(interval [, offset]) [SLIDING sliding]] | EVENT_WINDOW START WITH start_trigger_condition END WITH end_trigger_condition
[FILL({NONE | VALUE | PREV | NULL | LINEAR | NEXT})] }
``` ```
在上述语法中的具体限制如下 在上述语法中的具体限制如下
@ -138,6 +140,24 @@ SELECT tbname, _wstart, CASE WHEN voltage >= 205 and voltage <= 235 THEN 1 ELSE
SELECT COUNT(*), FIRST(ts) FROM temp_tb_1 SESSION(ts, tol_val); SELECT COUNT(*), FIRST(ts) FROM temp_tb_1 SESSION(ts, tol_val);
``` ```
### 事件窗口
事件窗口根据开始条件和结束条件来划定窗口当start_trigger_condition满足时则窗口开始直到end_trigger_condition满足时窗口关闭。start_trigger_condition和end_trigger_condition可以是任意 TDengine 支持的条件表达式,且可以包含不同的列。
事件窗口可以仅包含一条数据。即当一条数据同时满足start_trigger_condition和end_trigger_condition且当前不在一个窗口内时这条数据自己构成了一个窗口。
事件窗口无法关闭时不构成一个窗口不会被输出。即有数据满足start_trigger_condition此时窗口打开但后续数据都不能满足end_trigger_condition这个窗口无法被关闭这部分数据不够成一个窗口不会被输出。
如果直接在超级表上进行事件窗口查询TDengine 会将超级表的数据汇总成一条时间线,然后进行事件窗口的计算。
如果需要对子查询的结果集进行事件窗口查询,那么子查询的结果集需要满足按时间线输出的要求,且可以输出有效的时间戳列。
以下面的 SQL 语句为例,事件窗口切分如图所示:
```sql
select _wstart, _wend, count(*) from t start with c1 > 0 end with c2 < 10
```
![TDengine Database 事件窗口示意图](./event_window.webp)
### 时间戳伪列 ### 时间戳伪列
窗口聚合查询结果中,如果 SQL 语句中没有指定输出查询结果中的时间戳列,那么最终结果中不会自动包含窗口的时间列信息。如果需要在结果中输出聚合结果所对应的时间窗口信息,需要在 SELECT 子句中使用时间戳相关的伪列: 时间窗口起始时间 (\_WSTART), 时间窗口结束时间 (\_WEND), 时间窗口持续时间 (\_WDURATION), 以及查询整体窗口相关的伪列: 查询窗口起始时间(\_QSTART) 和查询窗口结束时间(\_QEND)。需要注意的是时间窗口起始时间和结束时间均是闭区间,时间窗口持续时间是数据当前时间分辨率下的数值。例如,如果当前数据库的时间分辨率是毫秒,那么结果中 500 就表示当前时间窗口的持续时间是 500毫秒 (500 ms)。 窗口聚合查询结果中,如果 SQL 语句中没有指定输出查询结果中的时间戳列,那么最终结果中不会自动包含窗口的时间列信息。如果需要在结果中输出聚合结果所对应的时间窗口信息,需要在 SELECT 子句中使用时间戳相关的伪列: 时间窗口起始时间 (\_WSTART), 时间窗口结束时间 (\_WEND), 时间窗口持续时间 (\_WDURATION), 以及查询整体窗口相关的伪列: 查询窗口起始时间(\_QSTART) 和查询窗口结束时间(\_QEND)。需要注意的是时间窗口起始时间和结束时间均是闭区间,时间窗口持续时间是数据当前时间分辨率下的数值。例如,如果当前数据库的时间分辨率是毫秒,那么结果中 500 就表示当前时间窗口的持续时间是 500毫秒 (500 ms)。

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

View File

@ -208,6 +208,9 @@ taosBenchmark -A INT,DOUBLE,NCHAR,BINARY\(16\)
- ** -z/--trying-interval <NUMBER\>** : 失败重试间隔时间单位为毫秒仅在 -k 指定重试后有效需使用 v3.0.9 以上版本 - ** -z/--trying-interval <NUMBER\>** : 失败重试间隔时间单位为毫秒仅在 -k 指定重试后有效需使用 v3.0.9 以上版本
- **-v/--vgroups <NUMBER\>** :
创建数据库时指定 vgroups 数,仅对 TDengine v3.0+ 有效。
- **-V/--version** : - **-V/--version** :
显示版本信息并退出。不能与其它参数混用。 显示版本信息并退出。不能与其它参数混用。
@ -238,6 +241,13 @@ taosBenchmark -A INT,DOUBLE,NCHAR,BINARY\(16\)
- ** keep_trying ** : 失败后进行重试的次数,默认不重试。需使用 v3.0.9 以上版本。 - ** keep_trying ** : 失败后进行重试的次数,默认不重试。需使用 v3.0.9 以上版本。
- ** trying_interval ** : 失败重试间隔时间,单位为毫秒,仅在 keep_trying 指定重试后有效。需使用 v3.0.9 以上版本。 - ** trying_interval ** : 失败重试间隔时间,单位为毫秒,仅在 keep_trying 指定重试后有效。需使用 v3.0.9 以上版本。
- ** childtable_from 和 childtable_to ** : 指定写入子表范围,开闭区间为 [childtable_from, childtable_to).
 
- ** continue_if_fail ** : 允许用户定义失败后行为
“continue_if_fail”:  “no”, 失败 taosBenchmark 自动退出,默认行为
“continue_if_fail”: “yes”, 失败 taosBenchmark 警告用户,并继续写入
“continue_if_fail”: “smart”, 如果子表不存在失败taosBenchmark 会建立子表并继续写入
#### 数据库相关配置参数 #### 数据库相关配置参数

View File

@ -10,6 +10,11 @@ TDengine 2.x 各版本安装包请访问[这里](https://www.taosdata.com/all-do
import Release from "/components/ReleaseV3"; import Release from "/components/ReleaseV3";
## 3.0.3.0
<Release type="tdengine" version="3.0.3.0" />
## 3.0.2.6 ## 3.0.2.6
<Release type="tdengine" version="3.0.2.6" /> <Release type="tdengine" version="3.0.2.6" />

View File

@ -10,6 +10,10 @@ taosTools 各版本安装包下载链接如下:
import Release from "/components/ReleaseV3"; import Release from "/components/ReleaseV3";
## 2.4.8
<Release type="tools" version="2.4.8" />
## 2.4.6 ## 2.4.6
<Release type="tools" version="2.4.6" /> <Release type="tools" version="2.4.6" />