未验证 提交 e342b8cb 编写于 作者: G Ganlin Zhao 提交者: GitHub

Merge pull request #15527 from taosdata/glzhao89-patch-3

doc: fix errors/typos in SQL function sections
...@@ -15,9 +15,9 @@ Single-Row functions return a result row for each row in the query result. ...@@ -15,9 +15,9 @@ Single-Row functions return a result row for each row in the query result.
SELECT ABS(field_name) FROM { tb_name | stb_name } [WHERE clause] SELECT ABS(field_name) FROM { tb_name | stb_name } [WHERE clause]
``` ```
**Description**: The absolute of a specific column. **Description**: The absolute value of a specific field.
**Return value type**: UBIGINT if the input value is integer; DOUBLE if the input value is FLOAT/DOUBLE. **Return value type**: Same as input type.
**Applicable data types**: Numeric types. **Applicable data types**: Numeric types.
...@@ -26,7 +26,7 @@ SELECT ABS(field_name) FROM { tb_name | stb_name } [WHERE clause] ...@@ -26,7 +26,7 @@ SELECT ABS(field_name) FROM { tb_name | stb_name } [WHERE clause]
**Applicable nested query**: Inner query and Outer query. **Applicable nested query**: Inner query and Outer query.
**More explanations**: **More explanations**:
- Can't be used with aggregate functions. - Cannot be used with aggregate functions.
#### ACOS #### ACOS
...@@ -34,18 +34,18 @@ SELECT ABS(field_name) FROM { tb_name | stb_name } [WHERE clause] ...@@ -34,18 +34,18 @@ SELECT ABS(field_name) FROM { tb_name | stb_name } [WHERE clause]
SELECT ACOS(field_name) FROM { tb_name | stb_name } [WHERE clause] SELECT ACOS(field_name) FROM { tb_name | stb_name } [WHERE clause]
``` ```
**Description**: The anti-cosine of a specific column **Description**: The anti-cosine of a specific field.
**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL **Return value type**: DOUBLE.
**Applicable data types**: Numeric types. **Applicable data types**: Numeric types.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**Applicable nested query**: Inner query and Outer query **Applicable nested query**: Inner query and Outer query.
**More explanations**: **More explanations**:
- Can't be used with aggregate functions - Cannot be used with aggregate functions.
#### ASIN #### ASIN
...@@ -53,18 +53,18 @@ SELECT ACOS(field_name) FROM { tb_name | stb_name } [WHERE clause] ...@@ -53,18 +53,18 @@ SELECT ACOS(field_name) FROM { tb_name | stb_name } [WHERE clause]
SELECT ASIN(field_name) FROM { tb_name | stb_name } [WHERE clause] SELECT ASIN(field_name) FROM { tb_name | stb_name } [WHERE clause]
``` ```
**Description**: The anti-sine of a specific column **Description**: The anti-sine of a specific field.
**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL **Return value type**: DOUBLE.
**Applicable data types**: Numeric types. **Applicable data types**: Numeric types.
**Applicable table types**: table, STable **Applicable table types**: table, STable
**Applicable nested query**: Inner query and Outer query **Applicable nested query**: Inner query and Outer query.
**More explanations**: **More explanations**:
- Can't be used with aggregate functions - Cannot be used with aggregate functions.
#### ATAN #### ATAN
...@@ -72,20 +72,18 @@ SELECT ASIN(field_name) FROM { tb_name | stb_name } [WHERE clause] ...@@ -72,20 +72,18 @@ SELECT ASIN(field_name) FROM { tb_name | stb_name } [WHERE clause]
SELECT ATAN(field_name) FROM { tb_name | stb_name } [WHERE clause] SELECT ATAN(field_name) FROM { tb_name | stb_name } [WHERE clause]
``` ```
**Description**: anti-tangent of a specific column **Description**: anti-tangent of a specific field.
**Description**: The anti-cosine of a specific column
**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL **Return value type**: DOUBLE.
**Applicable data types**: Numeric types. **Applicable data types**: Numeric types.
**Applicable table types**: table, STable **Applicable table types**: table, STable
**Applicable nested query**: Inner query and Outer query **Applicable nested query**: Inner query and Outer query.
**More explanations**: **More explanations**:
- Can't be used with aggregate functions - Cannot be used with aggregate functions.
#### CEIL #### CEIL
...@@ -93,19 +91,18 @@ SELECT ATAN(field_name) FROM { tb_name | stb_name } [WHERE clause] ...@@ -93,19 +91,18 @@ SELECT ATAN(field_name) FROM { tb_name | stb_name } [WHERE clause]
SELECT CEIL(field_name) FROM { tb_name | stb_name } [WHERE clause]; SELECT CEIL(field_name) FROM { tb_name | stb_name } [WHERE clause];
``` ```
**Description**: The rounded up value of a specific column **Description**: The rounded up value of a specific field.
**Return value type**: Same as the column being used **Return value type**: Same as input type.
**Applicable data types**: Numeric types. **Applicable data types**: Numeric types.
**Applicable table types**: table, STable **Applicable table types**: table, STable
**Applicable nested query**: Inner query and outer query **Applicable nested query**: Inner query and outer query.
**More explanations**: **More explanations**:
- Arithmetic operation can be performed on the result of `ceil` function - Can't be used with aggregate functions.
- Can't be used with aggregate functions
#### COS #### COS
...@@ -113,20 +110,18 @@ SELECT CEIL(field_name) FROM { tb_name | stb_name } [WHERE clause]; ...@@ -113,20 +110,18 @@ SELECT CEIL(field_name) FROM { tb_name | stb_name } [WHERE clause];
SELECT COS(field_name) FROM { tb_name | stb_name } [WHERE clause] SELECT COS(field_name) FROM { tb_name | stb_name } [WHERE clause]
``` ```
**Description**: The cosine of a specific column **Description**: The cosine of a specific field.
**Description**: The anti-cosine of a specific column
**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL **Return value type**: DOUBLE.
**Applicable data types**: Numeric types. **Applicable data types**: Numeric types.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**Applicable nested query**: Inner query and Outer query **Applicable nested query**: Inner query and Outer query.
**More explanations**: **More explanations**:
- Can't be used with aggregate functions - Can't be used with aggregate functions.
#### FLOOR #### FLOOR
...@@ -134,9 +129,9 @@ SELECT COS(field_name) FROM { tb_name | stb_name } [WHERE clause] ...@@ -134,9 +129,9 @@ SELECT COS(field_name) FROM { tb_name | stb_name } [WHERE clause]
SELECT FLOOR(field_name) FROM { tb_name | stb_name } [WHERE clause]; SELECT FLOOR(field_name) FROM { tb_name | stb_name } [WHERE clause];
``` ```
**Description**: The rounded down value of a specific column **Description**: The rounded down value of a specific field.
**More explanations**: The restrictions are same as those of the `CEIL` function. **More explanations**: Refer to `CEIL` function for usage restrictions.
#### LOG #### LOG
...@@ -144,15 +139,15 @@ SELECT FLOOR(field_name) FROM { tb_name | stb_name } [WHERE clause]; ...@@ -144,15 +139,15 @@ SELECT FLOOR(field_name) FROM { tb_name | stb_name } [WHERE clause];
SELECT LOG(field_name, base) FROM { tb_name | stb_name } [WHERE clause] SELECT LOG(field_name, base) FROM { tb_name | stb_name } [WHERE clause]
``` ```
**Description**: The log of a specific with `base` as the radix **Description**: The logarithm of a specific field with `base` as the radix. If `base` parameter is ignored, natural logarithm of the field is returned.
**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL **Return value type**: DOUBLE.
**Applicable data types**: Numeric types. **Applicable data types**: Numeric types.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**Applicable nested query**: Inner query and Outer query **Applicable nested query**: Inner query and Outer query.
**More explanations**: **More explanations**:
- Can't be used with aggregate functions - Can't be used with aggregate functions
...@@ -163,18 +158,18 @@ SELECT LOG(field_name, base) FROM { tb_name | stb_name } [WHERE clause] ...@@ -163,18 +158,18 @@ SELECT LOG(field_name, base) FROM { tb_name | stb_name } [WHERE clause]
SELECT POW(field_name, power) FROM { tb_name | stb_name } [WHERE clause] SELECT POW(field_name, power) FROM { tb_name | stb_name } [WHERE clause]
``` ```
**Description**: The power of a specific column with `power` as the index **Description**: The power of a specific field with `power` as the index.
**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL **Return value type**: DOUBLE.
**Applicable data types**: Numeric types. **Applicable data types**: Numeric types.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**Applicable nested query**: Inner query and Outer query **Applicable nested query**: Inner query and Outer query.
**More explanations**: **More explanations**:
- Can't be used with aggregate functions - Can't be used with aggregate functions.
#### ROUND #### ROUND
...@@ -182,9 +177,9 @@ SELECT POW(field_name, power) FROM { tb_name | stb_name } [WHERE clause] ...@@ -182,9 +177,9 @@ SELECT POW(field_name, power) FROM { tb_name | stb_name } [WHERE clause]
SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause];
``` ```
**Description**: The rounded value of a specific column. **Description**: The rounded value of a specific field.
**More explanations**: The restrictions are same as `CEIL` function. **More explanations**: Refer to `CEIL` function for usage restrictions.
#### SIN #### SIN
...@@ -192,20 +187,20 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; ...@@ -192,20 +187,20 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause];
SELECT SIN(field_name) FROM { tb_name | stb_name } [WHERE clause] SELECT SIN(field_name) FROM { tb_name | stb_name } [WHERE clause]
``` ```
**Description**: The sine of a specific column **Description**: The sine of a specific field.
**Description**: The anti-cosine of a specific column **Description**: The anti-cosine of a specific field.
**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL **Return value type**: DOUBLE.
**Applicable data types**: Numeric types. **Applicable data types**: Numeric types.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**Applicable nested query**: Inner query and Outer query **Applicable nested query**: Inner query and Outer query.
**More explanations**: **More explanations**:
- Can't be used with aggregate functions - Can't be used with aggregate functions.
#### SQRT #### SQRT
...@@ -213,18 +208,18 @@ SELECT SIN(field_name) FROM { tb_name | stb_name } [WHERE clause] ...@@ -213,18 +208,18 @@ SELECT SIN(field_name) FROM { tb_name | stb_name } [WHERE clause]
SELECT SQRT(field_name) FROM { tb_name | stb_name } [WHERE clause] SELECT SQRT(field_name) FROM { tb_name | stb_name } [WHERE clause]
``` ```
**Description**: The square root of a specific column **Description**: The square root of a specific field.
**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL **Return value type**: DOUBLE.
**Applicable data types**: Numeric types. **Applicable data types**: Numeric types.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**Applicable nested query**: Inner query and Outer query **Applicable nested query**: Inner query and Outer query.
**More explanations**: **More explanations**:
- Can't be used with aggregate functions - Can't be used with aggregate functions.
#### TAN #### TAN
...@@ -232,20 +227,20 @@ SELECT SQRT(field_name) FROM { tb_name | stb_name } [WHERE clause] ...@@ -232,20 +227,20 @@ SELECT SQRT(field_name) FROM { tb_name | stb_name } [WHERE clause]
SELECT TAN(field_name) FROM { tb_name | stb_name } [WHERE clause] SELECT TAN(field_name) FROM { tb_name | stb_name } [WHERE clause]
``` ```
**Description**: The tangent of a specific column **Description**: The tangent of a specific field.
**Description**: The anti-cosine of a specific column **Description**: The anti-cosine of a specific field.
**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL **Return value type**: DOUBLE.
**Applicable data types**: Numeric types. **Applicable data types**: Numeric types.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**Applicable nested query**: Inner query and Outer query **Applicable nested query**: Inner query and Outer query.
**More explanations**: **More explanations**:
- Can't be used with aggregate functions - Can't be used with aggregate functions.
### String Functions ### String Functions
...@@ -257,19 +252,16 @@ String functiosn take strings as input and output numbers or strings. ...@@ -257,19 +252,16 @@ String functiosn take strings as input and output numbers or strings.
SELECT CHAR_LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] SELECT CHAR_LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause]
``` ```
**Description**: The length in number of characters of a string **Description**: The mumber of characters of a string.
**Return value type**: Integer **Return value type**: INTEGER.
**Applicable data types**: VARCHAR or NCHAR **Applicable data types**: VARCHAR, NCHAR.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**Applicable nested query**: Inner query and Outer query
**More explanations** **Applicable nested query**: Inner query and Outer query.
- If the input value is NULL, the output is NULL too
#### CONCAT #### CONCAT
...@@ -277,15 +269,16 @@ SELECT CHAR_LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] ...@@ -277,15 +269,16 @@ SELECT CHAR_LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause]
SELECT CONCAT(str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHERE clause] SELECT CONCAT(str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHERE clause]
``` ```
**Description**: The concatenation result of two or more strings, the number of strings to be concatenated is at least 2 and at most 8 **Description**: The concatenation result of two or more strings.
**Return value type**: If all input strings are VARCHAR type, the result is VARCHAR type too. If any one of input strings is NCHAR type, then the result is NCHAR. **Return value type**: If all input strings are VARCHAR type, the result is VARCHAR type too. If any one of input strings is NCHAR type, then the result is NCHAR. If input strings contain NULL value, the result is NULL.
**Applicable data types**: VARCHAR, NCHAR. At least 2 input strings are requird, and at most 8 input strings are allowed. **Applicable data types**: VARCHAR, NCHAR. At least 2 input strings are requird, and at most 8 input strings are allowed.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**Applicable nested query**: Inner query and Outer query.
**Applicable nested query**: Inner query and Outer query
#### CONCAT_WS #### CONCAT_WS
...@@ -293,19 +286,16 @@ SELECT CONCAT(str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHER ...@@ -293,19 +286,16 @@ SELECT CONCAT(str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHER
SELECT CONCAT_WS(separator, str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHERE clause] SELECT CONCAT_WS(separator, str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHERE clause]
``` ```
**Description**: The concatenation result of two or more strings with separator, the number of strings to be concatenated is at least 3 and at most 9 **Description**: The concatenation result of two or more strings with separator.
**Return value type**: If all input strings are VARCHAR type, the result is VARCHAR type too. If any one of input strings is NCHAR type, then the result is NCHAR. **Return value type**: If all input strings are VARCHAR type, the result is VARCHAR type too. If any one of input strings is NCHAR type, then the result is NCHAR. If input strings contain NULL value, the result is NULL.
**Applicable data types**: VARCHAR, NCHAR. At least 3 input strings are requird, and at most 9 input strings are allowed. **Applicable data types**: VARCHAR, NCHAR. At least 3 input strings are requird, and at most 9 input strings are allowed.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**Applicable nested query**: Inner query and Outer query
**More explanations**: **Applicable nested query**: Inner query and Outer query.
- If the value of `separator` is NULL, the output is NULL. If the value of `separator` is not NULL but other input are all NULL, the output is empty string.
#### LENGTH #### LENGTH
...@@ -313,18 +303,16 @@ SELECT CONCAT_WS(separator, str1|column1, str2|column2, ...) FROM { tb_name | st ...@@ -313,18 +303,16 @@ SELECT CONCAT_WS(separator, str1|column1, str2|column2, ...) FROM { tb_name | st
SELECT LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] SELECT LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause]
``` ```
**Description**: The length in bytes of a string **Description**: The length in bytes of a string.
**Return value type**: Integer **Return value type**: INTEGER.
**Applicable data types**: VARCHAR or NCHAR **Applicable data types**: VARCHAR, NCHAR.
**Applicable table types**: table, STable
**Applicable nested query**: Inner query and Outer query **Applicable table types**: table, STable.
**More explanations** **Applicable nested query**: Inner query and Outer query.
- If the input value is NULL, the output is NULL too
#### LOWER #### LOWER
...@@ -332,19 +320,16 @@ SELECT LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] ...@@ -332,19 +320,16 @@ SELECT LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause]
SELECT LOWER(str|column) FROM { tb_name | stb_name } [WHERE clause] SELECT LOWER(str|column) FROM { tb_name | stb_name } [WHERE clause]
``` ```
**Description**: Convert the input string to lower case **Description**: Convert the input string to lower case.
**Return value type**: Same as input
**Applicable data types**: VARCHAR or NCHAR **Return value type**: Same as input type.
**Applicable table types**: table, STable **Applicable data types**: VARCHAR, NCHAR.
**Applicable nested query**: Inner query and Outer query **Applicable table types**: table, STable.
**More explanations** **Applicable nested query**: Inner query and Outer query.
- If the input value is NULL, the output is NULL too
#### LTRIM #### LTRIM
...@@ -352,19 +337,16 @@ SELECT LOWER(str|column) FROM { tb_name | stb_name } [WHERE clause] ...@@ -352,19 +337,16 @@ SELECT LOWER(str|column) FROM { tb_name | stb_name } [WHERE clause]
SELECT LTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] SELECT LTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause]
``` ```
**Description**: Remove the left leading blanks of a string **Description**: Remove the left leading blanks of a string.
**Return value type**: Same as input
**Applicable data types**: VARCHAR or NCHAR **Return value type**: Same as input type.
**Applicable table types**: table, STable **Applicable data types**: VARCHAR, NCHAR.
**Applicable nested query**: Inner query and Outer query **Applicable table types**: table, STable.
**More explanations** **Applicable nested query**: Inner query and Outer query.
- If the input value is NULL, the output is NULL too
#### RTRIM #### RTRIM
...@@ -372,19 +354,16 @@ SELECT LTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] ...@@ -372,19 +354,16 @@ SELECT LTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause]
SELECT RTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] SELECT RTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause]
``` ```
**Description**: Remove the right tailing blanks of a string **Description**: Remove the right tailing blanks of a string.
**Return value type**: Same as input
**Applicable data types**: VARCHAR or NCHAR **Return value type**: Same as input type.
**Applicable table types**: table, STable **Applicable data types**: VARCHAR, NCHAR.
**Applicable nested query**: Inner query and Outer query **Applicable table types**: table, STable.
**More explanations** **Applicable nested query**: Inner query and Outer query.
- If the input value is NULL, the output is NULL too
#### SUBSTR #### SUBSTR
...@@ -392,21 +371,21 @@ SELECT RTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] ...@@ -392,21 +371,21 @@ SELECT RTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause]
SELECT SUBSTR(str,pos[,len]) FROM { tb_name | stb_name } [WHERE clause] SELECT SUBSTR(str,pos[,len]) FROM { tb_name | stb_name } [WHERE clause]
``` ```
**Description**: The sub-string starting from `pos` with length of `len` from the original string `str` **Description**: The sub-string starting from `pos` with length of `len` from the original string `str`.
**Return value type**: Same as input **Return value type**: Same as input type.
**Applicable data types**: VARCHAR or NCHAR **Applicable data types**: VARCHAR, NCHAR.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**Applicable nested query**: Inner query and Outer query **Applicable nested query**: Inner query and Outer query.
**More explanations**: **More explanations**:
- If the input is NULL, the output is NULL - If the input is NULL, the output is NULL
- Parameter `pos` can be an positive or negative integer; If it's positive, the starting position will be counted from the beginning of the string; if it's negative, the starting position will be counted from the end of the string. - Parameter `pos` can be an positive or negative integer; If it's positive, the starting position will be counted from the beginning of the string; if it's negative, the starting position will be counted from the end of the string.
- If `len` is not specified, it means from `pos` to the end. - If `len` is not specified, it means from `pos` to the end of string.
#### UPPER #### UPPER
...@@ -414,23 +393,20 @@ SELECT SUBSTR(str,pos[,len]) FROM { tb_name | stb_name } [WHERE clause] ...@@ -414,23 +393,20 @@ SELECT SUBSTR(str,pos[,len]) FROM { tb_name | stb_name } [WHERE clause]
SELECT UPPER(str|column) FROM { tb_name | stb_name } [WHERE clause] SELECT UPPER(str|column) FROM { tb_name | stb_name } [WHERE clause]
``` ```
**Description**: Convert the input string to upper case **Description**: Convert the input string to upper case.
**Return value type**: Same as input **Return value type**: Same as input type.
**Applicable data types**: VARCHAR or NCHAR **Applicable data types**: VARCHAR, NCHAR.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**Applicable nested query**: Inner query and Outer query
**More explanations** **Applicable nested query**: Inner query and Outer query.
- If the input value is NULL, the output is NULL too
### Conversion Functions ### Conversion Functions
This kind of functions convert from one data type to another one. Conversion functions convert from one data type to another.
#### CAST #### CAST
...@@ -438,43 +414,38 @@ This kind of functions convert from one data type to another one. ...@@ -438,43 +414,38 @@ This kind of functions convert from one data type to another one.
SELECT CAST(expression AS type_name) FROM { tb_name | stb_name } [WHERE clause] SELECT CAST(expression AS type_name) FROM { tb_name | stb_name } [WHERE clause]
``` ```
**Description**: It's used for type casting. The input parameter `expression` can be data columns, constants, scalar functions or arithmetic between them. **Description**: Used for type casting. Convert `expression` to the type specified by `type_name`.
**Return value type**: The type specified by parameter `type_name` **Return value type**: The type specified by parameter `type_name`.
**Applicable data types**: **Applicable data types**: `expression` can be any data type except for JSON.
- Parameter `expression` can be any data type except for JSON
- The output data type specified by `type_name` can only be one of BIGINT/VARCHAR(N)/TIMESTAMP/NCHAR(N)/BIGINT UNSIGNED
**More explanations**: **More explanations**:
- Error will be reported for unsupported type casting - Error will be reported for unsupported type casting.
- NULL will be returned if the input value is NULL
- Some values of some supported data types may not be casted, below are known issues: - Some values of some supported data types may not be casted, below are known issues:
1)When casting VARCHAR/NCHAR to BIGINT/BIGINT UNSIGNED, some characters may be treated as illegal, for example "a" may be converted to 0. 1)When casting VARCHAR/NCHAR to BIGINT/BIGINT UNSIGNED, some characters may be treated as illegal, for example "a" may be converted to 0.
2)There may be overflow when casting singed integer or TIMESTAMP to unsigned BIGINT 2)When casting to numeric type, if converted result is out of range the destination data type can hold, overflow may occur and casting behavior is undefined.
3)There may be overflow when casting unsigned BIGINT to BIGINT 3) When casting to VARCHAR/NCHAR type, if converted string length exceeds the length specified in `type_name`, the result will be truncated. (e.g. CAST("abcd" as BINARY(2)) will return string "ab").
4)There may be overflow when casting FLOAT/DOUBLE to BIGINT or UNSIGNED BIGINT
#### TO_ISO8601 #### TO_ISO8601
```sql ```sql
SELECT TO_ISO8601(ts_val | ts_col) FROM { tb_name | stb_name } [WHERE clause]; SELECT TO_ISO8601(ts[, timezone]) FROM { tb_name | stb_name } [WHERE clause];
``` ```
**Description**: The ISO8601 date/time format converted from a UNIX timestamp, plus the timezone of the client side system **Description**: The ISO8601 date/time format converted from a UNIX timestamp, with timezone attached. `timezone` parameter allows attaching any customized timezone string to the output format. If `timezone` parameter is not specified, the timezone information of client side system will be attached.
**Return value type**: VARCHAR **Return value type**: VARCHAR.
**Applicable column types**: TIMESTAMP, constant or a column **Applicable data types**: INTEGER, TIMESTAMP.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**More explanations**: **More explanations**:
- If the input is UNIX timestamp constant, the precision of the returned value is determined by the digits of the input timestamp - If the input is INTEGER represents UNIX timestamp, the precision of the returned value is determined by the digits of the input integer.
- If the input is a column of TIMESTAMP type, The precision of the returned value is same as the precision set for the current data base in use - If the input is of TIMESTAMP type, The precision of the returned value is same as the precision set for the current database in use.
#### TO_JSON #### TO_JSON
...@@ -482,13 +453,13 @@ SELECT TO_ISO8601(ts_val | ts_col) FROM { tb_name | stb_name } [WHERE clause]; ...@@ -482,13 +453,13 @@ SELECT TO_ISO8601(ts_val | ts_col) FROM { tb_name | stb_name } [WHERE clause];
SELECT TO_JSON(str_literal) FROM { tb_name | stb_name } [WHERE clause]; SELECT TO_JSON(str_literal) FROM { tb_name | stb_name } [WHERE clause];
``` ```
**Description**: Convert a JSON string to a JSON body **Description**: Convert a JSON string to a JSON body.
**Return value type**: JSON **Return value type**: JSON.
**Applicable column types**: JSON string, in the format like '{ "literal" : literal }'. '{}' is NULL value. keys in the string must be string constants, values can be constants of numeric types, bool, string or NULL. Escaping characters are not allowed in the JSON string. **Applicable data types**: JSON string, in the format like '{ "literal" : literal }'. '{}' is NULL value. keys in the string must be string constants, values can be constants of numeric types, bool, string or NULL. Escaping characters are not allowed in the JSON string.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**Applicable nested query**: Inner query and Outer query. **Applicable nested query**: Inner query and Outer query.
...@@ -498,22 +469,22 @@ SELECT TO_JSON(str_literal) FROM { tb_name | stb_name } [WHERE clause]; ...@@ -498,22 +469,22 @@ SELECT TO_JSON(str_literal) FROM { tb_name | stb_name } [WHERE clause];
SELECT TO_UNIXTIMESTAMP(datetime_string | ts_col) FROM { tb_name | stb_name } [WHERE clause]; SELECT TO_UNIXTIMESTAMP(datetime_string | ts_col) FROM { tb_name | stb_name } [WHERE clause];
``` ```
**Description**: UNIX timestamp converted from a string of date/time format **Description**: UNIX timestamp converted from a string of date/time format.
**Return value type**: Long integer **Return value type**: BIGINT.
**Applicable column types**: Constant or column of VARCHAR/NCHAR **Applicable data types**: VARCHAR, NCHAR.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**More explanations**: **More explanations**:
- The input string must be compatible with ISO8601/RFC3339 standard, 0 will be returned if the string can't be converted - The input string must be compatible with ISO8601/RFC3339 standard, NULL will be returned if the string cannot be converted.
- The precision of the returned timestamp is same as the precision set for the current data base in use - The precision of the returned timestamp is same as the precision set for the current database in use.
### DateTime Functions ### DateTime Functions
This kind of functiosn oeprate on timestamp data. NOW(), TODAY() and TIMEZONE() are executed only once even though they may occurr multiple times in a single SQL statement. DateTime functions applied to timestamp data. NOW(), TODAY() and TIMEZONE() are executed only once even though they may occur multiple times in a single SQL statement.
#### NOW #### NOW
...@@ -523,39 +494,39 @@ SELECT select_expr FROM { tb_name | stb_name } WHERE ts_col cond_operatior NOW() ...@@ -523,39 +494,39 @@ SELECT select_expr FROM { tb_name | stb_name } WHERE ts_col cond_operatior NOW()
INSERT INTO tb_name VALUES (NOW(), ...); INSERT INTO tb_name VALUES (NOW(), ...);
``` ```
**Description**: The current time of the client side system **Description**: The current time of the client side system.
**Return value type**: TIMESTAMP **Return value type**: TIMESTAMP.
**Applicable column types**: TIMESTAMP only **Applicable data types**: TIMESTAMP only if used in WHERE/INSERT clause.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**More explanations**: **More explanations**:
- Add and Subtract operation can be performed, for example NOW() + 1s, the time unit can be: - Addition and Subtraction operation with time duration can be performed, for example NOW() + 1s, the time unit can be one of the followings:
b(nanosecond), u(microsecond), a(millisecond)), s(second), m(minute), h(hour), d(day), w(week) b(nanosecond), u(microsecond), a(millisecond)), s(second), m(minute), h(hour), d(day), w(week).
- The precision of the returned timestamp is same as the precision set for the current data base in use - The precision of the returned timestamp is same as the precision set for the current database in use.
#### TIMEDIFF #### TIMEDIFF
```sql ```sql
SELECT TIMEDIFF(ts_val1 | datetime_string1 | ts_col1, ts_val2 | datetime_string2 | ts_col2 [, time_unit]) FROM { tb_name | stb_name } [WHERE clause]; SELECT TIMEDIFF(ts1 | datetime_string1, ts2 | datetime_string2 [, time_unit]) FROM { tb_name | stb_name } [WHERE clause];
``` ```
**Description**: The difference between two timestamps, and rounded to the time unit specified by `time_unit` **Description**: The difference(duration) between two timestamps, and rounded to the time unit specified by `time_unit`.
**Return value type**: Long Integer **Return value type**: BIGINT.
**Applicable column types**: UNIX timestamp constant, string constant of date/time format, or a column of TIMESTAMP type **Applicable data types**: INTEGER/TIMESTAMP represents UNIX timestamp, or VARCHAR/NCHAR string in date/time format.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**More explanations**: **More explanations**:
- Time unit specified by `time_unit` can be: - Time unit specified by `time_unit` can be:
1u(microsecond),1a(millisecond),1s(second),1m(minute),1h(hour),1d(day). 1b(nanosecond), 1u(microsecond),1a(millisecond),1s(second),1m(minute),1h(hour),1d(day),1w(week).
- The precision of the returned timestamp is same as the precision set for the current data base in use - If `time_unit` parameter is not specified, the precision of the returned time duration is same as the precision set for the current database in use.
#### TIMETRUNCATE #### TIMETRUNCATE
...@@ -563,19 +534,19 @@ SELECT TIMEDIFF(ts_val1 | datetime_string1 | ts_col1, ts_val2 | datetime_string2 ...@@ -563,19 +534,19 @@ SELECT TIMEDIFF(ts_val1 | datetime_string1 | ts_col1, ts_val2 | datetime_string2
SELECT TIMETRUNCATE(ts_val | datetime_string | ts_col, time_unit) FROM { tb_name | stb_name } [WHERE clause]; SELECT TIMETRUNCATE(ts_val | datetime_string | ts_col, time_unit) FROM { tb_name | stb_name } [WHERE clause];
``` ```
**Description**: Truncate the input timestamp with unit specified by `time_unit` **Description**: Truncate the input timestamp with unit specified by `time_unit`.
**Return value type**: TIMESTAMP **Return value type**: TIMESTAMP.
**Applicable column types**: UNIX timestamp constant, string constant of date/time format, or a column of timestamp **Applicable data types**: INTEGER/TIMESTAMP represents UNIX timestamp, or VARCHAR/NCHAR string in date/time format.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**More explanations**: **More explanations**:
- Time unit specified by `time_unit` can be: - Time unit specified by `time_unit` can be:
1u(microsecond),1a(millisecond),1s(second),1m(minute),1h(hour),1d(day). 1b(nanosecond),1u(microsecond),1a(millisecond),1s(second),1m(minute),1h(hour),1d(day),1w(week).
- The precision of the returned timestamp is same as the precision set for the current data base in use - The precision of the returned timestamp is same as the precision set for the current database in use.
#### TIMEZONE #### TIMEZONE
...@@ -583,13 +554,13 @@ SELECT TIMETRUNCATE(ts_val | datetime_string | ts_col, time_unit) FROM { tb_name ...@@ -583,13 +554,13 @@ SELECT TIMETRUNCATE(ts_val | datetime_string | ts_col, time_unit) FROM { tb_name
SELECT TIMEZONE() FROM { tb_name | stb_name } [WHERE clause]; SELECT TIMEZONE() FROM { tb_name | stb_name } [WHERE clause];
``` ```
**Description**: The timezone of the client side system **Description**: The timezone of the client side system.
**Return value type**: VARCHAR **Return value type**: VARCHAR.
**Applicable column types**: None **Applicable data types**: None.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
#### TODAY #### TODAY
...@@ -599,19 +570,19 @@ SELECT select_expr FROM { tb_name | stb_name } WHERE ts_col cond_operatior TODAY ...@@ -599,19 +570,19 @@ SELECT select_expr FROM { tb_name | stb_name } WHERE ts_col cond_operatior TODAY
INSERT INTO tb_name VALUES (TODAY(), ...); INSERT INTO tb_name VALUES (TODAY(), ...);
``` ```
**Description**: The timestamp of 00:00:00 of the client side system **Description**: The timestamp of 00:00:00 of the client side system.
**Return value type**: TIMESTAMP **Return value type**: TIMESTAMP.
**Applicable column types**: TIMESTAMP only **Applicable data types**: TIMESTAMP only if used in WHERE/INSERT clause.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**More explanations**: **More explanations**:
- Add and Subtract operation can be performed, for example NOW() + 1s, the time unit can be: - Addition and Subtraction operation can be performed with time durations, for example NOW() + 1s, the time unit can be:
b(nanosecond), u(microsecond), a(millisecond)), s(second), m(minute), h(hour), d(day), w(week) b(nanosecond), u(microsecond), a(millisecond)), s(second), m(minute), h(hour), d(day), w(week).
- The precision of the returned timestamp is same as the precision set for the current data base in use - The precision of the returned timestamp is same as the precision set for the current database in use.
## Aggregate Functions ## Aggregate Functions
...@@ -623,13 +594,13 @@ Aggregate functions return single result row for each group in the query result ...@@ -623,13 +594,13 @@ Aggregate functions return single result row for each group in the query result
SELECT AVG(field_name) FROM tb_name [WHERE clause]; SELECT AVG(field_name) FROM tb_name [WHERE clause];
``` ```
**Description**: Get the average value of a column in a table or STable **Description**: Get the average value of a column in a table or STable.
**Return value type**: Double precision floating number **Return value type**: DOUBLE.
**Applicable column types**: Numeric type **Applicable data types**: Numeric type.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
### COUNT ### COUNT
...@@ -637,17 +608,17 @@ SELECT AVG(field_name) FROM tb_name [WHERE clause]; ...@@ -637,17 +608,17 @@ SELECT AVG(field_name) FROM tb_name [WHERE clause];
SELECT COUNT([*|field_name]) FROM tb_name [WHERE clause]; SELECT COUNT([*|field_name]) FROM tb_name [WHERE clause];
``` ```
**Description**: Get the number of rows or the number of non-null values in a table or a super table. **Description**: Get the number of rows in a table or a super table.
**Return value type**: Long integer INT64 **Return value type**: BIGINT.
**Applicable column types**: All **Applicable data types**: All data types.
**Applicable table types**: table, super table, sub table **Applicable table types**: table, STable.
**More explanation**: **More explanation**:
- Wildcard (\*) is used to represent all columns. The `COUNT` function is used to get the total number of all rows. - Wildcard (\*) is used to represent all columns. If \* used `COUNT` function will get the total number of all rows.
- The number of non-NULL values will be returned if this function is used on a specific column. - The number of non-NULL values will be returned if this function is used on a specific column.
### ELAPSED ### ELAPSED
...@@ -656,13 +627,13 @@ SELECT COUNT([*|field_name]) FROM tb_name [WHERE clause]; ...@@ -656,13 +627,13 @@ SELECT COUNT([*|field_name]) FROM tb_name [WHERE clause];
SELECT ELAPSED(field_name[, time_unit]) FROM { tb_name | stb_name } [WHERE clause] [INTERVAL(interval [, offset]) [SLIDING sliding]]; SELECT ELAPSED(field_name[, time_unit]) FROM { tb_name | stb_name } [WHERE clause] [INTERVAL(interval [, offset]) [SLIDING sliding]];
``` ```
**Description**`elapsed` function can be used to calculate the continuous time length in which there is valid data. If it's used with `INTERVAL` clause, the returned result is the calcualted time length within each time window. If it's used without `INTERVAL` caluse, the returned result is the calculated time length within the specified time range. Please be noted that the return value of `elapsed` is the number of `time_unit` in the calculated time length. **Description**`elapsed` function can be used to calculate the continuous time length in which there is valid data. If it's used with `INTERVAL` clause, the returned result is the calcualted time length within each time window. If it's used without `INTERVAL` caluse, the returned result is the calculated time duration within the specified time range. Please be noted that the calculated time duration is in the specified `time_unit`.
**Return value type**:Double **Return value type**:DOUBLE.
**Applicable Column type**:Timestamp **Applicable Column type**:TIMESTAMP.
**Applicable tables**: table, STable, outter in nested query **Applicable tables**: table, STable, outter in nested query.
**Explanations** **Explanations**
...@@ -673,7 +644,7 @@ SELECT ELAPSED(field_name[, time_unit]) FROM { tb_name | stb_name } [WHERE claus ...@@ -673,7 +644,7 @@ SELECT ELAPSED(field_name[, time_unit]) FROM { tb_name | stb_name } [WHERE claus
- `group by tbname` must be used together when `elapsed` is used against a STable. - `group by tbname` must be used together when `elapsed` is used against a STable.
- `group by` must NOT be used together when `elapsed` is used against a table or sub table. - `group by` must NOT be used together when `elapsed` is used against a table or sub table.
- When used in nested query, it's only applicable when the inner query outputs an implicit timestamp column as the primary key. For example, `select elapsed(ts) from (select diff(value) from sub1)` is legal usage while `select elapsed(ts) from (select * from sub1)` is not. - When used in nested query, it's only applicable when the inner query outputs an implicit timestamp column as the primary key. For example, `select elapsed(ts) from (select diff(value) from sub1)` is legal usage while `select elapsed(ts) from (select * from sub1)` is not.
- It can't be used with `leastsquares`, `diff`, `derivative`, `top`, `bottom`, `last_row`, `interp`. - It cannot be used with `leastsquares`, `diff`, `derivative`, `top`, `bottom`, `last_row`, `interp`.
### LEASTSQUARES ### LEASTSQUARES
...@@ -683,11 +654,12 @@ SELECT LEASTSQUARES(field_name, start_val, step_val) FROM tb_name [WHERE clause] ...@@ -683,11 +654,12 @@ SELECT LEASTSQUARES(field_name, start_val, step_val) FROM tb_name [WHERE clause]
**Description**: The linear regression function of the specified column and the timestamp column (primary key), `start_val` is the initial value and `step_val` is the step value. **Description**: The linear regression function of the specified column and the timestamp column (primary key), `start_val` is the initial value and `step_val` is the step value.
**Return value type**: A string in the format of "(slope, intercept)" **Return value type**: VARCHAR string in the format of "(slope, intercept)".
**Applicable column types**: Numeric types **Applicable data types**: Numeric types.
**Applicable table types**: table only.
**Applicable table types**: table only
### MODE ### MODE
...@@ -695,11 +667,11 @@ SELECT LEASTSQUARES(field_name, start_val, step_val) FROM tb_name [WHERE clause] ...@@ -695,11 +667,11 @@ SELECT LEASTSQUARES(field_name, start_val, step_val) FROM tb_name [WHERE clause]
SELECT MODE(field_name) FROM tb_name [WHERE clause]; SELECT MODE(field_name) FROM tb_name [WHERE clause];
``` ```
**Description**:The value which has the highest frequency of occurrence. NULL is returned if there are multiple values which have highest frequency of occurrence. It can't be used on timestamp column. **Description**:The value which has the highest frequency of occurrence. NULL is returned if there are multiple values which have highest frequency of occurrence.
**Return value type**:Same as the data type of the column being operated upon **Return value type**:Same as the data type of the column being operated upon.
**Applicable column types**:Data types except for timestamp **Applicable column types**: All data types.
**More explanations**:Considering the number of returned result set is unpredictable, it's suggested to limit the number of unique values to 100,000, otherwise error will be returned. **More explanations**:Considering the number of returned result set is unpredictable, it's suggested to limit the number of unique values to 100,000, otherwise error will be returned.
...@@ -709,15 +681,15 @@ SELECT MODE(field_name) FROM tb_name [WHERE clause]; ...@@ -709,15 +681,15 @@ SELECT MODE(field_name) FROM tb_name [WHERE clause];
SELECT SPREAD(field_name) FROM { tb_name | stb_name } [WHERE clause]; SELECT SPREAD(field_name) FROM { tb_name | stb_name } [WHERE clause];
``` ```
**Description**: The difference between the max and the min of a specific column **Description**: The difference between the max and the min value of a specific column.
**Return value type**: Double precision floating point **Return value type**: DOUBLE.
**Applicable column types**: Numeric types **Applicable column types**: Numeric types.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**More explanations**: Can be used on a column of TIMESTAMP type, the result is the time range size. **More explanations**: Can be used on a column of TIMESTAMP type, the result time unit precision is same as the current database in use.
### STDDEV ### STDDEV
...@@ -725,13 +697,13 @@ SELECT SPREAD(field_name) FROM { tb_name | stb_name } [WHERE clause]; ...@@ -725,13 +697,13 @@ SELECT SPREAD(field_name) FROM { tb_name | stb_name } [WHERE clause];
SELECT STDDEV(field_name) FROM tb_name [WHERE clause]; SELECT STDDEV(field_name) FROM tb_name [WHERE clause];
``` ```
**Description**: Standard deviation of a specific column in a table or STable **Description**: Standard deviation of a specific column in a table or STable.
**Return value type**: Double precision floating number **Return value type**: DOUBLE.
**Applicable column types**: Numeric types **Applicable column types**: Numeric types.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
### SUM ### SUM
...@@ -739,13 +711,13 @@ SELECT STDDEV(field_name) FROM tb_name [WHERE clause]; ...@@ -739,13 +711,13 @@ SELECT STDDEV(field_name) FROM tb_name [WHERE clause];
SELECT SUM(field_name) FROM tb_name [WHERE clause]; SELECT SUM(field_name) FROM tb_name [WHERE clause];
``` ```
**Description**: The sum of a specific column in a table or STable **Description**: The summation of values of a specific column in a table or STable.
**Return value type**: Double precision floating number or long integer **Return value type**: DOUBLE.
**Applicable column types**: Numeric types **Applicable column types**: Numeric types.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
### HYPERLOGLOG ### HYPERLOGLOG
...@@ -755,9 +727,9 @@ SELECT HYPERLOGLOG(field_name) FROM { tb_name | stb_name } [WHERE clause]; ...@@ -755,9 +727,9 @@ SELECT HYPERLOGLOG(field_name) FROM { tb_name | stb_name } [WHERE clause];
**Description**:The cardinal number of a specific column is returned by using hyperloglog algorithm. **Description**:The cardinal number of a specific column is returned by using hyperloglog algorithm.
**Return value type**:Integer **Return value type**: INTEGER.
**Applicable column types**:Any data type **Applicable column types**: All data types.
**More explanations**: The benefit of using hyperloglog algorithm is that the memory usage is under control when the data volume is huge. However, when the data volume is very small, the result may be not accurate, it's recommented to use `select count(data) from (select unique(col) as data from table)` in this case. **More explanations**: The benefit of using hyperloglog algorithm is that the memory usage is under control when the data volume is huge. However, when the data volume is very small, the result may be not accurate, it's recommented to use `select count(data) from (select unique(col) as data from table)` in this case.
...@@ -769,11 +741,11 @@ SELECT HISTOGRAM(field_name,bin_type, bin_description, normalized) FROM tb_nam ...@@ -769,11 +741,11 @@ SELECT HISTOGRAM(field_name,bin_type, bin_description, normalized) FROM tb_nam
**Description**:Returns count of data points in user-specified ranges. **Description**:Returns count of data points in user-specified ranges.
**Return value type**:Double or INT64, depends on normalized parameter settings. **Return value type**:DOUBLE or BIGINT, depends on normalized parameter settings.
**Applicable column type**:Numerical types. **Applicable column type**:Numerical types.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**Explanations** **Explanations**
...@@ -800,7 +772,7 @@ SELECT HISTOGRAM(field_name,bin_type, bin_description, normalized) FROM tb_nam ...@@ -800,7 +772,7 @@ SELECT HISTOGRAM(field_name,bin_type, bin_description, normalized) FROM tb_nam
## Selector Functions ## Selector Functions
Selector functiosn choose one or more rows in the query result set to retrun according toe the semantics. You can specify to output ts column and other columns including tbname and tags so that you can easily know which rows the selected values belong to. Selector functiosn choose one or more rows in the query result according to the semantics. You can specify to output primary timestamp column and other columns including tbname and tags so that you can easily know which rows the selected values belong to.
### APERCENTILE ### APERCENTILE
...@@ -809,19 +781,19 @@ SELECT APERCENTILE(field_name, P[, algo_type]) ...@@ -809,19 +781,19 @@ SELECT APERCENTILE(field_name, P[, algo_type])
FROM { tb_name | stb_name } [WHERE clause] FROM { tb_name | stb_name } [WHERE clause]
``` ```
**Description**: Similar to `PERCENTILE`, but a simulated result is returned **Description**: Similar to `PERCENTILE`, but a approximated result is returned.
**Return value type**: Double precision floating point **Return value type**: DOUBLE.
**Applicable column types**: Numeric types **Applicable column types**: Numeric types.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**More explanations** **More explanations**
- _P_ is in range [0,100], when _P_ is 0, the result is same as using function MIN; when _P_ is 100, the result is same as function MAX. - _P_ is in range [0,100], when _P_ is 0, the result is same as using function MIN; when _P_ is 100, the result is same as function MAX.
- **algo_type** can only be input as `default` or `t-digest`, if it's not specified `default` will be used, i.e. `apercentile(column_name, 50)` is same as `apercentile(column_name, 50, "default")`. - **algo_type** can only be input as `default` or `t-digest`, if it's not specified `default` will be used, i.e. `apercentile(column_name, 50)` is same as `apercentile(column_name, 50, "default")`.
- When `t-digest` is used, `t-digest` sampling is used to calculate. - If `default` is used, histogram based algorithm is used for calculation. If `t-digest` is used, `t-digest` sampling algorithm is used to calculate the result.
**Nested query**: It can be used in both the outer query and inner query in a nested query. **Nested query**: It can be used in both the outer query and inner query in a nested query.
...@@ -833,17 +805,17 @@ SELECT BOTTOM(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; ...@@ -833,17 +805,17 @@ SELECT BOTTOM(field_name, K) FROM { tb_name | stb_name } [WHERE clause];
**Description**: The least _k_ values of a specific column in a table or STable. If a value has multiple occurrences in the column but counting all of them in will exceed the upper limit _k_, then a part of them will be returned randomly. **Description**: The least _k_ values of a specific column in a table or STable. If a value has multiple occurrences in the column but counting all of them in will exceed the upper limit _k_, then a part of them will be returned randomly.
**Return value type**: Same as the column being operated upon **Return value type**: Same as the column being operated upon.
**Applicable column types**: Numeric types **Applicable column types**: Numeric types.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**More explanations**: **More explanations**:
- _k_ must be in range [1,100] - _k_ must be in range [1,100].
- The timestamp associated with the selected values are returned too - The timestamp associated with the selected values are returned too.
- Can't be used with `FILL` - Can't be used with `FILL`.
### FIRST ### FIRST
...@@ -851,13 +823,13 @@ SELECT BOTTOM(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; ...@@ -851,13 +823,13 @@ SELECT BOTTOM(field_name, K) FROM { tb_name | stb_name } [WHERE clause];
SELECT FIRST(field_name) FROM { tb_name | stb_name } [WHERE clause]; SELECT FIRST(field_name) FROM { tb_name | stb_name } [WHERE clause];
``` ```
**Description**: The first non-null value of a specific column in a table or STable **Description**: The first non-null value of a specific column in a table or STable.
**Return value type**: Same as the column being operated upon **Return value type**: Same as the column being operated upon.
**Applicable column types**: Any data type **Applicable column types**: All data types.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**More explanations**: **More explanations**:
...@@ -873,11 +845,11 @@ SELECT INTERP(field_name) FROM { tb_name | stb_name } [WHERE where_condition] [ ...@@ -873,11 +845,11 @@ SELECT INTERP(field_name) FROM { tb_name | stb_name } [WHERE where_condition] [
**Description**: The value that matches the specified timestamp range is returned, if existing; or an interpolation value is returned. **Description**: The value that matches the specified timestamp range is returned, if existing; or an interpolation value is returned.
**Return value type**: Same as the column being operated upon **Return value type**: Same as the column being operated upon.
**Applicable column types**: Numeric data types **Applicable column types**: Numeric data types.
**Applicable table types**: table, STable, nested query **Applicable table types**: table, STable, nested query.
**More explanations** **More explanations**
...@@ -895,13 +867,13 @@ SELECT INTERP(field_name) FROM { tb_name | stb_name } [WHERE where_condition] [ ...@@ -895,13 +867,13 @@ SELECT INTERP(field_name) FROM { tb_name | stb_name } [WHERE where_condition] [
SELECT LAST(field_name) FROM { tb_name | stb_name } [WHERE clause]; SELECT LAST(field_name) FROM { tb_name | stb_name } [WHERE clause];
``` ```
**Description**: The last non-NULL value of a specific column in a table or STable **Description**: The last non-NULL value of a specific column in a table or STable.
**Return value type**: Same as the column being operated upon **Return value type**: Same as the column being operated upon.
**Applicable column types**: Any data type **Applicable column types**: All data types.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**More explanations**: **More explanations**:
...@@ -915,18 +887,18 @@ SELECT LAST(field_name) FROM { tb_name | stb_name } [WHERE clause]; ...@@ -915,18 +887,18 @@ SELECT LAST(field_name) FROM { tb_name | stb_name } [WHERE clause];
SELECT LAST_ROW(field_name) FROM { tb_name | stb_name }; SELECT LAST_ROW(field_name) FROM { tb_name | stb_name };
``` ```
**Description**: The last row of a table or STable **Description**: The last row of a table or STable.
**Return value type**: Same as the column being operated upon **Return value type**: Same as the column being operated upon.
**Applicable column types**: Any data type **Applicable column types**: All data type.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**More explanations**: **More explanations**:
- When it's used against a STable, multiple rows with the same and largest timestamp may exist, in this case one of them is returned randomly and it's not guaranteed that the result is same if the query is run multiple times. - When it's used against a STable, multiple rows with the same and largest timestamp may exist, in this case one of them is returned randomly and it's not guaranteed that the result is same if the query is run multiple times.
- Can't be used with `INTERVAL`. - Cannot be used with `INTERVAL`.
### MAX ### MAX
...@@ -934,13 +906,13 @@ SELECT LAST_ROW(field_name) FROM { tb_name | stb_name }; ...@@ -934,13 +906,13 @@ SELECT LAST_ROW(field_name) FROM { tb_name | stb_name };
SELECT MAX(field_name) FROM { tb_name | stb_name } [WHERE clause]; SELECT MAX(field_name) FROM { tb_name | stb_name } [WHERE clause];
``` ```
**Description**: The maximum value of a specific column of a table or STable **Description**: The maximum value of a specific column of a table or STable.
**Return value type**: Same as the data type of the column being operated upon **Return value type**: Same as the data type of the column being operated upon.
**Applicable column types**: Numeric types **Applicable column types**: Numeric types.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
### MIN ### MIN
...@@ -948,13 +920,13 @@ SELECT MAX(field_name) FROM { tb_name | stb_name } [WHERE clause]; ...@@ -948,13 +920,13 @@ SELECT MAX(field_name) FROM { tb_name | stb_name } [WHERE clause];
SELECT MIN(field_name) FROM {tb_name | stb_name} [WHERE clause]; SELECT MIN(field_name) FROM {tb_name | stb_name} [WHERE clause];
``` ```
**Description**: The minimum value of a specific column in a table or STable **Description**: The minimum value of a specific column in a table or STable.
**Return value type**: Same as the data type of the column being operated upon **Return value type**: Same as the data type of the column being operated upon.
**Applicable column types**: Numeric types **Applicable column types**: Numeric types.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
### PERCENTILE ### PERCENTILE
...@@ -964,11 +936,11 @@ SELECT PERCENTILE(field_name, P) FROM { tb_name } [WHERE clause]; ...@@ -964,11 +936,11 @@ SELECT PERCENTILE(field_name, P) FROM { tb_name } [WHERE clause];
**Description**: The value whose rank in a specific column matches the specified percentage. If such a value matching the specified percentage doesn't exist in the column, an interpolation value will be returned. **Description**: The value whose rank in a specific column matches the specified percentage. If such a value matching the specified percentage doesn't exist in the column, an interpolation value will be returned.
**Return value type**: Double precision floating point **Return value type**: DOUBLE.
**Applicable column types**: Numeric types **Applicable column types**: Numeric types.
**Applicable table types**: table **Applicable table types**: table.
**More explanations**: _P_ is in range [0,100], when _P_ is 0, the result is same as using function MIN; when _P_ is 100, the result is same as function MAX. **More explanations**: _P_ is in range [0,100], when _P_ is 0, the result is same as using function MIN; when _P_ is 100, the result is same as function MAX.
...@@ -980,11 +952,11 @@ SELECT TAIL(field_name, k, offset_val) FROM {tb_name | stb_name} [WHERE clause]; ...@@ -980,11 +952,11 @@ SELECT TAIL(field_name, k, offset_val) FROM {tb_name | stb_name} [WHERE clause];
**Description**: The next _k_ rows are returned after skipping the last `offset_val` rows, NULL values are not ignored. `offset_val` is optional parameter. When it's not specified, the last _k_ rows are returned. When `offset_val` is used, the effect is same as `order by ts desc LIMIT k OFFSET offset_val`. **Description**: The next _k_ rows are returned after skipping the last `offset_val` rows, NULL values are not ignored. `offset_val` is optional parameter. When it's not specified, the last _k_ rows are returned. When `offset_val` is used, the effect is same as `order by ts desc LIMIT k OFFSET offset_val`.
**Parameter value range**: k: [1,100] offset_val: [0,100] **Parameter value range**: k: [1,100] offset_val: [0,100].
**Return value type**: Same as the column being operated upon **Return value type**: Same as the column being operated upon.
**Applicable column types**: Any data type except form timestamp, i.e. the primary key **Applicable column types**: All data types.
### TOP ### TOP
...@@ -994,17 +966,17 @@ SELECT TOP(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; ...@@ -994,17 +966,17 @@ SELECT TOP(field_name, K) FROM { tb_name | stb_name } [WHERE clause];
**Description**: The greatest _k_ values of a specific column in a table or STable. If a value has multiple occurrences in the column but counting all of them in will exceed the upper limit _k_, then a part of them will be returned randomly. **Description**: The greatest _k_ values of a specific column in a table or STable. If a value has multiple occurrences in the column but counting all of them in will exceed the upper limit _k_, then a part of them will be returned randomly.
**Return value type**: Same as the column being operated upon **Return value type**: Same as the column being operated upon.
**Applicable column types**: Numeric types **Applicable column types**: Numeric types.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**More explanations**: **More explanations**:
- _k_ must be in range [1,100] - _k_ must be in range [1,100].
- The timestamp associated with the selected values are returned too - The timestamp associated with the selected values are returned too.
- Can't be used with `FILL` - Cannot be used with `FILL`.
### UNIQUE ### UNIQUE
...@@ -1014,9 +986,9 @@ SELECT UNIQUE(field_name) FROM {tb_name | stb_name} [WHERE clause]; ...@@ -1014,9 +986,9 @@ SELECT UNIQUE(field_name) FROM {tb_name | stb_name} [WHERE clause];
**Description**: The values that occur the first time in the specified column. The effect is similar to `distinct` keyword, but it can also be used to match tags or timestamp. **Description**: The values that occur the first time in the specified column. The effect is similar to `distinct` keyword, but it can also be used to match tags or timestamp.
**Return value type**: Same as the column or tag being operated upon **Return value type**: Same as the column or tag being operated upon.
**Applicable column types**: Any data types except for timestamp **Applicable column types**: All data types.
**More explanations**: **More explanations**:
...@@ -1035,18 +1007,18 @@ TDengine provides a set of time-series specific functions to better meet the req ...@@ -1035,18 +1007,18 @@ TDengine provides a set of time-series specific functions to better meet the req
**Description**: The cumulative sum of each row for a specific column. The number of output rows is same as that of the input rows. **Description**: The cumulative sum of each row for a specific column. The number of output rows is same as that of the input rows.
**Return value type**: Long integer for integers; Double for floating points. Timestamp is returned for each row. **Return value type**: BIGINT for signed integer input types; UNSIGNED BIGINT for unsigned integer input types; DOUBLE for floating point input types.
**Applicable data types**: Numeric types **Applicable data types**: Numeric types.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**Applicable nested query**: Inner query and Outer query **Applicable nested query**: Inner query and Outer query.
**More explanations**: **More explanations**:
- Arithmetic operation can't be performed on the result of `csum` function - Arithmetic operation cannot be performed on the result of `csum` function.
- Can only be used with aggregate functions - Can only be used with aggregate functions.
- `Group by tbname` must be used together on a STable to force the result on a single timeline - `Partition by tbname` must be used together on a STable to force the result on a single timeline.
### DERIVATIVE ### DERIVATIVE
...@@ -1056,16 +1028,16 @@ SELECT DERIVATIVE(field_name, time_interval, ignore_negative) FROM tb_name [WHER ...@@ -1056,16 +1028,16 @@ SELECT DERIVATIVE(field_name, time_interval, ignore_negative) FROM tb_name [WHER
**Description**: The derivative of a specific column. The time rage can be specified by parameter `time_interval`, the minimum allowed time range is 1 second (1s); the value of `ignore_negative` can be 0 or 1, 1 means negative values are ignored. **Description**: The derivative of a specific column. The time rage can be specified by parameter `time_interval`, the minimum allowed time range is 1 second (1s); the value of `ignore_negative` can be 0 or 1, 1 means negative values are ignored.
**Return value type**: Double precision floating point **Return value type**: DOUBLE.
**Applicable column types**: Numeric types **Applicable column types**: Numeric types.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**More explanations**: **More explanations**:
- The number of result rows is the number of total rows in the time range subtracted by one, no output for the first row. - The number of result rows is the number of total rows in the time range subtracted by one, no output for the first row.
- It can be used together with `GROUP BY tbname` against a STable. - It can be used together with `PARTITION BY tbname` against a STable.
### DIFF ### DIFF
...@@ -1075,16 +1047,16 @@ SELECT {DIFF(field_name, ignore_negative) | DIFF(field_name)} FROM tb_name [WHER ...@@ -1075,16 +1047,16 @@ SELECT {DIFF(field_name, ignore_negative) | DIFF(field_name)} FROM tb_name [WHER
**Description**: The different of each row with its previous row for a specific column. `ignore_negative` can be specified as 0 or 1, the default value is 1 if it's not specified. `1` means negative values are ignored. **Description**: The different of each row with its previous row for a specific column. `ignore_negative` can be specified as 0 or 1, the default value is 1 if it's not specified. `1` means negative values are ignored.
**Return value type**: Same as the column being operated upon **Return value type**: Same as the column being operated upon.
**Applicable column types**: Numeric types **Applicable column types**: Numeric types.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**More explanations**: **More explanations**:
- The number of result rows is the number of rows subtracted by one, no output for the first row - The number of result rows is the number of rows subtracted by one, no output for the first row.
- It can be used on STable with `GROUP by tbname` - It can be used on STable with `PARTITION by tbname`
### IRATE ### IRATE
...@@ -1094,15 +1066,15 @@ SELECT IRATE(field_name) FROM tb_name WHERE clause; ...@@ -1094,15 +1066,15 @@ SELECT IRATE(field_name) FROM tb_name WHERE clause;
**Description**: instantaneous rate on a specific column. The last two samples in the specified time range are used to calculate instantaneous rate. If the last sample value is smaller, then only the last sample value is used instead of the difference between the last two sample values. **Description**: instantaneous rate on a specific column. The last two samples in the specified time range are used to calculate instantaneous rate. If the last sample value is smaller, then only the last sample value is used instead of the difference between the last two sample values.
**Return value type**: Double precision floating number **Return value type**: DOUBLE.
**Applicable column types**: Numeric types **Applicable column types**: Numeric types.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**More explanations**: **More explanations**:
- It can be used on stble with `GROUP BY`, i.e. timelines generated by `GROUP BY tbname` on a STable. - It can be used on stble with `PARTITION BY`, i.e. timelines generated by `PARTITION BY tbname` on a STable.
### MAVG ### MAVG
...@@ -1112,19 +1084,19 @@ SELECT IRATE(field_name) FROM tb_name WHERE clause; ...@@ -1112,19 +1084,19 @@ SELECT IRATE(field_name) FROM tb_name WHERE clause;
**Description**: The moving average of continuous _k_ values of a specific column. If the number of input rows is less than _k_, nothing is returned. The applicable range of _k_ is [1,1000]. **Description**: The moving average of continuous _k_ values of a specific column. If the number of input rows is less than _k_, nothing is returned. The applicable range of _k_ is [1,1000].
**Return value type**: Double precision floating point **Return value type**: DOUBLE.
**Applicable data types**: Numeric types **Applicable data types**: Numeric types.
**Applicable nested query**: Inner query and Outer query **Applicable nested query**: Inner query and Outer query.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**More explanations**: **More explanations**:
- Arithmetic operation can't be performed on the result of `MAVG`. - Arithmetic operation cannot be performed on the result of `MAVG`.
- Can't be used with aggregate functions. - Cannot be used with aggregate functions.
- Must be used with `GROUP BY tbname` when it's used on a STable to force the result on each single timeline. - Must be used with `PARTITION BY tbname` when it's used on a STable to force the result on each single timeline.
### SAMPLE ### SAMPLE
...@@ -1132,20 +1104,20 @@ SELECT IRATE(field_name) FROM tb_name WHERE clause; ...@@ -1132,20 +1104,20 @@ SELECT IRATE(field_name) FROM tb_name WHERE clause;
SELECT SAMPLE(field_name, K) FROM { tb_name | stb_name } [WHERE clause] SELECT SAMPLE(field_name, K) FROM { tb_name | stb_name } [WHERE clause]
``` ```
**Description**: _k_ sampling values of a specific column. The applicable range of _k_ is [1,10000] **Description**: _k_ sampling values of a specific column. The applicable range of _k_ is [1,1000]
**Return value type**: Same as the column being operated plus the associated timestamp **Return value type**: Same as the column being operated.
**Applicable data types**: Any data type except for tags of STable **Applicable data types**: All data types.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**Applicable nested query**: Inner query and Outer query **Applicable nested query**: Inner query and Outer query.
**More explanations**: **More explanations**:
- Arithmetic operation can't be operated on the result of `SAMPLE` function - Arithmetic operation cannot be operated on the result of `SAMPLE` function
- Must be used with `Group by tbname` when it's used on a STable to force the result on each single timeline - Must be used with `Partition by tbname` when it's used on a STable to force the result on each single timeline.
### STATECOUNT ### STATECOUNT
...@@ -1153,25 +1125,25 @@ SELECT IRATE(field_name) FROM tb_name WHERE clause; ...@@ -1153,25 +1125,25 @@ SELECT IRATE(field_name) FROM tb_name WHERE clause;
SELECT STATECOUNT(field_name, oper, val) FROM { tb_name | stb_name } [WHERE clause]; SELECT STATECOUNT(field_name, oper, val) FROM { tb_name | stb_name } [WHERE clause];
``` ```
**Description**: The number of continuous rows satisfying the specified conditions for a specific column. The result is shown as an extra column for each row. If the specified condition is evaluated as true, the number is increased by 1; otherwise the number is reset to -1. If the input value is NULL, then the corresponding row is skipped. **Description**: The number of continuous rows satisfying the specified conditions for a specific column. If the specified condition is evaluated as true, the number is increased by 1; otherwise the number is reset to -1. If the input value is NULL, then the corresponding row is skipped.
**Applicable parameter values**: **Applicable parameter values**:
- oper : Can be one of LT (lower than), GT (greater than), LE (lower than or euqal to), GE (greater than or equal to), NE (not equal to), EQ (equal to), the value is case insensitive - oper : Can be one of "LT" (lower than), "GT" (greater than), "LE" (lower than or euqal to), "GE" (greater than or equal to), "NE" (not equal to), "EQ" (equal to).
- val : Numeric types - val : Numeric types.
**Return value type**: Integer **Return value type**: INTEGER.
**Applicable data types**: Numeric types **Applicable data types**: Numeric types.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**Applicable nested query**: Outer query only **Applicable nested query**: Outer query only.
**More explanations**: **More explanations**:
- Must be used together with `GROUP BY tbname` when it's used on a STable to force the result into each single timeline] - Must be used together with `PARTITION BY tbname` when it's used on a STable to force the result into each single timeline.
- Can't be used with window operation, like interval/state_window/session_window - Cannot be used with window operation, like interval/state_window/session_window.
### STATEDURATION ### STATEDURATION
...@@ -1179,26 +1151,26 @@ SELECT STATECOUNT(field_name, oper, val) FROM { tb_name | stb_name } [WHERE clau ...@@ -1179,26 +1151,26 @@ SELECT STATECOUNT(field_name, oper, val) FROM { tb_name | stb_name } [WHERE clau
SELECT stateDuration(field_name, oper, val, unit) FROM { tb_name | stb_name } [WHERE clause]; SELECT stateDuration(field_name, oper, val, unit) FROM { tb_name | stb_name } [WHERE clause];
``` ```
**Description**: The length of time range in which all rows satisfy the specified condition for a specific column. The result is shown as an extra column for each row. The length for the first row that satisfies the condition is 0. Next, if the condition is evaluated as true for a row, the time interval between current row and its previous row is added up to the time range; otherwise the time range length is reset to -1. If the value of the column is NULL, the corresponding row is skipped. **Description**: The length of time range in which all rows satisfy the specified condition for a specific column. The length for the first row that satisfies the condition is 0. Next, if the condition is evaluated as true for a row, the time interval between current row and its previous row is added up to the time range; otherwise the time range length is reset to -1. If the value of the column is NULL, the corresponding row is skipped.
**Applicable parameter values**: **Applicable parameter values**:
- oper : Can be one of LT (lower than), GT (greater than), LE (lower than or euqal to), GE (greater than or equal to), NE (not equal to), EQ (equal to), the value is case insensitive - oper : Can be one of "LT" (lower than), "GT" (greater than), "LE" (lower than or euqal to), "GE" (greater than or equal to), "NE" (not equal to), "EQ" (equal to).
- val : Numeric types - val : Numeric types.
- unit: The unit of time interval, can be [1s, 1m, 1h], default is 1s - unit: The unit of time interval, can be [1s, 1m, 1h], default is 1s.
**Return value type**: Integer **Return value type**: INTEGER.
**Applicable data types**: Numeric types **Applicable data types**: Numeric types.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**Applicable nested query**: Outer query only **Applicable nested query**: Outer query only.
**More explanations**: **More explanations**:
- Must be used together with `GROUP BY tbname` when it's used on a STable to force the result into each single timeline] - Must be used together with `PARTITION BY tbname` when it's used on a STable to force the result into each single timeline]
- Can't be used with window operation, like interval/state_window/session_window - Cannot be used with window operation, like interval/state_window/session_window
### TWA ### TWA
...@@ -1206,17 +1178,17 @@ SELECT stateDuration(field_name, oper, val, unit) FROM { tb_name | stb_name } [W ...@@ -1206,17 +1178,17 @@ SELECT stateDuration(field_name, oper, val, unit) FROM { tb_name | stb_name } [W
SELECT TWA(field_name) FROM tb_name WHERE clause; SELECT TWA(field_name) FROM tb_name WHERE clause;
``` ```
**Description**: Time weighted average on a specific column within a time range **Description**: Time weighted average on a specific column within a time range.
**Return value type**: Double precision floating number **Return value type**: DOUBLE.
**Applicable column types**: Numeric types **Applicable column types**: Numeric types.
**Applicable table types**: table, STable **Applicable table types**: table, STable.
**More explanations**: **More explanations**:
- It can be used on stable with `GROUP BY`, i.e. timelines generated by `GROUP BY tbname` on a STable. - It can be used on stable with `PARTITION BY`, i.e. timelines generated by `PARTITION BY tbname` on a STable.
## System Information Functions ## System Information Functions
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册