Skip to content

Commit 19da048

Browse files
authored
update UDF function library (#398)
1 parent cb5f8c7 commit 19da048

File tree

8 files changed

+5
-453
lines changed

8 files changed

+5
-453
lines changed

src/UserGuide/Master/Reference/Function-and-Expression.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ The aggregate functions supported by IoTDB are as follows:
549549
| COUNT_IF | Find the number of data points that continuously meet a given condition and the number of data points that meet the condition (represented by keep) meet the specified threshold. | BOOLEAN | `[keep >=/>/=/!=/</<=]threshold`:The specified threshold or threshold condition, it is equivalent to `keep >= threshold` if `threshold` is used alone, type of `threshold` is `INT64` `ignoreNull`:Optional, default value is `true`;If the value is `true`, null values are ignored, it means that if there is a null value in the middle, the value is ignored without interrupting the continuity. If the value is `true`, null values are not ignored, it means that if there are null values in the middle, continuity will be broken | INT64 |
550550
| TIME_DURATION | Find the difference between the timestamp of the largest non-null value and the timestamp of the smallest non-null value in a column | All data Types | / | INT64 |
551551
| MODE | Find the mode. Note: 1.Having too many different values in the input series risks a memory exception; 2.If all the elements have the same number of occurrences, that is no Mode, return the value with earliest time; 3.If there are many Modes, return the Mode with earliest time. | All data Types | / | Consistent with the input data type |
552+
| STDDEV | Calculate the overall standard deviation of the data. Note:<br> Missing points, null points and `NaN` in the input series will be ignored.| INT32 INT64 FLOAT DOUBLE | / | DOUBLE |
552553
| COUNT_TIME | The number of timestamps in the query data set. When used with `align by device`, the result is the number of timestamps in the data set per device. | All data Types, the input parameter can only be `*` | / | INT64 |
553554
554555

src/UserGuide/Master/Reference/UDF-Libraries.md

Lines changed: 0 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,60 +1140,6 @@ Output series:
11401140
+-----------------------------+--------------------+
11411141
```
11421142

1143-
### Mode
1144-
1145-
#### Usage
1146-
1147-
This function is used to calculate the mode of time series, that is, the value that occurs most frequently.
1148-
1149-
**Name:** MODE
1150-
1151-
**Input Series:** Only support a single input series. The type is arbitrary.
1152-
1153-
**Output Series:** Output a single series. The type is the same as the input. There is only one data point in the series, whose timestamp is the same as which the first mode value has and value is the mode.
1154-
1155-
**Note:**
1156-
1157-
+ If there are multiple values with the most occurrences, the arbitrary one will be output.
1158-
+ Missing points and null points in the input series will be ignored, but `NaN` will not.
1159-
1160-
#### Examples
1161-
1162-
Input series:
1163-
1164-
```
1165-
+-----------------------------+---------------+
1166-
| Time|root.test.d2.s2|
1167-
+-----------------------------+---------------+
1168-
|1970-01-01T08:00:00.001+08:00| Hello|
1169-
|1970-01-01T08:00:00.002+08:00| hello|
1170-
|1970-01-01T08:00:00.003+08:00| Hello|
1171-
|1970-01-01T08:00:00.004+08:00| World|
1172-
|1970-01-01T08:00:00.005+08:00| World|
1173-
|1970-01-01T08:00:01.600+08:00| World|
1174-
|1970-01-15T09:37:34.451+08:00| Hello|
1175-
|1970-01-15T09:37:34.452+08:00| hello|
1176-
|1970-01-15T09:37:34.453+08:00| Hello|
1177-
|1970-01-15T09:37:34.454+08:00| World|
1178-
|1970-01-15T09:37:34.455+08:00| World|
1179-
+-----------------------------+---------------+
1180-
```
1181-
1182-
SQL for query:
1183-
1184-
```sql
1185-
select mode(s2) from root.test.d2
1186-
```
1187-
1188-
Output series:
1189-
1190-
```
1191-
+-----------------------------+---------------------+
1192-
| Time|mode(root.test.d2.s2)|
1193-
+-----------------------------+---------------------+
1194-
|1970-01-01T08:00:00.004+08:00| World|
1195-
+-----------------------------+---------------------+
1196-
```
11971143

11981144
### MvAvg
11991145

@@ -2264,66 +2210,7 @@ Output series:
22642210
+-----------------------------+-----------------------+
22652211
```
22662212

2267-
### Stddev
2268-
2269-
#### Usage
2270-
2271-
This function is used to calculate the population standard deviation.
2272-
2273-
**Name:** STDDEV
2274-
2275-
**Input Series:** Only support a single input series. The type is INT32 / INT64 / FLOAT / DOUBLE.
2276-
2277-
**Output Series:** Output a single series. The type is DOUBLE. There is only one data point in the series, whose timestamp is 0 and value is the population standard deviation.
2278-
2279-
**Note:** Missing points, null points and `NaN` in the input series will be ignored.
2280-
2281-
#### Examples
2282-
2283-
Input series:
2284-
2285-
```
2286-
+-----------------------------+---------------+
2287-
| Time|root.test.d1.s1|
2288-
+-----------------------------+---------------+
2289-
|2020-01-01T00:00:00.000+08:00| 1.0|
2290-
|2020-01-01T00:00:01.000+08:00| 2.0|
2291-
|2020-01-01T00:00:02.000+08:00| 3.0|
2292-
|2020-01-01T00:00:03.000+08:00| 4.0|
2293-
|2020-01-01T00:00:04.000+08:00| 5.0|
2294-
|2020-01-01T00:00:05.000+08:00| 6.0|
2295-
|2020-01-01T00:00:06.000+08:00| 7.0|
2296-
|2020-01-01T00:00:07.000+08:00| 8.0|
2297-
|2020-01-01T00:00:08.000+08:00| 9.0|
2298-
|2020-01-01T00:00:09.000+08:00| 10.0|
2299-
|2020-01-01T00:00:10.000+08:00| 11.0|
2300-
|2020-01-01T00:00:11.000+08:00| 12.0|
2301-
|2020-01-01T00:00:12.000+08:00| 13.0|
2302-
|2020-01-01T00:00:13.000+08:00| 14.0|
2303-
|2020-01-01T00:00:14.000+08:00| 15.0|
2304-
|2020-01-01T00:00:15.000+08:00| 16.0|
2305-
|2020-01-01T00:00:16.000+08:00| 17.0|
2306-
|2020-01-01T00:00:17.000+08:00| 18.0|
2307-
|2020-01-01T00:00:18.000+08:00| 19.0|
2308-
|2020-01-01T00:00:19.000+08:00| 20.0|
2309-
+-----------------------------+---------------+
2310-
```
2311-
2312-
SQL for query:
23132213

2314-
```sql
2315-
select stddev(s1) from root.test.d1
2316-
```
2317-
2318-
Output series:
2319-
2320-
```
2321-
+-----------------------------+-----------------------+
2322-
| Time|stddev(root.test.d1.s1)|
2323-
+-----------------------------+-----------------------+
2324-
|1970-01-01T08:00:00.000+08:00| 5.7662812973353965|
2325-
+-----------------------------+-----------------------+
2326-
```
23272214

23282215
### ZScore
23292216

src/UserGuide/latest/Reference/Function-and-Expression.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ The aggregate functions supported by IoTDB are as follows:
549549
| COUNT_IF | Find the number of data points that continuously meet a given condition and the number of data points that meet the condition (represented by keep) meet the specified threshold. | BOOLEAN | `[keep >=/>/=/!=/</<=]threshold`:The specified threshold or threshold condition, it is equivalent to `keep >= threshold` if `threshold` is used alone, type of `threshold` is `INT64` `ignoreNull`:Optional, default value is `true`;If the value is `true`, null values are ignored, it means that if there is a null value in the middle, the value is ignored without interrupting the continuity. If the value is `true`, null values are not ignored, it means that if there are null values in the middle, continuity will be broken | INT64 |
550550
| TIME_DURATION | Find the difference between the timestamp of the largest non-null value and the timestamp of the smallest non-null value in a column | All data Types | / | INT64 |
551551
| MODE | Find the mode. Note: 1.Having too many different values in the input series risks a memory exception; 2.If all the elements have the same number of occurrences, that is no Mode, return the value with earliest time; 3.If there are many Modes, return the Mode with earliest time. | All data Types | / | Consistent with the input data type |
552+
| STDDEV | Calculate the overall standard deviation of the data. Note:<br> Missing points, null points and `NaN` in the input series will be ignored.| INT32 INT64 FLOAT DOUBLE | / | DOUBLE |
552553
| COUNT_TIME | The number of timestamps in the query data set. When used with `align by device`, the result is the number of timestamps in the data set per device. | All data Types, the input parameter can only be `*` | / | INT64 |
553554
554555

src/UserGuide/latest/Reference/UDF-Libraries.md

Lines changed: 0 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,60 +1140,7 @@ Output series:
11401140
+-----------------------------+--------------------+
11411141
```
11421142

1143-
### Mode
11441143

1145-
#### Usage
1146-
1147-
This function is used to calculate the mode of time series, that is, the value that occurs most frequently.
1148-
1149-
**Name:** MODE
1150-
1151-
**Input Series:** Only support a single input series. The type is arbitrary.
1152-
1153-
**Output Series:** Output a single series. The type is the same as the input. There is only one data point in the series, whose timestamp is the same as which the first mode value has and value is the mode.
1154-
1155-
**Note:**
1156-
1157-
+ If there are multiple values with the most occurrences, the arbitrary one will be output.
1158-
+ Missing points and null points in the input series will be ignored, but `NaN` will not.
1159-
1160-
#### Examples
1161-
1162-
Input series:
1163-
1164-
```
1165-
+-----------------------------+---------------+
1166-
| Time|root.test.d2.s2|
1167-
+-----------------------------+---------------+
1168-
|1970-01-01T08:00:00.001+08:00| Hello|
1169-
|1970-01-01T08:00:00.002+08:00| hello|
1170-
|1970-01-01T08:00:00.003+08:00| Hello|
1171-
|1970-01-01T08:00:00.004+08:00| World|
1172-
|1970-01-01T08:00:00.005+08:00| World|
1173-
|1970-01-01T08:00:01.600+08:00| World|
1174-
|1970-01-15T09:37:34.451+08:00| Hello|
1175-
|1970-01-15T09:37:34.452+08:00| hello|
1176-
|1970-01-15T09:37:34.453+08:00| Hello|
1177-
|1970-01-15T09:37:34.454+08:00| World|
1178-
|1970-01-15T09:37:34.455+08:00| World|
1179-
+-----------------------------+---------------+
1180-
```
1181-
1182-
SQL for query:
1183-
1184-
```sql
1185-
select mode(s2) from root.test.d2
1186-
```
1187-
1188-
Output series:
1189-
1190-
```
1191-
+-----------------------------+---------------------+
1192-
| Time|mode(root.test.d2.s2)|
1193-
+-----------------------------+---------------------+
1194-
|1970-01-01T08:00:00.004+08:00| World|
1195-
+-----------------------------+---------------------+
1196-
```
11971144

11981145
### MvAvg
11991146

@@ -2264,66 +2211,6 @@ Output series:
22642211
+-----------------------------+-----------------------+
22652212
```
22662213

2267-
### Stddev
2268-
2269-
#### Usage
2270-
2271-
This function is used to calculate the population standard deviation.
2272-
2273-
**Name:** STDDEV
2274-
2275-
**Input Series:** Only support a single input series. The type is INT32 / INT64 / FLOAT / DOUBLE.
2276-
2277-
**Output Series:** Output a single series. The type is DOUBLE. There is only one data point in the series, whose timestamp is 0 and value is the population standard deviation.
2278-
2279-
**Note:** Missing points, null points and `NaN` in the input series will be ignored.
2280-
2281-
#### Examples
2282-
2283-
Input series:
2284-
2285-
```
2286-
+-----------------------------+---------------+
2287-
| Time|root.test.d1.s1|
2288-
+-----------------------------+---------------+
2289-
|2020-01-01T00:00:00.000+08:00| 1.0|
2290-
|2020-01-01T00:00:01.000+08:00| 2.0|
2291-
|2020-01-01T00:00:02.000+08:00| 3.0|
2292-
|2020-01-01T00:00:03.000+08:00| 4.0|
2293-
|2020-01-01T00:00:04.000+08:00| 5.0|
2294-
|2020-01-01T00:00:05.000+08:00| 6.0|
2295-
|2020-01-01T00:00:06.000+08:00| 7.0|
2296-
|2020-01-01T00:00:07.000+08:00| 8.0|
2297-
|2020-01-01T00:00:08.000+08:00| 9.0|
2298-
|2020-01-01T00:00:09.000+08:00| 10.0|
2299-
|2020-01-01T00:00:10.000+08:00| 11.0|
2300-
|2020-01-01T00:00:11.000+08:00| 12.0|
2301-
|2020-01-01T00:00:12.000+08:00| 13.0|
2302-
|2020-01-01T00:00:13.000+08:00| 14.0|
2303-
|2020-01-01T00:00:14.000+08:00| 15.0|
2304-
|2020-01-01T00:00:15.000+08:00| 16.0|
2305-
|2020-01-01T00:00:16.000+08:00| 17.0|
2306-
|2020-01-01T00:00:17.000+08:00| 18.0|
2307-
|2020-01-01T00:00:18.000+08:00| 19.0|
2308-
|2020-01-01T00:00:19.000+08:00| 20.0|
2309-
+-----------------------------+---------------+
2310-
```
2311-
2312-
SQL for query:
2313-
2314-
```sql
2315-
select stddev(s1) from root.test.d1
2316-
```
2317-
2318-
Output series:
2319-
2320-
```
2321-
+-----------------------------+-----------------------+
2322-
| Time|stddev(root.test.d1.s1)|
2323-
+-----------------------------+-----------------------+
2324-
|1970-01-01T08:00:00.000+08:00| 5.7662812973353965|
2325-
+-----------------------------+-----------------------+
2326-
```
23272214

23282215
### ZScore
23292216

src/zh/UserGuide/Master/Reference/Function-and-Expression.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ IoTDB 支持的聚合函数如下:
4444
| COUNT_IF | 求数据点连续满足某一给定条件,且满足条件的数据点个数(用keep表示)满足指定阈值的次数。 | BOOLEAN | `[keep >=/>/=/!=/</<=]threshold`:被指定的阈值或阈值条件,若只使用`threshold`则等价于`keep >= threshold`,`threshold`类型为`INT64` <br> `ignoreNull`:可选,默认为`true`;为`true`表示忽略null值,即如果中间出现null值,直接忽略,不会打断连续性;为`false`表示不忽略null值,即如果中间出现null值,会打断连续性 | INT64 |
4545
| TIME_DURATION | 求某一列最大一个不为NULL的值所在时间戳与最小一个不为NULL的值所在时间戳的时间戳差 | 所有类型 || INT64 |
4646
| MODE | 求众数。注意:<br>1.输入序列的不同值个数过多时会有内存异常风险; <br>2.如果所有元素出现的频次相同,即没有众数,则返回对应时间戳最小的值; <br>3.如果有多个众数,则返回对应时间戳最小的众数。 | 所有类型 || 与输入类型一致 |
47+
| STDDEV | 求数据的总体标准差。注意:<br> 数据中的空值、缺失值和`NaN`将会被忽略。 | INT32 INT64 FLOAT DOUBLE || DOUBLE |
4748
| COUNT_TIME | 查询结果集的时间戳的数量。与 align by device 搭配使用时,得到的结果是每个设备的结果集的时间戳的数量。 | 所有类型,输入参数只能为* || INT64 |
4849
| MAX_BY | MAX_BY(x, y) 求二元输入 x 和 y 在 y 最大时对应的 x 的值。MAX_BY(time, x) 返回 x 取最大值时对应的时间戳。 | 第一个输入 x 可以是任意类型,第二个输入 y 只能是 INT32 INT64 FLOAT DOUBLE || 与第一个输入 x 的数据类型一致 |
4950
| MIN_BY | MIN_BY(x, y) 求二元输入 x 和 y 在 y 最小时对应的 x 的值。MIN_BY(time, x) 返回 x 取最小值时对应的时间戳。 | 第一个输入 x 可以是任意类型,第二个输入 y 只能是 INT32 INT64 FLOAT DOUBLE || 与第一个输入 x 的数据类型一致 |

0 commit comments

Comments
 (0)