Update 10-function.md

This commit is contained in:
facetosea 2024-07-10 15:18:19 +08:00
parent fe0737e5bf
commit 706013e2cd
2 changed files with 16 additions and 16 deletions

View File

@ -1239,7 +1239,7 @@ ignore_option: {
- If the data of current row is NULL or can't find the **first valid data before the current row**, the diff result is NULL
- When ignoring negative values (ignore_option is set to 1 or 3), if the diff result is negative, the result is set to null, and then filtered according to the null value filtering rule
- When the diff result has an overflow, whether to ignore the negative value depends on the result of the logical operation is positive or negative. For example, the value of 9223372036854775800 - (-9223372036854775806) exceeds the range of BIGINT, and the diff result will display the overflow value -10, but it will not be ignored as a negative value
- Single or multiple diffs can be used in a single statement, and for each diff you can specify same or different `ignore_option`. When there are multiple diffs in a single statement, when and only when all the diff results are NULL for a row and the `ignore_option` is specified as ignoring NULL for all diffs, the output of this row will be removed from the result set.
- Single or multiple diffs can be used in a single statement, and for each diff you can specify same or different `ignore_option`. When there are multiple diffs in a single statement, when and only when all the diff results are NULL for a row and each diff's `ignore_option` is specified as ignoring NULL, the output of this row will be removed from the result set.
- Can be used with the selected associated columns. For example: `select _rowts, DIFF()`.
- When there is not composite primary key, if there are the same timestamps across different subtables, it will prompt "Duplicate timestamps not allowed"
- When using with composite primary key, there may be same combination of timestamp and complete primary key across sub-tables, which row will be used depends on which row is found first, that means the result of running diff() multiple times may be different in such a case

View File

@ -1210,14 +1210,14 @@ ignore_option: {
}
```
**功能说明**:统计表中某列的值与之前行有效值的差。 ignore_option 取值为 0|1|2|3 , 可以不填,默认值为 0.
- 为 0 表示不忽略(diff结果)负值不忽略 null 值
- 为 1 时则表示(diff结果)负值作为 null 值
- 为 2 表示不忽略(diff结果)负值但忽略 null 值
- 为 3 时则表示忽略(diff结果)负值且忽略 null 值
**功能说明**:统计表中特定列与之前行的当前列有效值之差。 ignore_option 取值为 0|1|2|3 , 可以不填,默认值为 0.
- `0` 表示不忽略(diff结果)负值不忽略 null 值
- `1` 表示(diff结果)负值作为 null 值
- `2` 表示不忽略(diff结果)负值但忽略 null 值
- `3` 表示忽略(diff结果)负值且忽略 null 值
- 对于存在复合主键的表的查询,若时间戳相同的数据存在多条,则只有对应的复合主键最小的数据参与运算。
**返回数据类型**bool、时间戳类型及整型数值类型均返回 int_64浮点类型返回 double, 若 diff 结果溢出则按溢出返回。
**返回数据类型**bool、时间戳及整型数值类型均返回 int_64浮点类型返回 double, 若 diff 结果溢出则返回溢出后的值
**适用数据类型**:数值类型、时间戳和 bool 类型。
@ -1225,15 +1225,15 @@ ignore_option: {
**使用说明**:
- diff 是本行本列数据和之前最近的第一个有效数据做 diff之前最近的第一个有效数据指的是按照时间戳排序从本行向较小的时间戳方向寻找查看其他行的同一列寻找到的第一个非 null 数据
- 数值类型 diff 结果为对应差值;时间戳根据创建数据库的精度类型的时间戳进行差值计算bool 型 true 为1 false 为 0 进行差值计算
- 当本行列数据不存在(为 null )时,或者没找到有效的比较数据diff 结果为 null
- 忽略负值时( ignore_option 为 1 / 3 ),如果 diff 结果为负值,则结果设置为 null 然后根据 null 值过滤规则过滤
- 当 diff 结果有类型溢出时,根据逻辑运算结果的正负进行判定是否忽略负值,例如 9223372036854775800 - (-9223372036854775806) 的值超出 BIGINT 的范围 diff 结果会显示溢出值 -10但并不会被作为负值忽略
- 支持单个语句中同时存在单个或者多个 diff支持不同的 diff 函数指定相同或不同的 ignore_option ,当存在多个 diff 时只有当某行所有 diff 结果都为 null 且 ignore_option 都设置了忽略 null 值,该行才从结果集中剔除
- 可以选择相关联的列一起使用。 例如: select _rowts, DIFF() from。
- 不使用复合主键时,超级表的子表可能会有相同时间戳数据,有相同的时间戳时,会提示 "Duplicate timestamps not allowed"
- 使用复合主键时,超级表的子表可能有相同的复合主键,以首先找到的行数据为准
- diff 是计算本行特定列与同列的前一个有效数据的差值,同列的前一个有效数据:指的是同一列中时间戳较小的最临近的非空值
- 数值类型 diff 结果为对应的算术差值;时间戳类型根据数据库的时间戳精度进行差值计算bool 计算差值时 true 1 false 为 0
- 如当前行数据为 null 或者没有找到同列前一个有效数据时diff 结果为 null
- 忽略负值时( ignore_option 设置为 1 或 3 ),如果 diff 结果为负值,则结果设置为 null然后根据 null 值过滤规则进行过滤
- 当 diff 结果发生溢出时,结果是否是`应该忽略的负值`取决于逻辑运算结果是正数还是负数,例如 9223372036854775800 - (-9223372036854775806) 的值超出 BIGINT 的范围 diff 结果会显示溢出值 -10但并不会被作为负值忽略
- 单个语句中可以使用单个或者多个 diff并且每个 diff 可以指定相同或不同的 ignore_option ,当单个语句中存在多个 diff 时当且仅当某行所有 diff 的结果都为 null ,并且 ignore_option 都设置为忽略 null 值,该行才从结果集中剔除
- 可以选择相关联的列一起使用。 例如: select _rowts, DIFF() from。
- 当没有复合主键时,如果不同的子表有相同时间戳的数据,会提示 "Duplicate timestamps not allowed"
- 当使用复合主键时,不同子表的时间戳和主键组合可能相同,使用哪一行取决于先找到哪一行,这意味着在这种情况下多次运行 diff() 的结果可能会不同。
### IRATE