Przeglądaj źródła

fix(doc): add stats function document for built-in function

Signed-off-by: Jianxiang Ran <rxan_embedded@163.com>
Jianxiang Ran 2 lat temu
rodzic
commit
2ce22451ca

+ 15 - 9
docs/en_US/sqls/built-in_functions.md

@@ -7,15 +7,21 @@ Aggregate functions perform a calculation on a set of values and return a single
 * The select list of a SELECT statement (either a sub-query or an outer query).
 * The select list of a SELECT statement (either a sub-query or an outer query).
 * A HAVING clause.
 * A HAVING clause.
 
 
-| Function    | Example                   | Description                                                                                                                                                                                                                                                                                                                                                                                                             |
-|-------------|---------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| avg         | avg(col1)                 | The average of the values in a group. The null values will be ignored.                                                                                                                                                                                                                                                                                                                                                  |
-| count       | count(*)                  | The number of items in a group. The null values will be ignored.                                                                                                                                                                                                                                                                                                                                                        |
-| max         | max(col1)                 | The maximum value in a group. The null values will be ignored.                                                                                                                                                                                                                                                                                                                                                          |
-| min         | min(col1)                 | The minimum value in a group. The null values will be ignored.                                                                                                                                                                                                                                                                                                                                                          |
-| sum         | sum(col1)                 | The sum of all the values in a group. The null values will be ignored.                                                                                                                                                                                                                                                                                                                                                  |
-| collect     | collect(*), collect(col1) | Returns an array with all column or the whole record (when the parameter is *) values from the group.                                                                                                                                                                                                                                                                                                                   |
-| deduplicate | deduplicate(col, false)   | Returns the deduplicate results in the group, usually a window. The first argument is the column as the key to deduplicate; the second argument is whether to return all items or just the latest item which is not duplicate. If the latest item is a duplicate, the sink will receive an empty map. Set the sink property [omitIfEmpty](../guide/rules/overview.md#Sinks/Actions) to the sink to not triggering the action. |
+| Function        | Example                          | Description                                                                                                                                                                                                                                                                                                                                                                                                                   |
+|-----------------|----------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| avg             | avg(col1)                        | The average of the values in a group. The null values will be ignored.                                                                                                                                                                                                                                                                                                                                                        |
+| count           | count(*)                         | The number of items in a group. The null values will be ignored.                                                                                                                                                                                                                                                                                                                                                              |
+| max             | max(col1)                        | The maximum value in a group. The null values will be ignored.                                                                                                                                                                                                                                                                                                                                                                |
+| min             | min(col1)                        | The minimum value in a group. The null values will be ignored.                                                                                                                                                                                                                                                                                                                                                                |
+| sum             | sum(col1)                        | The sum of all the values in a group. The null values will be ignored.                                                                                                                                                                                                                                                                                                                                                        |
+| collect         | collect(*), collect(col1)        | Returns an array with all column or the whole record (when the parameter is *) values from the group.                                                                                                                                                                                                                                                                                                                         |
+| deduplicate     | deduplicate(col, false)          | Returns the deduplicate results in the group, usually a window. The first argument is the column as the key to deduplicate; the second argument is whether to return all items or just the latest item which is not duplicate. If the latest item is a duplicate, the sink will receive an empty map. Set the sink property [omitIfEmpty](../guide/rules/overview.md#Sinks/Actions) to the sink to not triggering the action. |
+| stddev          | stddev(col)                      | Returns the population standard deviation of expression in the group, usually a window. The argument is the column as the key to stddev.                                                                                                                                                                                                                                                                                      |
+| stddevs         | stddevs(col)                     | Returns the sample standard deviation of expression in the group, usually a window. The argument is the column as the key to stddevs.                                                                                                                                                                                                                                                                                         |
+| var             | var(col)                         | Returns the population variance (square of the population standard deviation) of expression in the group, usually a window. The argument is the column as the key to var.                                                                                                                                                                                                                                                     |
+| vars            | vars(col)                        | Returns the sample variance (square of the sample standard deviation) of expression in the group, usually a window. The argument is the column as the key to vars.                                                                                                                                                                                                                                                            |
+| percentile      | percentile(col, percentile)      | Returns the percentile value based on a continuous distribution of expression in the group, usually a window. The first argument is the column as the key to percentile.  The second argument is the percentile of the value that you want to find. The percentile must be a constant between 0.0 and 1.0.                                                                                                                    |
+| percentile_disc | percentile_disc(col, percentile) | Returns the percentile value based on a discrete distribution of expression in the group, usually a window. The first argument is the column as the key to percentile_disc.  The second argument is the percentile of the value that you want to find. The percentile must be a constant between 0.0 and 1.0.                                                                                                                 |
 
 
 ### Collect() Examples
 ### Collect() Examples
 
 

+ 15 - 9
docs/zh_CN/sqls/built-in_functions.md

@@ -7,15 +7,21 @@ eKuiper 具有许多内置函数,可以对数据执行计算。
 * select 语句的 select 列表(子查询或外部查询)。
 * select 语句的 select 列表(子查询或外部查询)。
 * HAVING 子句。
 * HAVING 子句。
 
 
-| 函数          | 示例                        | 说明                                                                                                                                                                     |
-|-------------|---------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| avg         | avg(col1)                 | 组中的平均值。空值不参与计算。                                                                                                                                                        |
-| count       | count(*)                  | 组中的项目数。空值不参与计算。                                                                                                                                                        |
-| max         | max(col1)                 | 组中的最大值。空值不参与计算。                                                                                                                                                        |
-| min         | min(col1)                 | 组中的最小值。空值不参与计算。                                                                                                                                                        |
-| sum         | sum(col1)                 | 组中所有值的总和。空值不参与计算。                                                                                                                                                      |
-| collect     | collect(*), collect(col1) | 返回组中指定的列或整个消息(参数为*时)的值组成的数组。                                                                                                                                           |
-| deduplicate | deduplicate(col, false)   | 返回当前组去重的结果,通常用在窗口中。其中,第一个参数指定用于去重的列;第二个参数指定是否返回全部结果。若为 false ,则仅返回最近的未重复的项;若最近的项有重复,则返回空数组;此时可以设置 sink 参数 [omitIfEmpty](../rules/overview.md#目标/动作),使得 sink 接到空结果后不触发。 |
+| 函数              | 示例                               | 说明                                                                                                                                                                     |
+|-----------------|----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| avg             | avg(col1)                        | 组中的平均值。空值不参与计算。                                                                                                                                                        |
+| count           | count(*)                         | 组中的项目数。空值不参与计算。                                                                                                                                                        |
+| max             | max(col1)                        | 组中的最大值。空值不参与计算。                                                                                                                                                        |
+| min             | min(col1)                        | 组中的最小值。空值不参与计算。                                                                                                                                                        |
+| sum             | sum(col1)                        | 组中所有值的总和。空值不参与计算。                                                                                                                                                      |
+| collect         | collect(*), collect(col1)        | 返回组中指定的列或整个消息(参数为*时)的值组成的数组。                                                                                                                                           |
+| deduplicate     | deduplicate(col, false)          | 返回当前组去重的结果,通常用在窗口中。其中,第一个参数指定用于去重的列;第二个参数指定是否返回全部结果。若为 false ,则仅返回最近的未重复的项;若最近的项有重复,则返回空数组;此时可以设置 sink 参数 [omitIfEmpty](../rules/overview.md#目标/动作),使得 sink 接到空结果后不触发。 |
+| stddev          | stddev(col)                      | 返回当前组总体标准偏差的结果,通常用在窗口中。其中,参数指定用于计算的列。                                                                                                                                  |
+| stddevs         | stddevs(col)                     | 返回当前组样本标准偏差的结果,通常用在窗口中。其中,参数指定用于计算的列。                                                                                                                                  |
+| var             | var(col)                         | 返回当前组总体标准偏差的方差的结果,通常用在窗口中。其中,参数指定用于计算的列。                                                                                                                               |
+| vars            | vars(col)                        | 返回当前组样本标准偏差的方差的结果,通常用在窗口中。其中,参数指定用于计算的列。                                                                                                                               |
+| percentile      | percentile(col, percentile)      | 返回当前组中表达式连续分布的百分位值,通常用在窗口中。第一个参数指定用于 percentile 的列。第二个参数是您要查找的值的百分位数。百分位数必须是介于 0.0 和 1.0 之间的常数。                                                                        |
+| percentile_disc | percentile_disc(col, percentile) | 返回当前组中表达式离散分布的百分位值,通常用在窗口中。第一个参数指定用于 percentile_disc 的列。第二个参数是您要查找的值的百分位数。百分位数必须是介于 0.0 和 1.0 之间的常数。                                                                   |
 
 
 ### Collect() 示例
 ### Collect() 示例
 
 

+ 262 - 0
etc/functions/internal.json

@@ -212,6 +212,268 @@
 			}
 			}
 		}
 		}
 	}, {
 	}, {
+		"name": "stddev",
+		"example": "stddev(col1)",
+		"aggregate": true,
+		"hint": {
+			"en_US": "The population standard deviation of all the values in a group. ",
+			"zh_CN": "组中所有值的总体标准偏差。"
+		},
+		"args": [
+			{
+				"name": "field",
+				"optional": false,
+				"control": "field",
+				"type": "number",
+				"hint": {
+					"en_US": "The field to calculate the population standard deviation.",
+					"zh_CN": "用于计算总体标准偏差的字段名"
+				},
+				"label": {
+					"en_US": "Field",
+					"zh_CN": "字段"
+				}
+			}
+		],
+		"return": {
+			"type": "number",
+			"hint": {
+				"en_US": "population standard deviation",
+				"zh_CN": "总体标准偏差"
+			}
+		},
+		"node": {
+			"category": "function",
+			"icon": "iconPath",
+			"label": {
+				"en_US": "population standard deviation",
+				"zh_CN": "总体标准偏差"
+			}
+		}
+	}, {
+		"name": "stddevs",
+		"example": "stddevs(col1)",
+		"aggregate": true,
+		"hint": {
+			"en_US": "The sample standard deviation of all the values in a group. ",
+			"zh_CN": "组中所有值的样本标准偏差。"
+		},
+		"args": [
+			{
+				"name": "field",
+				"optional": false,
+				"control": "field",
+				"type": "number",
+				"hint": {
+					"en_US": "The field to calculate the sample standard deviation.",
+					"zh_CN": "用于计算样本标准偏差的字段名"
+				},
+				"label": {
+					"en_US": "Field",
+					"zh_CN": "字段"
+				}
+			}
+		],
+		"return": {
+			"type": "number",
+			"hint": {
+				"en_US": "sample standard deviation",
+				"zh_CN": "样本标准偏差"
+			}
+		},
+		"node": {
+			"category": "function",
+			"icon": "iconPath",
+			"label": {
+				"en_US": "sample standard deviation",
+				"zh_CN": "样本标准偏差"
+			}
+		}
+	}, {
+		"name": "var",
+		"example": "var(col1)",
+		"aggregate": true,
+		"hint": {
+			"en_US": "The population variance of all the values in a group. ",
+			"zh_CN": "组中所有值的总体标准偏差的方差。"
+		},
+		"args": [
+			{
+				"name": "field",
+				"optional": false,
+				"control": "field",
+				"type": "number",
+				"hint": {
+					"en_US": "The field to calculate the population variance.",
+					"zh_CN": "用于计算总体标准偏差的方差"
+				},
+				"label": {
+					"en_US": "Field",
+					"zh_CN": "字段"
+				}
+			}
+		],
+		"return": {
+			"type": "number",
+			"hint": {
+				"en_US": "population variance",
+				"zh_CN": "总体标准偏差的方差"
+			}
+		},
+		"node": {
+			"category": "function",
+			"icon": "iconPath",
+			"label": {
+				"en_US": "population variance",
+				"zh_CN": "总体标准偏差的方差"
+			}
+		}
+	},{
+		"name": "vars",
+		"example": "vars(col1)",
+		"aggregate": true,
+		"hint": {
+			"en_US": "The sample variance of all the values in a group. ",
+			"zh_CN": "组中所有值的样本标准偏差的方差。"
+		},
+		"args": [
+			{
+				"name": "field",
+				"optional": false,
+				"control": "field",
+				"type": "number",
+				"hint": {
+					"en_US": "The field to calculate the sample variance.",
+					"zh_CN": "用于计算样本标准偏差的方差"
+				},
+				"label": {
+					"en_US": "Field",
+					"zh_CN": "字段"
+				}
+			}
+		],
+		"return": {
+			"type": "number",
+			"hint": {
+				"en_US": "sample variance",
+				"zh_CN": "样本标准偏差的方差"
+			}
+		},
+		"node": {
+			"category": "function",
+			"icon": "iconPath",
+			"label": {
+				"en_US": "sample variance",
+				"zh_CN": "样本标准偏差的方差"
+			}
+		}
+	}, {
+		"name": "percentile",
+		"example": "percentile(col1, 0.5)",
+		"aggregate": true,
+		"hint": {
+			"en_US": "The percentile value based on a continuous distribution of all the values in a group. ",
+			"zh_CN": "组中所有值的连续分布的百分位值。"
+		},
+		"args": [
+			{
+				"name": "field",
+				"optional": false,
+				"control": "field",
+				"type": "number",
+				"hint": {
+					"en_US": "The percentile value based on a continuous distribution of all the values in a group.",
+					"zh_CN": "组中所有值的连续分布的百分位值。"
+				},
+				"label": {
+					"en_US": "Field",
+					"zh_CN": "字段"
+				}
+			},
+			{
+				"name": "field",
+				"optional": false,
+				"control": "field",
+				"type": "number",
+				"hint": {
+					"en_US": "The percentile of the value that you want to find. The percentile must be a constant between 0.0 and 1.0.",
+					"zh_CN": "要查找的值的百分位数。百分位数必须是介于 0.0 和 1.0 之间的常数。"
+				},
+				"label": {
+					"en_US": "percentile",
+					"zh_CN": "百分位数"
+				}
+			}
+		],
+		"return": {
+			"type": "number",
+			"hint": {
+				"en_US": "percentile value based on a continuous distribution",
+				"zh_CN": "连续分布的百分位值"
+			}
+		},
+		"node": {
+			"category": "function",
+			"icon": "iconPath",
+			"label": {
+				"en_US": "percentile value based on a continuous distribution",
+				"zh_CN": "连续分布的百分位值"
+			}
+		}
+	}, {
+		"name": "percentile_disc",
+		"example": "percentile_disc(col1, 0.5)",
+		"aggregate": true,
+		"hint": {
+			"en_US": "The percentile value based on a discrete distribution of all the values in a group. ",
+			"zh_CN": "组中所有值的离散分布的百分位值。"
+		},
+		"args": [
+			{
+				"name": "field",
+				"optional": false,
+				"control": "field",
+				"type": "number",
+				"hint": {
+					"en_US": "The percentile value based on a discrete distribution of all the values in a group.",
+					"zh_CN": "组中所有值的离散分布的百分位值。"
+				},
+				"label": {
+					"en_US": "Field",
+					"zh_CN": "字段"
+				}
+			},
+			{
+				"name": "field",
+				"optional": false,
+				"control": "field",
+				"type": "number",
+				"hint": {
+					"en_US": "The percentile of the value that you want to find. The percentile must be a constant between 0.0 and 1.0.",
+					"zh_CN": "要查找的值的百分位数。百分位数必须是介于 0.0 和 1.0 之间的常数。"
+				},
+				"label": {
+					"en_US": "percentile",
+					"zh_CN": "百分位数"
+				}
+			}
+		],
+		"return": {
+			"type": "number",
+			"hint": {
+				"en_US": "percentile value based on a discrete distribution",
+				"zh_CN": "离散分布的百分位值"
+			}
+		},
+		"node": {
+			"category": "function",
+			"icon": "iconPath",
+			"label": {
+				"en_US": "percentile value based on a discrete distribution",
+				"zh_CN": "离散分布的百分位值"
+			}
+		}
+	}, {
 		"name": "collect",
 		"name": "collect",
 		"example": "collect(*), collect(col1)",
 		"example": "collect(*), collect(col1)",
 		"aggregate": true,
 		"aggregate": true,