diff --git a/src/UserGuide/Master/Tree/SQL-Manual/Function-and-Expression.md b/src/UserGuide/Master/Tree/SQL-Manual/Function-and-Expression.md index 328b2a66d..160bb069d 100644 --- a/src/UserGuide/Master/Tree/SQL-Manual/Function-and-Expression.md +++ b/src/UserGuide/Master/Tree/SQL-Manual/Function-and-Expression.md @@ -2583,109 +2583,9 @@ Output series: +-----------------------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+ ``` - - -## 13. Lambda Expression - -### 13.1 JEXL Function - -Java Expression Language (JEXL) is an expression language engine. We use JEXL to extend UDFs, which are implemented on the command line with simple lambda expressions. See the link for [operators supported in jexl lambda expressions](https://commons.apache.org/proper/commons-jexl/apidocs/org/apache/commons/jexl3/package-summary.html#customization). - -| Function Name | Allowed Input Series Data Types | Required Attributes | Output Series Data Type | Series Data Type Description | -|----------|--------------------------------|---------------------------------------|------------|--------------------------------------------------| -| JEXL | INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | `expr` is a lambda expression that supports standard one or multi arguments in the form `x -> {...}` or `(x, y, z) -> {...}`, e.g. ` x -> {x * 2}`, `(x, y, z) -> {x + y * z}` | INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | Returns the input time series transformed by a lambda expression | - -##### Demonstrate -Example data: `root.ln.wf01.wt01.temperature`, `root.ln.wf01.wt01.st`, `root.ln.wf01.wt01.str` a total of `11` data. - -``` -IoTDB> select * from root.ln.wf01.wt01; -+-----------------------------+---------------------+--------------------+-----------------------------+ -| Time|root.ln.wf01.wt01.str|root.ln.wf01.wt01.st|root.ln.wf01.wt01.temperature| -+-----------------------------+---------------------+--------------------+-----------------------------+ -|1970-01-01T08:00:00.000+08:00| str| 10.0| 0.0| -|1970-01-01T08:00:00.001+08:00| str| 20.0| 1.0| -|1970-01-01T08:00:00.002+08:00| str| 30.0| 2.0| -|1970-01-01T08:00:00.003+08:00| str| 40.0| 3.0| -|1970-01-01T08:00:00.004+08:00| str| 50.0| 4.0| -|1970-01-01T08:00:00.005+08:00| str| 60.0| 5.0| -|1970-01-01T08:00:00.006+08:00| str| 70.0| 6.0| -|1970-01-01T08:00:00.007+08:00| str| 80.0| 7.0| -|1970-01-01T08:00:00.008+08:00| str| 90.0| 8.0| -|1970-01-01T08:00:00.009+08:00| str| 100.0| 9.0| -|1970-01-01T08:00:00.010+08:00| str| 110.0| 10.0| -+-----------------------------+---------------------+--------------------+-----------------------------+ -``` -Sql: -```sql -select jexl(temperature, 'expr'='x -> {x + x}') as jexl1, jexl(temperature, 'expr'='x -> {x * 3}') as jexl2, jexl(temperature, 'expr'='x -> {x * x}') as jexl3, jexl(temperature, 'expr'='x -> {multiply(x, 100)}') as jexl4, jexl(temperature, st, 'expr'='(x, y) -> {x + y}') as jexl5, jexl(temperature, st, str, 'expr'='(x, y, z) -> {x + y + z}') as jexl6 from root.ln.wf01.wt01;``` -``` - -Result: -``` -+-----------------------------+-----+-----+-----+------+-----+--------+ -| Time|jexl1|jexl2|jexl3| jexl4|jexl5| jexl6| -+-----------------------------+-----+-----+-----+------+-----+--------+ -|1970-01-01T08:00:00.000+08:00| 0.0| 0.0| 0.0| 0.0| 10.0| 10.0str| -|1970-01-01T08:00:00.001+08:00| 2.0| 3.0| 1.0| 100.0| 21.0| 21.0str| -|1970-01-01T08:00:00.002+08:00| 4.0| 6.0| 4.0| 200.0| 32.0| 32.0str| -|1970-01-01T08:00:00.003+08:00| 6.0| 9.0| 9.0| 300.0| 43.0| 43.0str| -|1970-01-01T08:00:00.004+08:00| 8.0| 12.0| 16.0| 400.0| 54.0| 54.0str| -|1970-01-01T08:00:00.005+08:00| 10.0| 15.0| 25.0| 500.0| 65.0| 65.0str| -|1970-01-01T08:00:00.006+08:00| 12.0| 18.0| 36.0| 600.0| 76.0| 76.0str| -|1970-01-01T08:00:00.007+08:00| 14.0| 21.0| 49.0| 700.0| 87.0| 87.0str| -|1970-01-01T08:00:00.008+08:00| 16.0| 24.0| 64.0| 800.0| 98.0| 98.0str| -|1970-01-01T08:00:00.009+08:00| 18.0| 27.0| 81.0| 900.0|109.0|109.0str| -|1970-01-01T08:00:00.010+08:00| 20.0| 30.0|100.0|1000.0|120.0|120.0str| -+-----------------------------+-----+-----+-----+------+-----+--------+ -Total line number = 11 -It costs 0.118s -``` - - - - -## 14. Conditional Expressions +## 13. Conditional Expressions -### 14.1 CASE +### 13.1 CASE The CASE expression is a kind of conditional expression that can be used to return different values based on specific conditions, similar to the if-else statements in other languages. diff --git a/src/UserGuide/Master/Tree/SQL-Manual/Operator-and-Expression.md b/src/UserGuide/Master/Tree/SQL-Manual/Operator-and-Expression.md index ee905b41f..d484ec327 100644 --- a/src/UserGuide/Master/Tree/SQL-Manual/Operator-and-Expression.md +++ b/src/UserGuide/Master/Tree/SQL-Manual/Operator-and-Expression.md @@ -25,7 +25,7 @@ This chapter describes the operators and functions supported by IoTDB. IoTDB pro A list of all available functions, both built-in and custom, can be displayed with `SHOW FUNCTIONS` command. -See the documentation [Select-Expression](../SQL-Manual/Function-and-Expression.md#selector-functions) for the behavior of operators and functions in SQL. +See the documentation [Select-Expression](../SQL-Manual/Function-and-Expression.md#_8-selector-functions) for the behavior of operators and functions in SQL. ## 1. OPERATORS @@ -41,7 +41,7 @@ See the documentation [Select-Expression](../SQL-Manual/Function-and-Expression. | `+` | addition | | `-` | subtraction | -For details and examples, see the document [Arithmetic Operators and Functions](../SQL-Manual/Function-and-Expression.md#arithmetic-functions). +For details and examples, see the document [Arithmetic Operators and Functions](../SQL-Manual/Function-and-Expression.md#_1-1-arithmetic-operators). ### 1.2 Comparison Operators @@ -64,7 +64,7 @@ For details and examples, see the document [Arithmetic Operators and Functions]( | `IN` / `CONTAINS` | is a value in the specified list | | `NOT IN` / `NOT CONTAINS` | is not a value in the specified list | -For details and examples, see the document [Comparison Operators and Functions](../SQL-Manual/Function-and-Expression.md#comparison-operators-and-functions). +For details and examples, see the document [Comparison Operators and Functions](../SQL-Manual/Function-and-Expression.md#_2-comparison-operators-and-functions). ### 1.3 Logical Operators @@ -74,7 +74,7 @@ For details and examples, see the document [Comparison Operators and Functions]( | `AND` / `&` / `&&` | logical AND | | `OR`/ | / || | logical OR | -For details and examples, see the document [Logical Operators](../SQL-Manual/Function-and-Expression.md#logical-operators). +For details and examples, see the document [Logical Operators](../SQL-Manual/Function-and-Expression.md#_3-logical-operators). ### 1.4 Operator Precedence @@ -123,7 +123,7 @@ The built-in functions can be used in IoTDB without registration, and the functi | MAX_BY | MAX_BY(x, y) returns the value of x corresponding to the maximum value of the input y. MAX_BY(time, x) returns the timestamp when x is at its maximum value. | The first input x can be of any type, while the second input y must be of type INT32, INT64, FLOAT, DOUBLE, STRING, TIMESTAMP or DATE. | / | Consistent with the data type of the first input x. | | MIN_BY | MIN_BY(x, y) returns the value of x corresponding to the minimum value of the input y. MIN_BY(time, x) returns the timestamp when x is at its minimum value. | The first input x can be of any type, while the second input y must be of type INT32, INT64, FLOAT, DOUBLE, STRING, TIMESTAMP or DATE. | / | Consistent with the data type of the first input x. | -For details and examples, see the document [Aggregate Functions](../SQL-Manual/Function-and-Expression.md#aggregate-functions). +For details and examples, see the document [Aggregate Functions](../SQL-Manual/Function-and-Expression.md#_4-aggregate-functions). ### 2.2 Arithmetic Functions @@ -150,7 +150,7 @@ For details and examples, see the document [Aggregate Functions](../SQL-Manual/F | LOG10 | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE | / | Math#log10(double) | | SQRT | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE | / | Math#sqrt(double) | -For details and examples, see the document [Arithmetic Operators and Functions](../SQL-Manual/Function-and-Expression.md#arithmetic-operators-and-functions). +For details and examples, see the document [Arithmetic Operators and Functions](../SQL-Manual/Function-and-Expression.md#_1-arithmetic-operators-and-functionss). ### 2.3 Comparison Functions @@ -159,7 +159,7 @@ For details and examples, see the document [Arithmetic Operators and Functions]( | ON_OFF | INT32 / INT64 / FLOAT / DOUBLE | `threshold`: a double type variate | BOOLEAN | Return `ts_value >= threshold`. | | IN_RANGR | INT32 / INT64 / FLOAT / DOUBLE | `lower`: DOUBLE type `upper`: DOUBLE type | BOOLEAN | Return `ts_value >= lower && value <= upper`. | -For details and examples, see the document [Comparison Operators and Functions](../SQL-Manual/Function-and-Expression.md#comparison-operators-and-functions). +For details and examples, see the document [Comparison Operators and Functions](../SQL-Manual/Function-and-Expression.md#_2-comparison-operators-and-functions). ### 2.4 String Processing Functions @@ -179,7 +179,7 @@ For details and examples, see the document [Comparison Operators and Functions]( | TRIM | TEXT STRING | / | TEXT | Get the string whose value is same to input series, with all leading and trailing space removed. | | STRCMP | TEXT STRING | / | TEXT | Get the compare result of two input series. Returns `0` if series value are the same, a `negative integer` if value of series1 is smaller than series2,
a `positive integer` if value of series1 is more than series2. | -For details and examples, see the document [String Processing](../SQL-Manual/Function-and-Expression.md#string-processing). +For details and examples, see the document [String Processing](../SQL-Manual/Function-and-Expression.md#_5-string-processing). ### 2.5 Data Type Conversion Function @@ -187,7 +187,7 @@ For details and examples, see the document [String Processing](../SQL-Manual/Fun | ------------- | ------------------------------------------------------------ | ----------------------- | ------------------------------------------------------------ | | CAST | `type`: Output data type, INT32 / INT64 / FLOAT / DOUBLE / BOOLEAN / TEXT | determined by `type` | Convert the data to the type specified by the `type` parameter. | -For details and examples, see the document [Data Type Conversion Function](../SQL-Manual/Function-and-Expression.md#data-type-conversion-function). +For details and examples, see the document [Data Type Conversion Function](../SQL-Manual/Function-and-Expression.md#_6-data-type-conversion-function). ### 2.6 Constant Timeseries Generating Functions @@ -197,7 +197,7 @@ For details and examples, see the document [Data Type Conversion Function](../SQ | PI | None | DOUBLE | Data point value: a `double` value of `π`, the ratio of the circumference of a circle to its diameter, which is equals to `Math.PI` in the *Java Standard Library*. | | E | None | DOUBLE | Data point value: a `double` value of `e`, the base of the natural logarithms, which is equals to `Math.E` in the *Java Standard Library*. | -For details and examples, see the document [Constant Timeseries Generating Functions](../SQL-Manual/Function-and-Expression.md#constant-timeseries-generating-functions). +For details and examples, see the document [Constant Timeseries Generating Functions](../SQL-Manual/Function-and-Expression.md#_7-constant-timeseries-generating-functions). ### 2.7 Selector Functions @@ -206,7 +206,7 @@ For details and examples, see the document [Constant Timeseries Generating Funct | TOP_K | INT32 / INT64 / FLOAT / DOUBLE / TEXT / STRING / DATE / TIEMSTAMP | `k`: the maximum number of selected data points, must be greater than 0 and less than or equal to 1000 | Same type as the input series | Returns `k` data points with the largest values in a time series. | | BOTTOM_K | INT32 / INT64 / FLOAT / DOUBLE / TEXT / STRING / DATE / TIEMSTAMP | `k`: the maximum number of selected data points, must be greater than 0 and less than or equal to 1000 | Same type as the input series | Returns `k` data points with the smallest values in a time series. | -For details and examples, see the document [Selector Functions](../SQL-Manual/Function-and-Expression.md#selector-functions). +For details and examples, see the document [Selector Functions](../SQL-Manual/Function-and-Expression.md#_8-selector-functions). ### 2.8 Continuous Interval Functions @@ -217,7 +217,7 @@ For details and examples, see the document [Selector Functions](../SQL-Manual/Fu | ZERO_COUNT | INT32/ INT64/ FLOAT/ DOUBLE/ BOOLEAN | `min`:Optional with default value `1L` `max`:Optional with default value `Long.MAX_VALUE` | Long | Return intervals' start times and the number of data points in the interval in which the value is always 0(false). Data points number `n` satisfy `n >= min && n <= max` | | NON_ZERO_COUNT | INT32/ INT64/ FLOAT/ DOUBLE/ BOOLEAN | `min`:Optional with default value `1L` `max`:Optional with default value `Long.MAX_VALUE` | Long | Return intervals' start times and the number of data points in the interval in which the value is always not 0(false). Data points number `n` satisfy `n >= min && n <= max` | -For details and examples, see the document [Continuous Interval Functions](../SQL-Manual/Function-and-Expression.md#continuous-interval-functions). +For details and examples, see the document [Continuous Interval Functions](../SQL-Manual/Function-and-Expression.md#_9-continuous-interval-functions). ### 2.9 Variation Trend Calculation Functions @@ -230,7 +230,7 @@ For details and examples, see the document [Continuous Interval Functions](../SQ | NON_NEGATIVE_DERIVATIVE | INT32 / INT64 / FLOAT / DOUBLE | / | DOUBLE | Calculates the absolute value of the rate of change of a data point compared to the previous data point, the result is equals to NON_NEGATIVE_DIFFERENCE / TIME_DIFFERENCE. There is no corresponding output for the first data point. | | DIFF | INT32 / INT64 / FLOAT / DOUBLE | `ignoreNull`:optional,default is true. If is true, the previous data point is ignored when it is null and continues to find the first non-null value forwardly. If the value is false, previous data point is not ignored when it is null, the result is also null because null is used for subtraction | DOUBLE | Calculates the difference between the value of a data point and the value of the previous data point. There is no corresponding output for the first data point, so output is null | -For details and examples, see the document [Variation Trend Calculation Functions](../SQL-Manual/Function-and-Expression.md#variation-trend-calculation-functions). +For details and examples, see the document [Variation Trend Calculation Functions](../SQL-Manual/Function-and-Expression.md#_10-variation-trend-calculation-functions). ### 2.10 Sample Functions @@ -242,7 +242,7 @@ For details and examples, see the document [Variation Trend Calculation Function | EQUAL_SIZE_BUCKET_OUTLIER_SAMPLE | INT32 / INT64 / FLOAT / DOUBLE | The value range of `proportion` is `(0, 1]`, the default is `0.1`
The value of `type` is `avg` or `stendis` or `cos` or `prenextdis`, the default is `avg`
The value of `number` should be greater than 0, the default is `3` | INT32 / INT64 / FLOAT / DOUBLE | Returns outlier samples in equal buckets that match the sampling ratio and the number of samples in the bucket | | M4 | INT32 / INT64 / FLOAT / DOUBLE | Different attributes used by the size window and the time window. The size window uses attributes `windowSize` and `slidingStep`. The time window uses attributes `timeInterval`, `slidingStep`, `displayWindowBegin`, and `displayWindowEnd`. More details see below. | INT32 / INT64 / FLOAT / DOUBLE | Returns the `first, last, bottom, top` points in each sliding window. M4 sorts and deduplicates the aggregated points within the window before outputting them. | -For details and examples, see the document [Sample Functions](../SQL-Manual/Function-and-Expression.md#sample-functions). +For details and examples, see the document [Sample Functions](../SQL-Manual/Function-and-Expression.md#_11-sample-functions). ### 2.11 Change Points Function @@ -250,26 +250,18 @@ For details and examples, see the document [Sample Functions](../SQL-Manual/Func | ------------- | ------------------------------- | ------------------- | ----------------------------- | ----------------------------------------------------------- | | CHANGE_POINTS | INT32 / INT64 / FLOAT / DOUBLE | / | Same type as the input series | Remove consecutive identical values from an input sequence. | -For details and examples, see the document [Time-Series](../SQL-Manual/Function-and-Expression.md#time-series-processing). +For details and examples, see the document [Time-Series](../SQL-Manual/Function-and-Expression.md#_12-time-series-processing). -## 3. LAMBDA EXPRESSION - -| Function Name | Allowed Input Series Data Types | Required Attributes | Output Series Data Type | Series Data Type Description | -| ------------- | ----------------------------------------------- | ------------------------------------------------------------ | ----------------------------------------------- | ------------------------------------------------------------ | -| JEXL | INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | `expr` is a lambda expression that supports standard one or multi arguments in the form `x -> {...}` or `(x, y, z) -> {...}`, e.g. `x -> {x * 2}`, `(x, y, z) -> {x + y * z}` | INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | Returns the input time series transformed by a lambda expression | - -For details and examples, see the document [Lambda](../SQL-Manual/Function-and-Expression.md#lambda-expression). - -## 4. CONDITIONAL EXPRESSION +## 3. CONDITIONAL EXPRESSION | Expression Name | Description | | --------------- | -------------------- | | `CASE` | similar to "if else" | -For details and examples, see the document [Conditional Expressions](../SQL-Manual/Function-and-Expression.md#conditional-expressions). +For details and examples, see the document [Conditional Expressions](../SQL-Manual/Function-and-Expression.md#_13-conditional-expressions). -## 5. SELECT EXPRESSION +## 4. SELECT EXPRESSION The `SELECT` clause specifies the output of the query, consisting of several `selectExpr`. Each `selectExpr` defines one or more columns in the query result. @@ -285,7 +277,7 @@ The `SELECT` clause specifies the output of the query, consisting of several `se - Time series generation functions (including built-in functions and user-defined functions) - constant -### 5.1 Use Alias +### 4.1 Use Alias Since the unique data model of IoTDB, lots of additional information like device will be carried before each sensor. Sometimes, we want to query just one specific device, then these prefix information show frequently will be redundant in this situation, influencing the analysis of result set. At this time, we can use `AS` function provided by IoTDB, assign an alias to time series selected in query. @@ -302,11 +294,11 @@ The result set is: | ... | ... | ... | -### 5.2 Operator +### 4.2 Operator See this documentation for a list of operators supported in IoTDB. -### 5.3 Function +### 4.3 Function #### Aggregate Functions @@ -322,7 +314,7 @@ Aggregate functions are many-to-one functions. They perform aggregate calculatio > select a, count(a) from root.sg group by ([10,100),10ms) > ``` -For the aggregation functions supported by IoTDB, see the document [Aggregate Functions](../SQL-Manual/Function-and-Expression.md#aggregate-functions). +For the aggregation functions supported by IoTDB, see the document [Aggregate Functions](../SQL-Manual/Function-and-Expression.md#_4-aggregate-functions). #### Time Series Generation Function @@ -339,7 +331,7 @@ See this documentation for a list of built-in functions supported in IoTDB. IoTDB supports function extension through User Defined Function (click for [User-Defined Function](../User-Manual/Database-Programming.md#udtfuser-defined-timeseries-generating-function)) capability. -### 5.4 Nested Expressions +### 4.4 Nested Expressions IoTDB supports the calculation of arbitrary nested expressions. Since time series query and aggregation query can not be used in a query statement at the same time, we divide nested expressions into two types, which are nested expressions with time series query and nested expressions with aggregation query. diff --git a/src/UserGuide/Master/Tree/SQL-Manual/SQL-Manual_apache.md b/src/UserGuide/Master/Tree/SQL-Manual/SQL-Manual_apache.md index b27cc3551..74a43ee19 100644 --- a/src/UserGuide/Master/Tree/SQL-Manual/SQL-Manual_apache.md +++ b/src/UserGuide/Master/Tree/SQL-Manual/SQL-Manual_apache.md @@ -915,7 +915,7 @@ For more details, see document [Operator-and-Expression](./Operator-and-Expressi ### 9.1 Arithmetic Operators -For details and examples, see the document [Arithmetic Operators and Functions](./Operator-and-Expression.md#arithmetic-operators). +For details and examples, see the document [Arithmetic Operators and Functions](./Operator-and-Expression.md#_1-1-arithmetic-operators). ```sql select s1, - s1, s2, + s2, s1 + s2, s1 - s2, s1 * s2, s1 / s2, s1 % s2 from root.sg.d1 @@ -923,7 +923,7 @@ select s1, - s1, s2, + s2, s1 + s2, s1 - s2, s1 * s2, s1 / s2, s1 % s2 from root ### 9.2 Comparison Operators -For details and examples, see the document [Comparison Operators and Functions](./Operator-and-Expression.md#comparison-operators). +For details and examples, see the document [Comparison Operators and Functions](./Operator-and-Expression.md#_1-2-comparison-operators). ```sql # Basic comparison operators @@ -954,7 +954,7 @@ select a, a in (1, 2) from root.test; ### 9.3 Logical Operators -For details and examples, see the document [Logical Operators](./Operator-and-Expression.md#logical-operators). +For details and examples, see the document [Logical Operators](./Operator-and-Expression.md#_1-3-logical-operators). ```sql select a, b, a > 10, a <= b, !(a <= b), a > 10 && a > b from root.test; @@ -962,11 +962,11 @@ select a, b, a > 10, a <= b, !(a <= b), a > 10 && a > b from root.test; ## 10. BUILT-IN FUNCTIONS -For more details, see document [Operator-and-Expression](./Operator-and-Expression.md#built-in-functions). +For more details, see document [Operator-and-Expression](./Operator-and-Expression.md#_2-built-in-functions). ### 10.1 Aggregate Functions -For details and examples, see the document [Aggregate Functions](./Operator-and-Expression.md#aggregate-functions). +For details and examples, see the document [Aggregate Functions](./Operator-and-Expression.md#_2-1-aggregate-functions). ```sql select count(status) from root.ln.wf01.wt01; @@ -979,7 +979,7 @@ select time_duration(s1) from root.db.d1; ### 10.2 Arithmetic Functions -For details and examples, see the document [Arithmetic Operators and Functions](./Operator-and-Expression.md#arithmetic-functions). +For details and examples, see the document [Arithmetic Operators and Functions](./Operator-and-Expression.md#_2-2-arithmetic-functions). ```sql select s1, sin(s1), cos(s1), tan(s1) from root.sg1.d1 limit 5 offset 1000; @@ -988,7 +988,7 @@ select s4,round(s4),round(s4,2),round(s4,-1) from root.sg1.d1; ### 10.3 Comparison Functions -For details and examples, see the document [Comparison Operators and Functions](./Operator-and-Expression.md#comparison-functions). +For details and examples, see the document [Comparison Operators and Functions](./Operator-and-Expression.md#_2-3-comparison-functions). ```sql select ts, on_off(ts, 'threshold'='2') from root.test; @@ -997,7 +997,7 @@ select ts, in_range(ts, 'lower'='2', 'upper'='3.1') from root.test; ### 10.4 String Processing Functions -For details and examples, see the document [String Processing](./Operator-and-Expression.md#string-processing-functions). +For details and examples, see the document [String Processing](./Operator-and-Expression.md#_2-4-string-processing-functions). ```sql select s1, string_contains(s1, 's'='warn') from root.sg1.d4; @@ -1025,7 +1025,7 @@ select regexsplit(s1, "regex"=",", "index"="3") from root.test.d1 ### 10.5 Data Type Conversion Function -For details and examples, see the document [Data Type Conversion Function](./Operator-and-Expression.md#data-type-conversion-function). +For details and examples, see the document [Data Type Conversion Function](./Operator-and-Expression.md#_2-5-data-type-conversion-function). ```sql SELECT cast(s1 as INT32) from root.sg @@ -1033,7 +1033,7 @@ SELECT cast(s1 as INT32) from root.sg ### 10.6 Constant Timeseries Generating Functions -For details and examples, see the document [Constant Timeseries Generating Functions](./Operator-and-Expression.md#constant-timeseries-generating-functions). +For details and examples, see the document [Constant Timeseries Generating Functions](./Operator-and-Expression.md#_2-6-constant-timeseries-generating-functions). ```sql select s1, s2, const(s1, 'value'='1024', 'type'='INT64'), pi(s2), e(s1, s2) from root.sg1.d1; @@ -1041,7 +1041,7 @@ select s1, s2, const(s1, 'value'='1024', 'type'='INT64'), pi(s2), e(s1, s2) from ### 10.7 Selector Functions -For details and examples, see the document [Selector Functions](./Operator-and-Expression.md#selector-functions). +For details and examples, see the document [Selector Functions](./Operator-and-Expression.md#_2-7-selector-functions). ```sql select s1, top_k(s1, 'k'='2'), bottom_k(s1, 'k'='2') from root.sg1.d2 where time > 2020-12-10T20:36:15.530+08:00; @@ -1049,7 +1049,7 @@ select s1, top_k(s1, 'k'='2'), bottom_k(s1, 'k'='2') from root.sg1.d2 where time ### 10.8 Continuous Interval Functions -For details and examples, see the document [Continuous Interval Functions](./Operator-and-Expression.md#continuous-interval-functions). +For details and examples, see the document [Continuous Interval Functions](./Operator-and-Expression.md#_2-8-continuous-interval-functions). ```sql select s1, zero_count(s1), non_zero_count(s2), zero_duration(s3), non_zero_duration(s4) from root.sg.d2; @@ -1057,7 +1057,7 @@ select s1, zero_count(s1), non_zero_count(s2), zero_duration(s3), non_zero_durat ### 10.9 Variation Trend Calculation Functions -For details and examples, see the document [Variation Trend Calculation Functions](./Operator-and-Expression.md#variation-trend-calculation-functions). +For details and examples, see the document [Variation Trend Calculation Functions](./Operator-and-Expression.md#_2-9-variation-trend-calculation-functions). ```sql select s1, time_difference(s1), difference(s1), non_negative_difference(s1), derivative(s1), non_negative_derivative(s1) from root.sg1.d1 limit 5 offset 1000; @@ -1068,7 +1068,7 @@ SELECT DIFF(s1, 'ignoreNull'='false'), DIFF(s2, 'ignoreNull'='false') from root. ### 10.10 Sample Functions -For details and examples, see the document [Sample Functions](./Operator-and-Expression.md#sample-functions). +For details and examples, see the document [Sample Functions](./Operator-and-Expression.md#_2-10-sample-functions). ```sql select equal_size_bucket_random_sample(temperature,'proportion'='0.1') as random_sample from root.ln.wf01.wt01; @@ -1082,7 +1082,7 @@ select M4(s1,'windowSize'='10') from root.vehicle.d1 ### 10.11 Change Points Function -For details and examples, see the document [Time-Series](./Operator-and-Expression.md#change-points-function). +For details and examples, see the document [Time-Series](./Operator-and-Expression.md#_2-11-change-points-function). ```sql select change_points(s1), change_points(s2), change_points(s3), change_points(s4), change_points(s5), change_points(s6) from root.testChangePoints.d1 @@ -1338,15 +1338,7 @@ select representation(s0,"tb"="3","vb"="2") from root.test.d0 select rm(s0, s1,"tb"="3","vb"="2") from root.test.d0 ``` -## 12. LAMBDA EXPRESSION - -For details and examples, see the document [Lambda](../SQL-Manual/UDF-Libraries.md#lambda-expression). - -```sql -select jexl(temperature, 'expr'='x -> {x + x}') as jexl1, jexl(temperature, 'expr'='x -> {x * 3}') as jexl2, jexl(temperature, 'expr'='x -> {x * x}') as jexl3, jexl(temperature, 'expr'='x -> {multiply(x, 100)}') as jexl4, jexl(temperature, st, 'expr'='(x, y) -> {x + y}') as jexl5, jexl(temperature, st, str, 'expr'='(x, y, z) -> {x + y + z}') as jexl6 from root.ln.wf01.wt01;``` -``` - -## 13. CONDITIONAL EXPRESSION +## 12. CONDITIONAL EXPRESSION For details and examples, see the document [Conditional Expressions](../SQL-Manual/UDF-Libraries.md#conditional-expressions). @@ -1384,11 +1376,11 @@ end as `result` from root.test4 ``` -## 14. TRIGGER +## 13. TRIGGER -For more details, see document [Database-Programming](../User-Manual/Database-Programming.md). +For more details, see document [TRIGGER](../User-Manual/Trigger.md). -### 14.1 Create Trigger +### 13.1 Create Trigger ```sql // Create Trigger @@ -1421,7 +1413,7 @@ triggerAttribute ; ``` -### 14.2 Drop Trigger +### 13.2 Drop Trigger ```sql // Drop Trigger @@ -1430,15 +1422,15 @@ dropTrigger ; ``` -### 14.3 Show Trigger +### 13.3 Show Trigger ```sql SHOW TRIGGERS ``` -## 15. CONTINUOUS QUERY (CQ) +## 14. CONTINUOUS QUERY (CQ) -For more details, see document [Operator-and-Expression](./Operator-and-Expression.md). +For more details, see document [CONTINUOUS QUERY](../User-Manual/Database-Programming.md). ```sql CREATE (CONTINUOUS QUERY | CQ) @@ -1461,7 +1453,7 @@ BEGIN END ``` -### 15.1 Configuring execution intervals +### 14.1 Configuring execution intervals ```sql CREATE CONTINUOUS QUERY cq1 @@ -1474,7 +1466,7 @@ SELECT max_value(temperature) END ``` -### 15.2 Configuring time range for resampling +### 14.2 Configuring time range for resampling ```sql CREATE CONTINUOUS QUERY cq2 @@ -1487,7 +1479,7 @@ BEGIN END ``` -### 15.3 Configuring execution intervals and CQ time ranges +### 14.3 Configuring execution intervals and CQ time ranges ```sql CREATE CONTINUOUS QUERY cq3 @@ -1501,7 +1493,7 @@ BEGIN END ``` -### 15.4 Configuring end_time_offset for CQ time range +### 14.4 Configuring end_time_offset for CQ time range ```sql CREATE CONTINUOUS QUERY cq4 @@ -1515,7 +1507,7 @@ BEGIN END ``` -### 15.5 CQ without group by clause +### 14.5 CQ without group by clause ```sql CREATE CONTINUOUS QUERY cq5 @@ -1528,7 +1520,7 @@ BEGIN END ``` -### 15.6 CQ Management +### 14.6 CQ Management #### Listing continuous queries @@ -1546,23 +1538,23 @@ DROP (CONTINUOUS QUERY | CQ) CQs can't be altered once they're created. To change a CQ, you must `DROP` and re`CREATE` it with the updated settings. -## 16. USER-DEFINED FUNCTION (UDF) +## 15. USER-DEFINED FUNCTION (UDF) -For more details, see document [Operator-and-Expression](../SQL-Manual/UDF-Libraries.md). +For more details, see document [UDF Libraries](../SQL-Manual/UDF-Libraries.md). -### 16.1 UDF Registration +### 15.1 UDF Registration ```sql CREATE FUNCTION AS (USING URI URI-STRING)? ``` -### 16.2 UDF Deregistration +### 15.2 UDF Deregistration ```sql DROP FUNCTION ``` -### 16.3 UDF Queries +### 15.3 UDF Queries ```sql SELECT example(*) from root.sg.d1 @@ -1578,17 +1570,17 @@ SELECT s1 * example(* / s1 + s2) FROM root.sg.d1; SELECT s1, s2, s1 + example(s1, s2), s1 - example(s1 + example(s1, s2) / s2) FROM root.sg.d1; ``` -### 16.4 Show All Registered UDFs +### 15.4 Show All Registered UDFs ```sql SHOW FUNCTIONS ``` -## 17. ADMINISTRATION MANAGEMENT +## 16. ADMINISTRATION MANAGEMENT -For more details, see document [Operator-and-Expression](./Operator-and-Expression.md). +For more details, see document [Authority Management](../User-Manual/Authority-Management_apache.md). -### 17.1 SQL Statements +### 16.1 SQL Statements - Create user (Requires MANAGE_USER permission) @@ -1679,7 +1671,7 @@ ALTER USER SET PASSWORD ; eg: ALTER USER tempuser SET PASSWORD 'newpwd'; ``` -### 17.2 Authorization and Deauthorization +### 16.2 Authorization and Deauthorization ```sql diff --git a/src/UserGuide/Master/Tree/SQL-Manual/SQL-Manual_timecho.md b/src/UserGuide/Master/Tree/SQL-Manual/SQL-Manual_timecho.md index 07363f7c6..5907c4b99 100644 --- a/src/UserGuide/Master/Tree/SQL-Manual/SQL-Manual_timecho.md +++ b/src/UserGuide/Master/Tree/SQL-Manual/SQL-Manual_timecho.md @@ -836,7 +836,7 @@ For more details, see document [Operator-and-Expression](./Operator-and-Expressi ### 8.1 Arithmetic Operators -For details and examples, see the document [Arithmetic Operators and Functions](./Operator-and-Expression.md#arithmetic-operators). +For details and examples, see the document [Arithmetic Operators and Functions](./Operator-and-Expression.md#_1-1-arithmetic-operators). ```sql select s1, - s1, s2, + s2, s1 + s2, s1 - s2, s1 * s2, s1 / s2, s1 % s2 from root.sg.d1 @@ -844,7 +844,7 @@ select s1, - s1, s2, + s2, s1 + s2, s1 - s2, s1 * s2, s1 / s2, s1 % s2 from root ### 8.2 Comparison Operators -For details and examples, see the document [Comparison Operators and Functions](./Operator-and-Expression.md#comparison-operators). +For details and examples, see the document [Comparison Operators and Functions](./Operator-and-Expression.md#_1-2-comparison-operators). ```sql # Basic comparison operators @@ -875,7 +875,7 @@ select a, a in (1, 2) from root.test; ### 8.3 Logical Operators -For details and examples, see the document [Logical Operators](./Operator-and-Expression.md#logical-operators). +For details and examples, see the document [Logical Operators](./Operator-and-Expression.md#_1-3-logical-operators). ```sql select a, b, a > 10, a <= b, !(a <= b), a > 10 && a > b from root.test; @@ -883,11 +883,11 @@ select a, b, a > 10, a <= b, !(a <= b), a > 10 && a > b from root.test; ## 9. BUILT-IN FUNCTIONS -For more details, see document [Operator-and-Expression](./Operator-and-Expression.md#built-in-functions). +For more details, see document [Operator-and-Expression](./Operator-and-Expression.md#_2-built-in-functions). ### 9.1 Aggregate Functions -For details and examples, see the document [Aggregate Functions](./Operator-and-Expression.md#aggregate-functions). +For details and examples, see the document [Aggregate Functions](./Operator-and-Expression.md#_2-1-aggregate-functions). ```sql select count(status) from root.ln.wf01.wt01; @@ -900,7 +900,7 @@ select time_duration(s1) from root.db.d1; ### 9.2 Arithmetic Functions -For details and examples, see the document [Arithmetic Operators and Functions](./Operator-and-Expression.md#arithmetic-functions). +For details and examples, see the document [Arithmetic Operators and Functions](./Operator-and-Expression.md#_2-2-arithmetic-functions). ```sql select s1, sin(s1), cos(s1), tan(s1) from root.sg1.d1 limit 5 offset 1000; @@ -909,7 +909,7 @@ select s4,round(s4),round(s4,2),round(s4,-1) from root.sg1.d1; ### 9.3 Comparison Functions -For details and examples, see the document [Comparison Operators and Functions](./Operator-and-Expression.md#comparison-functions). +For details and examples, see the document [Comparison Operators and Functions](./Operator-and-Expression.md#_2-3-comparison-functions). ```sql select ts, on_off(ts, 'threshold'='2') from root.test; @@ -918,7 +918,7 @@ select ts, in_range(ts, 'lower'='2', 'upper'='3.1') from root.test; ### 9.4 String Processing Functions -For details and examples, see the document [String Processing](./Operator-and-Expression.md#string-processing-functions). +For details and examples, see the document [String Processing](./Operator-and-Expression.md#_2-4-string-processing-functions). ```sql select s1, string_contains(s1, 's'='warn') from root.sg1.d4; @@ -946,7 +946,7 @@ select regexsplit(s1, "regex"=",", "index"="3") from root.test.d1 ### 9.5 Data Type Conversion Function -For details and examples, see the document [Data Type Conversion Function](./Operator-and-Expression.md#data-type-conversion-function). +For details and examples, see the document [Data Type Conversion Function](./Operator-and-Expression.md#_2-5-data-type-conversion-function). ```sql SELECT cast(s1 as INT32) from root.sg @@ -954,7 +954,7 @@ SELECT cast(s1 as INT32) from root.sg ### 9.6 Constant Timeseries Generating Functions -For details and examples, see the document [Constant Timeseries Generating Functions](./Operator-and-Expression.md#constant-timeseries-generating-functions). +For details and examples, see the document [Constant Timeseries Generating Functions](./Operator-and-Expression.md#_2-6-constant-timeseries-generating-functions). ```sql select s1, s2, const(s1, 'value'='1024', 'type'='INT64'), pi(s2), e(s1, s2) from root.sg1.d1; @@ -962,7 +962,7 @@ select s1, s2, const(s1, 'value'='1024', 'type'='INT64'), pi(s2), e(s1, s2) from ### 9.7 Selector Functions -For details and examples, see the document [Selector Functions](./Operator-and-Expression.md#selector-functions). +For details and examples, see the document [Selector Functions](./Operator-and-Expression.md#_2-7-selector-functions). ```sql select s1, top_k(s1, 'k'='2'), bottom_k(s1, 'k'='2') from root.sg1.d2 where time > 2020-12-10T20:36:15.530+08:00; @@ -970,7 +970,7 @@ select s1, top_k(s1, 'k'='2'), bottom_k(s1, 'k'='2') from root.sg1.d2 where time ### 9.8 Continuous Interval Functions -For details and examples, see the document [Continuous Interval Functions](./Operator-and-Expression.md#continuous-interval-functions). +For details and examples, see the document [Continuous Interval Functions](./Operator-and-Expression.md#_2-8-continuous-interval-functions). ```sql select s1, zero_count(s1), non_zero_count(s2), zero_duration(s3), non_zero_duration(s4) from root.sg.d2; @@ -978,7 +978,7 @@ select s1, zero_count(s1), non_zero_count(s2), zero_duration(s3), non_zero_durat ### 9.9 Variation Trend Calculation Functions -For details and examples, see the document [Variation Trend Calculation Functions](./Operator-and-Expression.md#variation-trend-calculation-functions). +For details and examples, see the document [Variation Trend Calculation Functions](./Operator-and-Expression.md#_2-9-variation-trend-calculation-functions). ```sql select s1, time_difference(s1), difference(s1), non_negative_difference(s1), derivative(s1), non_negative_derivative(s1) from root.sg1.d1 limit 5 offset 1000; @@ -989,7 +989,7 @@ SELECT DIFF(s1, 'ignoreNull'='false'), DIFF(s2, 'ignoreNull'='false') from root. ### 9.10 Sample Functions -For details and examples, see the document [Sample Functions](./Operator-and-Expression.md#sample-functions). +For details and examples, see the document [Sample Functions](./Operator-and-Expression.md#_2-10-sample-functions). ```sql select equal_size_bucket_random_sample(temperature,'proportion'='0.1') as random_sample from root.ln.wf01.wt01; @@ -1003,7 +1003,7 @@ select M4(s1,'windowSize'='10') from root.vehicle.d1 ### 9.11 Change Points Function -For details and examples, see the document [Time-Series](./Operator-and-Expression.md#change-points-function). +For details and examples, see the document [Time-Series](./Operator-and-Expression.md#_2-11-change-points-function). ```sql select change_points(s1), change_points(s2), change_points(s3), change_points(s4), change_points(s5), change_points(s6) from root.testChangePoints.d1 @@ -1259,15 +1259,8 @@ select representation(s0,"tb"="3","vb"="2") from root.test.d0 select rm(s0, s1,"tb"="3","vb"="2") from root.test.d0 ``` -## 11. LAMBDA EXPRESSION -For details and examples, see the document [Lambda](../SQL-Manual/UDF-Libraries.md#lambda-expression). - -```sql -select jexl(temperature, 'expr'='x -> {x + x}') as jexl1, jexl(temperature, 'expr'='x -> {x * 3}') as jexl2, jexl(temperature, 'expr'='x -> {x * x}') as jexl3, jexl(temperature, 'expr'='x -> {multiply(x, 100)}') as jexl4, jexl(temperature, st, 'expr'='(x, y) -> {x + y}') as jexl5, jexl(temperature, st, str, 'expr'='(x, y, z) -> {x + y + z}') as jexl6 from root.ln.wf01.wt01;``` -``` - -## 12. CONDITIONAL EXPRESSION +## 11. CONDITIONAL EXPRESSION For details and examples, see the document [Conditional Expressions](../SQL-Manual/UDF-Libraries.md#conditional-expressions). @@ -1305,11 +1298,11 @@ end as `result` from root.test4 ``` -## 13. TRIGGER +## 12. TRIGGER -For more details, see document [Database-Programming](../User-Manual/Database-Programming.md). +For more details, see document [TRIGGER](../User-Manual/Trigger.md). -### 13.1 Create Trigger +### 12.1 Create Trigger ```sql // Create Trigger @@ -1342,7 +1335,7 @@ triggerAttribute ; ``` -### 13.2 Drop Trigger +### 12.2 Drop Trigger ```sql // Drop Trigger @@ -1351,15 +1344,15 @@ dropTrigger ; ``` -### 13.3 Show Trigger +### 12.3 Show Trigger ```sql SHOW TRIGGERS ``` -## 14. CONTINUOUS QUERY (CQ) +## 13. CONTINUOUS QUERY (CQ) -For more details, see document [Operator-and-Expression](./Operator-and-Expression.md). +For more details, see document [CONTINUOUS QUERY](../User-Manual/Database-Programming.md). ```sql CREATE (CONTINUOUS QUERY | CQ) @@ -1382,7 +1375,7 @@ BEGIN END ``` -### 14.1 Configuring execution intervals +### 13.1 Configuring execution intervals ```sql CREATE CONTINUOUS QUERY cq1 @@ -1395,7 +1388,7 @@ SELECT max_value(temperature) END ``` -### 14.2 Configuring time range for resampling +### 13.2 Configuring time range for resampling ```sql CREATE CONTINUOUS QUERY cq2 @@ -1408,7 +1401,7 @@ BEGIN END ``` -### 14.3 Configuring execution intervals and CQ time ranges +### 13.3 Configuring execution intervals and CQ time ranges ```sql CREATE CONTINUOUS QUERY cq3 @@ -1422,7 +1415,7 @@ BEGIN END ``` -### 14.4 Configuring end_time_offset for CQ time range +### 13.4 Configuring end_time_offset for CQ time range ```sql CREATE CONTINUOUS QUERY cq4 @@ -1436,7 +1429,7 @@ BEGIN END ``` -### 14.5 CQ without group by clause +### 13.5 CQ without group by clause ```sql CREATE CONTINUOUS QUERY cq5 @@ -1449,7 +1442,7 @@ BEGIN END ``` -### 14.6 CQ Management +### 13.6 CQ Management #### Listing continuous queries @@ -1467,23 +1460,23 @@ DROP (CONTINUOUS QUERY | CQ) CQs can't be altered once they're created. To change a CQ, you must `DROP` and re`CREATE` it with the updated settings. -## 15. USER-DEFINED FUNCTION (UDF) +## 14. USER-DEFINED FUNCTION (UDF) -For more details, see document [Operator-and-Expression](../SQL-Manual/UDF-Libraries.md). +For more details, see document [UDF Libraries](../SQL-Manual/UDF-Libraries.md). -### 15.1 UDF Registration +### 14.1 UDF Registration ```sql CREATE FUNCTION AS (USING URI URI-STRING)? ``` -### 15.2 UDF Deregistration +### 14.2 UDF Deregistration ```sql DROP FUNCTION ``` -### 15.3 UDF Queries +### 14.3 UDF Queries ```sql SELECT example(*) from root.sg.d1 @@ -1499,17 +1492,17 @@ SELECT s1 * example(* / s1 + s2) FROM root.sg.d1; SELECT s1, s2, s1 + example(s1, s2), s1 - example(s1 + example(s1, s2) / s2) FROM root.sg.d1; ``` -### 15.4 Show All Registered UDFs +### 14.4 Show All Registered UDFs ```sql SHOW FUNCTIONS ``` -## 16. ADMINISTRATION MANAGEMENT +## 15. ADMINISTRATION MANAGEMENT -For more details, see document [Operator-and-Expression](./Operator-and-Expression.md). +For more details, see document [Authority Management](../User-Manual/Authority-Management_timecho.md). -### 16.1 SQL Statements +### 15.1 SQL Statements - Create user (Requires MANAGE_USER permission) @@ -1600,7 +1593,7 @@ ALTER USER SET PASSWORD ; eg: ALTER USER tempuser SET PASSWORD 'newpwd'; ``` -### 16.2 Authorization and Deauthorization +### 15.2 Authorization and Deauthorization ```sql diff --git a/src/UserGuide/V1.3.x/SQL-Manual/Function-and-Expression.md b/src/UserGuide/V1.3.x/SQL-Manual/Function-and-Expression.md index 0f41d2548..d52c1161d 100644 --- a/src/UserGuide/V1.3.x/SQL-Manual/Function-and-Expression.md +++ b/src/UserGuide/V1.3.x/SQL-Manual/Function-and-Expression.md @@ -2771,105 +2771,6 @@ Output series: +-----------------------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+ ``` - - -## Lambda Expression - -### JEXL Function - -Java Expression Language (JEXL) is an expression language engine. We use JEXL to extend UDFs, which are implemented on the command line with simple lambda expressions. See the link for [operators supported in jexl lambda expressions](https://commons.apache.org/proper/commons-jexl/apidocs/org/apache/commons/jexl3/package-summary.html#customization). - -| Function Name | Allowed Input Series Data Types | Required Attributes | Output Series Data Type | Series Data Type Description | -|----------|--------------------------------|---------------------------------------|------------|--------------------------------------------------| -| JEXL | INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | `expr` is a lambda expression that supports standard one or multi arguments in the form `x -> {...}` or `(x, y, z) -> {...}`, e.g. ` x -> {x * 2}`, `(x, y, z) -> {x + y * z}` | INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | Returns the input time series transformed by a lambda expression | - -##### Demonstrate -Example data: `root.ln.wf01.wt01.temperature`, `root.ln.wf01.wt01.st`, `root.ln.wf01.wt01.str` a total of `11` data. - -``` -IoTDB> select * from root.ln.wf01.wt01; -+-----------------------------+---------------------+--------------------+-----------------------------+ -| Time|root.ln.wf01.wt01.str|root.ln.wf01.wt01.st|root.ln.wf01.wt01.temperature| -+-----------------------------+---------------------+--------------------+-----------------------------+ -|1970-01-01T08:00:00.000+08:00| str| 10.0| 0.0| -|1970-01-01T08:00:00.001+08:00| str| 20.0| 1.0| -|1970-01-01T08:00:00.002+08:00| str| 30.0| 2.0| -|1970-01-01T08:00:00.003+08:00| str| 40.0| 3.0| -|1970-01-01T08:00:00.004+08:00| str| 50.0| 4.0| -|1970-01-01T08:00:00.005+08:00| str| 60.0| 5.0| -|1970-01-01T08:00:00.006+08:00| str| 70.0| 6.0| -|1970-01-01T08:00:00.007+08:00| str| 80.0| 7.0| -|1970-01-01T08:00:00.008+08:00| str| 90.0| 8.0| -|1970-01-01T08:00:00.009+08:00| str| 100.0| 9.0| -|1970-01-01T08:00:00.010+08:00| str| 110.0| 10.0| -+-----------------------------+---------------------+--------------------+-----------------------------+ -``` -Sql: -```sql -select jexl(temperature, 'expr'='x -> {x + x}') as jexl1, jexl(temperature, 'expr'='x -> {x * 3}') as jexl2, jexl(temperature, 'expr'='x -> {x * x}') as jexl3, jexl(temperature, 'expr'='x -> {multiply(x, 100)}') as jexl4, jexl(temperature, st, 'expr'='(x, y) -> {x + y}') as jexl5, jexl(temperature, st, str, 'expr'='(x, y, z) -> {x + y + z}') as jexl6 from root.ln.wf01.wt01;``` -``` - -Result: -``` -+-----------------------------+-----+-----+-----+------+-----+--------+ -| Time|jexl1|jexl2|jexl3| jexl4|jexl5| jexl6| -+-----------------------------+-----+-----+-----+------+-----+--------+ -|1970-01-01T08:00:00.000+08:00| 0.0| 0.0| 0.0| 0.0| 10.0| 10.0str| -|1970-01-01T08:00:00.001+08:00| 2.0| 3.0| 1.0| 100.0| 21.0| 21.0str| -|1970-01-01T08:00:00.002+08:00| 4.0| 6.0| 4.0| 200.0| 32.0| 32.0str| -|1970-01-01T08:00:00.003+08:00| 6.0| 9.0| 9.0| 300.0| 43.0| 43.0str| -|1970-01-01T08:00:00.004+08:00| 8.0| 12.0| 16.0| 400.0| 54.0| 54.0str| -|1970-01-01T08:00:00.005+08:00| 10.0| 15.0| 25.0| 500.0| 65.0| 65.0str| -|1970-01-01T08:00:00.006+08:00| 12.0| 18.0| 36.0| 600.0| 76.0| 76.0str| -|1970-01-01T08:00:00.007+08:00| 14.0| 21.0| 49.0| 700.0| 87.0| 87.0str| -|1970-01-01T08:00:00.008+08:00| 16.0| 24.0| 64.0| 800.0| 98.0| 98.0str| -|1970-01-01T08:00:00.009+08:00| 18.0| 27.0| 81.0| 900.0|109.0|109.0str| -|1970-01-01T08:00:00.010+08:00| 20.0| 30.0|100.0|1000.0|120.0|120.0str| -+-----------------------------+-----+-----+-----+------+-----+--------+ -Total line number = 11 -It costs 0.118s -``` - - - ## Conditional Expressions diff --git a/src/UserGuide/V1.3.x/SQL-Manual/Operator-and-Expression.md b/src/UserGuide/V1.3.x/SQL-Manual/Operator-and-Expression.md index 204598fae..356c73154 100644 --- a/src/UserGuide/V1.3.x/SQL-Manual/Operator-and-Expression.md +++ b/src/UserGuide/V1.3.x/SQL-Manual/Operator-and-Expression.md @@ -253,14 +253,6 @@ For details and examples, see the document [Sample Functions](../SQL-Manual/Func For details and examples, see the document [Time-Series](./Function-and-Expression.md#time-series-processing). -## LAMBDA EXPRESSION - -| Function Name | Allowed Input Series Data Types | Required Attributes | Output Series Data Type | Series Data Type Description | -| ------------- | ----------------------------------------------- | ------------------------------------------------------------ | ----------------------------------------------- | ------------------------------------------------------------ | -| JEXL | INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | `expr` is a lambda expression that supports standard one or multi arguments in the form `x -> {...}` or `(x, y, z) -> {...}`, e.g. `x -> {x * 2}`, `(x, y, z) -> {x + y * z}` | INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | Returns the input time series transformed by a lambda expression | - -For details and examples, see the document [Lambda](./Function-and-Expression.md#lambda-expression). - ## CONDITIONAL EXPRESSION | Expression Name | Description | diff --git a/src/UserGuide/V1.3.x/SQL-Manual/SQL-Manual.md b/src/UserGuide/V1.3.x/SQL-Manual/SQL-Manual.md index 740e604c6..33bc0891a 100644 --- a/src/UserGuide/V1.3.x/SQL-Manual/SQL-Manual.md +++ b/src/UserGuide/V1.3.x/SQL-Manual/SQL-Manual.md @@ -1338,13 +1338,6 @@ select representation(s0,"tb"="3","vb"="2") from root.test.d0 select rm(s0, s1,"tb"="3","vb"="2") from root.test.d0 ``` -## LAMBDA EXPRESSION - -For details and examples, see the document [Lambda](./UDF-Libraries.md#lambda-expression). - -```sql -select jexl(temperature, 'expr'='x -> {x + x}') as jexl1, jexl(temperature, 'expr'='x -> {x * 3}') as jexl2, jexl(temperature, 'expr'='x -> {x * x}') as jexl3, jexl(temperature, 'expr'='x -> {multiply(x, 100)}') as jexl4, jexl(temperature, st, 'expr'='(x, y) -> {x + y}') as jexl5, jexl(temperature, st, str, 'expr'='(x, y, z) -> {x + y + z}') as jexl6 from root.ln.wf01.wt01;``` -``` ## CONDITIONAL EXPRESSION diff --git a/src/UserGuide/dev-1.3/SQL-Manual/Function-and-Expression.md b/src/UserGuide/dev-1.3/SQL-Manual/Function-and-Expression.md index cf94a7602..27bb92371 100644 --- a/src/UserGuide/dev-1.3/SQL-Manual/Function-and-Expression.md +++ b/src/UserGuide/dev-1.3/SQL-Manual/Function-and-Expression.md @@ -2770,105 +2770,6 @@ Output series: +-----------------------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+ ``` - - -## Lambda Expression - -### JEXL Function - -Java Expression Language (JEXL) is an expression language engine. We use JEXL to extend UDFs, which are implemented on the command line with simple lambda expressions. See the link for [operators supported in jexl lambda expressions](https://commons.apache.org/proper/commons-jexl/apidocs/org/apache/commons/jexl3/package-summary.html#customization). - -| Function Name | Allowed Input Series Data Types | Required Attributes | Output Series Data Type | Series Data Type Description | -|----------|--------------------------------|---------------------------------------|------------|--------------------------------------------------| -| JEXL | INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | `expr` is a lambda expression that supports standard one or multi arguments in the form `x -> {...}` or `(x, y, z) -> {...}`, e.g. ` x -> {x * 2}`, `(x, y, z) -> {x + y * z}` | INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | Returns the input time series transformed by a lambda expression | - -##### Demonstrate -Example data: `root.ln.wf01.wt01.temperature`, `root.ln.wf01.wt01.st`, `root.ln.wf01.wt01.str` a total of `11` data. - -``` -IoTDB> select * from root.ln.wf01.wt01; -+-----------------------------+---------------------+--------------------+-----------------------------+ -| Time|root.ln.wf01.wt01.str|root.ln.wf01.wt01.st|root.ln.wf01.wt01.temperature| -+-----------------------------+---------------------+--------------------+-----------------------------+ -|1970-01-01T08:00:00.000+08:00| str| 10.0| 0.0| -|1970-01-01T08:00:00.001+08:00| str| 20.0| 1.0| -|1970-01-01T08:00:00.002+08:00| str| 30.0| 2.0| -|1970-01-01T08:00:00.003+08:00| str| 40.0| 3.0| -|1970-01-01T08:00:00.004+08:00| str| 50.0| 4.0| -|1970-01-01T08:00:00.005+08:00| str| 60.0| 5.0| -|1970-01-01T08:00:00.006+08:00| str| 70.0| 6.0| -|1970-01-01T08:00:00.007+08:00| str| 80.0| 7.0| -|1970-01-01T08:00:00.008+08:00| str| 90.0| 8.0| -|1970-01-01T08:00:00.009+08:00| str| 100.0| 9.0| -|1970-01-01T08:00:00.010+08:00| str| 110.0| 10.0| -+-----------------------------+---------------------+--------------------+-----------------------------+ -``` -Sql: -```sql -select jexl(temperature, 'expr'='x -> {x + x}') as jexl1, jexl(temperature, 'expr'='x -> {x * 3}') as jexl2, jexl(temperature, 'expr'='x -> {x * x}') as jexl3, jexl(temperature, 'expr'='x -> {multiply(x, 100)}') as jexl4, jexl(temperature, st, 'expr'='(x, y) -> {x + y}') as jexl5, jexl(temperature, st, str, 'expr'='(x, y, z) -> {x + y + z}') as jexl6 from root.ln.wf01.wt01;``` -``` - -Result: -``` -+-----------------------------+-----+-----+-----+------+-----+--------+ -| Time|jexl1|jexl2|jexl3| jexl4|jexl5| jexl6| -+-----------------------------+-----+-----+-----+------+-----+--------+ -|1970-01-01T08:00:00.000+08:00| 0.0| 0.0| 0.0| 0.0| 10.0| 10.0str| -|1970-01-01T08:00:00.001+08:00| 2.0| 3.0| 1.0| 100.0| 21.0| 21.0str| -|1970-01-01T08:00:00.002+08:00| 4.0| 6.0| 4.0| 200.0| 32.0| 32.0str| -|1970-01-01T08:00:00.003+08:00| 6.0| 9.0| 9.0| 300.0| 43.0| 43.0str| -|1970-01-01T08:00:00.004+08:00| 8.0| 12.0| 16.0| 400.0| 54.0| 54.0str| -|1970-01-01T08:00:00.005+08:00| 10.0| 15.0| 25.0| 500.0| 65.0| 65.0str| -|1970-01-01T08:00:00.006+08:00| 12.0| 18.0| 36.0| 600.0| 76.0| 76.0str| -|1970-01-01T08:00:00.007+08:00| 14.0| 21.0| 49.0| 700.0| 87.0| 87.0str| -|1970-01-01T08:00:00.008+08:00| 16.0| 24.0| 64.0| 800.0| 98.0| 98.0str| -|1970-01-01T08:00:00.009+08:00| 18.0| 27.0| 81.0| 900.0|109.0|109.0str| -|1970-01-01T08:00:00.010+08:00| 20.0| 30.0|100.0|1000.0|120.0|120.0str| -+-----------------------------+-----+-----+-----+------+-----+--------+ -Total line number = 11 -It costs 0.118s -``` - - - ## Conditional Expressions diff --git a/src/UserGuide/dev-1.3/SQL-Manual/Operator-and-Expression.md b/src/UserGuide/dev-1.3/SQL-Manual/Operator-and-Expression.md index 6c63b7ad7..b9bafd984 100644 --- a/src/UserGuide/dev-1.3/SQL-Manual/Operator-and-Expression.md +++ b/src/UserGuide/dev-1.3/SQL-Manual/Operator-and-Expression.md @@ -253,13 +253,6 @@ For details and examples, see the document [Sample Functions](../SQL-Manual/Func For details and examples, see the document [Time-Series](./Function-and-Expression.md#time-series-processing). -## LAMBDA EXPRESSION - -| Function Name | Allowed Input Series Data Types | Required Attributes | Output Series Data Type | Series Data Type Description | -| ------------- | ----------------------------------------------- | ------------------------------------------------------------ | ----------------------------------------------- | ------------------------------------------------------------ | -| JEXL | INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | `expr` is a lambda expression that supports standard one or multi arguments in the form `x -> {...}` or `(x, y, z) -> {...}`, e.g. `x -> {x * 2}`, `(x, y, z) -> {x + y * z}` | INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | Returns the input time series transformed by a lambda expression | - -For details and examples, see the document [Lambda](./Function-and-Expression.md#lambda-expression). ## CONDITIONAL EXPRESSION diff --git a/src/UserGuide/dev-1.3/SQL-Manual/SQL-Manual.md b/src/UserGuide/dev-1.3/SQL-Manual/SQL-Manual.md index 740e604c6..42f85bab4 100644 --- a/src/UserGuide/dev-1.3/SQL-Manual/SQL-Manual.md +++ b/src/UserGuide/dev-1.3/SQL-Manual/SQL-Manual.md @@ -1338,14 +1338,6 @@ select representation(s0,"tb"="3","vb"="2") from root.test.d0 select rm(s0, s1,"tb"="3","vb"="2") from root.test.d0 ``` -## LAMBDA EXPRESSION - -For details and examples, see the document [Lambda](./UDF-Libraries.md#lambda-expression). - -```sql -select jexl(temperature, 'expr'='x -> {x + x}') as jexl1, jexl(temperature, 'expr'='x -> {x * 3}') as jexl2, jexl(temperature, 'expr'='x -> {x * x}') as jexl3, jexl(temperature, 'expr'='x -> {multiply(x, 100)}') as jexl4, jexl(temperature, st, 'expr'='(x, y) -> {x + y}') as jexl5, jexl(temperature, st, str, 'expr'='(x, y, z) -> {x + y + z}') as jexl6 from root.ln.wf01.wt01;``` -``` - ## CONDITIONAL EXPRESSION For details and examples, see the document [Conditional Expressions](./UDF-Libraries.md#conditional-expressions). diff --git a/src/UserGuide/latest/SQL-Manual/Function-and-Expression.md b/src/UserGuide/latest/SQL-Manual/Function-and-Expression.md index 328b2a66d..160bb069d 100644 --- a/src/UserGuide/latest/SQL-Manual/Function-and-Expression.md +++ b/src/UserGuide/latest/SQL-Manual/Function-and-Expression.md @@ -2583,109 +2583,9 @@ Output series: +-----------------------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+ ``` - - -## 13. Lambda Expression - -### 13.1 JEXL Function - -Java Expression Language (JEXL) is an expression language engine. We use JEXL to extend UDFs, which are implemented on the command line with simple lambda expressions. See the link for [operators supported in jexl lambda expressions](https://commons.apache.org/proper/commons-jexl/apidocs/org/apache/commons/jexl3/package-summary.html#customization). - -| Function Name | Allowed Input Series Data Types | Required Attributes | Output Series Data Type | Series Data Type Description | -|----------|--------------------------------|---------------------------------------|------------|--------------------------------------------------| -| JEXL | INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | `expr` is a lambda expression that supports standard one or multi arguments in the form `x -> {...}` or `(x, y, z) -> {...}`, e.g. ` x -> {x * 2}`, `(x, y, z) -> {x + y * z}` | INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | Returns the input time series transformed by a lambda expression | - -##### Demonstrate -Example data: `root.ln.wf01.wt01.temperature`, `root.ln.wf01.wt01.st`, `root.ln.wf01.wt01.str` a total of `11` data. - -``` -IoTDB> select * from root.ln.wf01.wt01; -+-----------------------------+---------------------+--------------------+-----------------------------+ -| Time|root.ln.wf01.wt01.str|root.ln.wf01.wt01.st|root.ln.wf01.wt01.temperature| -+-----------------------------+---------------------+--------------------+-----------------------------+ -|1970-01-01T08:00:00.000+08:00| str| 10.0| 0.0| -|1970-01-01T08:00:00.001+08:00| str| 20.0| 1.0| -|1970-01-01T08:00:00.002+08:00| str| 30.0| 2.0| -|1970-01-01T08:00:00.003+08:00| str| 40.0| 3.0| -|1970-01-01T08:00:00.004+08:00| str| 50.0| 4.0| -|1970-01-01T08:00:00.005+08:00| str| 60.0| 5.0| -|1970-01-01T08:00:00.006+08:00| str| 70.0| 6.0| -|1970-01-01T08:00:00.007+08:00| str| 80.0| 7.0| -|1970-01-01T08:00:00.008+08:00| str| 90.0| 8.0| -|1970-01-01T08:00:00.009+08:00| str| 100.0| 9.0| -|1970-01-01T08:00:00.010+08:00| str| 110.0| 10.0| -+-----------------------------+---------------------+--------------------+-----------------------------+ -``` -Sql: -```sql -select jexl(temperature, 'expr'='x -> {x + x}') as jexl1, jexl(temperature, 'expr'='x -> {x * 3}') as jexl2, jexl(temperature, 'expr'='x -> {x * x}') as jexl3, jexl(temperature, 'expr'='x -> {multiply(x, 100)}') as jexl4, jexl(temperature, st, 'expr'='(x, y) -> {x + y}') as jexl5, jexl(temperature, st, str, 'expr'='(x, y, z) -> {x + y + z}') as jexl6 from root.ln.wf01.wt01;``` -``` - -Result: -``` -+-----------------------------+-----+-----+-----+------+-----+--------+ -| Time|jexl1|jexl2|jexl3| jexl4|jexl5| jexl6| -+-----------------------------+-----+-----+-----+------+-----+--------+ -|1970-01-01T08:00:00.000+08:00| 0.0| 0.0| 0.0| 0.0| 10.0| 10.0str| -|1970-01-01T08:00:00.001+08:00| 2.0| 3.0| 1.0| 100.0| 21.0| 21.0str| -|1970-01-01T08:00:00.002+08:00| 4.0| 6.0| 4.0| 200.0| 32.0| 32.0str| -|1970-01-01T08:00:00.003+08:00| 6.0| 9.0| 9.0| 300.0| 43.0| 43.0str| -|1970-01-01T08:00:00.004+08:00| 8.0| 12.0| 16.0| 400.0| 54.0| 54.0str| -|1970-01-01T08:00:00.005+08:00| 10.0| 15.0| 25.0| 500.0| 65.0| 65.0str| -|1970-01-01T08:00:00.006+08:00| 12.0| 18.0| 36.0| 600.0| 76.0| 76.0str| -|1970-01-01T08:00:00.007+08:00| 14.0| 21.0| 49.0| 700.0| 87.0| 87.0str| -|1970-01-01T08:00:00.008+08:00| 16.0| 24.0| 64.0| 800.0| 98.0| 98.0str| -|1970-01-01T08:00:00.009+08:00| 18.0| 27.0| 81.0| 900.0|109.0|109.0str| -|1970-01-01T08:00:00.010+08:00| 20.0| 30.0|100.0|1000.0|120.0|120.0str| -+-----------------------------+-----+-----+-----+------+-----+--------+ -Total line number = 11 -It costs 0.118s -``` - - - - -## 14. Conditional Expressions +## 13. Conditional Expressions -### 14.1 CASE +### 13.1 CASE The CASE expression is a kind of conditional expression that can be used to return different values based on specific conditions, similar to the if-else statements in other languages. diff --git a/src/UserGuide/latest/SQL-Manual/Operator-and-Expression.md b/src/UserGuide/latest/SQL-Manual/Operator-and-Expression.md index ee905b41f..d484ec327 100644 --- a/src/UserGuide/latest/SQL-Manual/Operator-and-Expression.md +++ b/src/UserGuide/latest/SQL-Manual/Operator-and-Expression.md @@ -25,7 +25,7 @@ This chapter describes the operators and functions supported by IoTDB. IoTDB pro A list of all available functions, both built-in and custom, can be displayed with `SHOW FUNCTIONS` command. -See the documentation [Select-Expression](../SQL-Manual/Function-and-Expression.md#selector-functions) for the behavior of operators and functions in SQL. +See the documentation [Select-Expression](../SQL-Manual/Function-and-Expression.md#_8-selector-functions) for the behavior of operators and functions in SQL. ## 1. OPERATORS @@ -41,7 +41,7 @@ See the documentation [Select-Expression](../SQL-Manual/Function-and-Expression. | `+` | addition | | `-` | subtraction | -For details and examples, see the document [Arithmetic Operators and Functions](../SQL-Manual/Function-and-Expression.md#arithmetic-functions). +For details and examples, see the document [Arithmetic Operators and Functions](../SQL-Manual/Function-and-Expression.md#_1-1-arithmetic-operators). ### 1.2 Comparison Operators @@ -64,7 +64,7 @@ For details and examples, see the document [Arithmetic Operators and Functions]( | `IN` / `CONTAINS` | is a value in the specified list | | `NOT IN` / `NOT CONTAINS` | is not a value in the specified list | -For details and examples, see the document [Comparison Operators and Functions](../SQL-Manual/Function-and-Expression.md#comparison-operators-and-functions). +For details and examples, see the document [Comparison Operators and Functions](../SQL-Manual/Function-and-Expression.md#_2-comparison-operators-and-functions). ### 1.3 Logical Operators @@ -74,7 +74,7 @@ For details and examples, see the document [Comparison Operators and Functions]( | `AND` / `&` / `&&` | logical AND | | `OR`/ | / || | logical OR | -For details and examples, see the document [Logical Operators](../SQL-Manual/Function-and-Expression.md#logical-operators). +For details and examples, see the document [Logical Operators](../SQL-Manual/Function-and-Expression.md#_3-logical-operators). ### 1.4 Operator Precedence @@ -123,7 +123,7 @@ The built-in functions can be used in IoTDB without registration, and the functi | MAX_BY | MAX_BY(x, y) returns the value of x corresponding to the maximum value of the input y. MAX_BY(time, x) returns the timestamp when x is at its maximum value. | The first input x can be of any type, while the second input y must be of type INT32, INT64, FLOAT, DOUBLE, STRING, TIMESTAMP or DATE. | / | Consistent with the data type of the first input x. | | MIN_BY | MIN_BY(x, y) returns the value of x corresponding to the minimum value of the input y. MIN_BY(time, x) returns the timestamp when x is at its minimum value. | The first input x can be of any type, while the second input y must be of type INT32, INT64, FLOAT, DOUBLE, STRING, TIMESTAMP or DATE. | / | Consistent with the data type of the first input x. | -For details and examples, see the document [Aggregate Functions](../SQL-Manual/Function-and-Expression.md#aggregate-functions). +For details and examples, see the document [Aggregate Functions](../SQL-Manual/Function-and-Expression.md#_4-aggregate-functions). ### 2.2 Arithmetic Functions @@ -150,7 +150,7 @@ For details and examples, see the document [Aggregate Functions](../SQL-Manual/F | LOG10 | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE | / | Math#log10(double) | | SQRT | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE | / | Math#sqrt(double) | -For details and examples, see the document [Arithmetic Operators and Functions](../SQL-Manual/Function-and-Expression.md#arithmetic-operators-and-functions). +For details and examples, see the document [Arithmetic Operators and Functions](../SQL-Manual/Function-and-Expression.md#_1-arithmetic-operators-and-functionss). ### 2.3 Comparison Functions @@ -159,7 +159,7 @@ For details and examples, see the document [Arithmetic Operators and Functions]( | ON_OFF | INT32 / INT64 / FLOAT / DOUBLE | `threshold`: a double type variate | BOOLEAN | Return `ts_value >= threshold`. | | IN_RANGR | INT32 / INT64 / FLOAT / DOUBLE | `lower`: DOUBLE type `upper`: DOUBLE type | BOOLEAN | Return `ts_value >= lower && value <= upper`. | -For details and examples, see the document [Comparison Operators and Functions](../SQL-Manual/Function-and-Expression.md#comparison-operators-and-functions). +For details and examples, see the document [Comparison Operators and Functions](../SQL-Manual/Function-and-Expression.md#_2-comparison-operators-and-functions). ### 2.4 String Processing Functions @@ -179,7 +179,7 @@ For details and examples, see the document [Comparison Operators and Functions]( | TRIM | TEXT STRING | / | TEXT | Get the string whose value is same to input series, with all leading and trailing space removed. | | STRCMP | TEXT STRING | / | TEXT | Get the compare result of two input series. Returns `0` if series value are the same, a `negative integer` if value of series1 is smaller than series2,
a `positive integer` if value of series1 is more than series2. | -For details and examples, see the document [String Processing](../SQL-Manual/Function-and-Expression.md#string-processing). +For details and examples, see the document [String Processing](../SQL-Manual/Function-and-Expression.md#_5-string-processing). ### 2.5 Data Type Conversion Function @@ -187,7 +187,7 @@ For details and examples, see the document [String Processing](../SQL-Manual/Fun | ------------- | ------------------------------------------------------------ | ----------------------- | ------------------------------------------------------------ | | CAST | `type`: Output data type, INT32 / INT64 / FLOAT / DOUBLE / BOOLEAN / TEXT | determined by `type` | Convert the data to the type specified by the `type` parameter. | -For details and examples, see the document [Data Type Conversion Function](../SQL-Manual/Function-and-Expression.md#data-type-conversion-function). +For details and examples, see the document [Data Type Conversion Function](../SQL-Manual/Function-and-Expression.md#_6-data-type-conversion-function). ### 2.6 Constant Timeseries Generating Functions @@ -197,7 +197,7 @@ For details and examples, see the document [Data Type Conversion Function](../SQ | PI | None | DOUBLE | Data point value: a `double` value of `π`, the ratio of the circumference of a circle to its diameter, which is equals to `Math.PI` in the *Java Standard Library*. | | E | None | DOUBLE | Data point value: a `double` value of `e`, the base of the natural logarithms, which is equals to `Math.E` in the *Java Standard Library*. | -For details and examples, see the document [Constant Timeseries Generating Functions](../SQL-Manual/Function-and-Expression.md#constant-timeseries-generating-functions). +For details and examples, see the document [Constant Timeseries Generating Functions](../SQL-Manual/Function-and-Expression.md#_7-constant-timeseries-generating-functions). ### 2.7 Selector Functions @@ -206,7 +206,7 @@ For details and examples, see the document [Constant Timeseries Generating Funct | TOP_K | INT32 / INT64 / FLOAT / DOUBLE / TEXT / STRING / DATE / TIEMSTAMP | `k`: the maximum number of selected data points, must be greater than 0 and less than or equal to 1000 | Same type as the input series | Returns `k` data points with the largest values in a time series. | | BOTTOM_K | INT32 / INT64 / FLOAT / DOUBLE / TEXT / STRING / DATE / TIEMSTAMP | `k`: the maximum number of selected data points, must be greater than 0 and less than or equal to 1000 | Same type as the input series | Returns `k` data points with the smallest values in a time series. | -For details and examples, see the document [Selector Functions](../SQL-Manual/Function-and-Expression.md#selector-functions). +For details and examples, see the document [Selector Functions](../SQL-Manual/Function-and-Expression.md#_8-selector-functions). ### 2.8 Continuous Interval Functions @@ -217,7 +217,7 @@ For details and examples, see the document [Selector Functions](../SQL-Manual/Fu | ZERO_COUNT | INT32/ INT64/ FLOAT/ DOUBLE/ BOOLEAN | `min`:Optional with default value `1L` `max`:Optional with default value `Long.MAX_VALUE` | Long | Return intervals' start times and the number of data points in the interval in which the value is always 0(false). Data points number `n` satisfy `n >= min && n <= max` | | NON_ZERO_COUNT | INT32/ INT64/ FLOAT/ DOUBLE/ BOOLEAN | `min`:Optional with default value `1L` `max`:Optional with default value `Long.MAX_VALUE` | Long | Return intervals' start times and the number of data points in the interval in which the value is always not 0(false). Data points number `n` satisfy `n >= min && n <= max` | -For details and examples, see the document [Continuous Interval Functions](../SQL-Manual/Function-and-Expression.md#continuous-interval-functions). +For details and examples, see the document [Continuous Interval Functions](../SQL-Manual/Function-and-Expression.md#_9-continuous-interval-functions). ### 2.9 Variation Trend Calculation Functions @@ -230,7 +230,7 @@ For details and examples, see the document [Continuous Interval Functions](../SQ | NON_NEGATIVE_DERIVATIVE | INT32 / INT64 / FLOAT / DOUBLE | / | DOUBLE | Calculates the absolute value of the rate of change of a data point compared to the previous data point, the result is equals to NON_NEGATIVE_DIFFERENCE / TIME_DIFFERENCE. There is no corresponding output for the first data point. | | DIFF | INT32 / INT64 / FLOAT / DOUBLE | `ignoreNull`:optional,default is true. If is true, the previous data point is ignored when it is null and continues to find the first non-null value forwardly. If the value is false, previous data point is not ignored when it is null, the result is also null because null is used for subtraction | DOUBLE | Calculates the difference between the value of a data point and the value of the previous data point. There is no corresponding output for the first data point, so output is null | -For details and examples, see the document [Variation Trend Calculation Functions](../SQL-Manual/Function-and-Expression.md#variation-trend-calculation-functions). +For details and examples, see the document [Variation Trend Calculation Functions](../SQL-Manual/Function-and-Expression.md#_10-variation-trend-calculation-functions). ### 2.10 Sample Functions @@ -242,7 +242,7 @@ For details and examples, see the document [Variation Trend Calculation Function | EQUAL_SIZE_BUCKET_OUTLIER_SAMPLE | INT32 / INT64 / FLOAT / DOUBLE | The value range of `proportion` is `(0, 1]`, the default is `0.1`
The value of `type` is `avg` or `stendis` or `cos` or `prenextdis`, the default is `avg`
The value of `number` should be greater than 0, the default is `3` | INT32 / INT64 / FLOAT / DOUBLE | Returns outlier samples in equal buckets that match the sampling ratio and the number of samples in the bucket | | M4 | INT32 / INT64 / FLOAT / DOUBLE | Different attributes used by the size window and the time window. The size window uses attributes `windowSize` and `slidingStep`. The time window uses attributes `timeInterval`, `slidingStep`, `displayWindowBegin`, and `displayWindowEnd`. More details see below. | INT32 / INT64 / FLOAT / DOUBLE | Returns the `first, last, bottom, top` points in each sliding window. M4 sorts and deduplicates the aggregated points within the window before outputting them. | -For details and examples, see the document [Sample Functions](../SQL-Manual/Function-and-Expression.md#sample-functions). +For details and examples, see the document [Sample Functions](../SQL-Manual/Function-and-Expression.md#_11-sample-functions). ### 2.11 Change Points Function @@ -250,26 +250,18 @@ For details and examples, see the document [Sample Functions](../SQL-Manual/Func | ------------- | ------------------------------- | ------------------- | ----------------------------- | ----------------------------------------------------------- | | CHANGE_POINTS | INT32 / INT64 / FLOAT / DOUBLE | / | Same type as the input series | Remove consecutive identical values from an input sequence. | -For details and examples, see the document [Time-Series](../SQL-Manual/Function-and-Expression.md#time-series-processing). +For details and examples, see the document [Time-Series](../SQL-Manual/Function-and-Expression.md#_12-time-series-processing). -## 3. LAMBDA EXPRESSION - -| Function Name | Allowed Input Series Data Types | Required Attributes | Output Series Data Type | Series Data Type Description | -| ------------- | ----------------------------------------------- | ------------------------------------------------------------ | ----------------------------------------------- | ------------------------------------------------------------ | -| JEXL | INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | `expr` is a lambda expression that supports standard one or multi arguments in the form `x -> {...}` or `(x, y, z) -> {...}`, e.g. `x -> {x * 2}`, `(x, y, z) -> {x + y * z}` | INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | Returns the input time series transformed by a lambda expression | - -For details and examples, see the document [Lambda](../SQL-Manual/Function-and-Expression.md#lambda-expression). - -## 4. CONDITIONAL EXPRESSION +## 3. CONDITIONAL EXPRESSION | Expression Name | Description | | --------------- | -------------------- | | `CASE` | similar to "if else" | -For details and examples, see the document [Conditional Expressions](../SQL-Manual/Function-and-Expression.md#conditional-expressions). +For details and examples, see the document [Conditional Expressions](../SQL-Manual/Function-and-Expression.md#_13-conditional-expressions). -## 5. SELECT EXPRESSION +## 4. SELECT EXPRESSION The `SELECT` clause specifies the output of the query, consisting of several `selectExpr`. Each `selectExpr` defines one or more columns in the query result. @@ -285,7 +277,7 @@ The `SELECT` clause specifies the output of the query, consisting of several `se - Time series generation functions (including built-in functions and user-defined functions) - constant -### 5.1 Use Alias +### 4.1 Use Alias Since the unique data model of IoTDB, lots of additional information like device will be carried before each sensor. Sometimes, we want to query just one specific device, then these prefix information show frequently will be redundant in this situation, influencing the analysis of result set. At this time, we can use `AS` function provided by IoTDB, assign an alias to time series selected in query. @@ -302,11 +294,11 @@ The result set is: | ... | ... | ... | -### 5.2 Operator +### 4.2 Operator See this documentation for a list of operators supported in IoTDB. -### 5.3 Function +### 4.3 Function #### Aggregate Functions @@ -322,7 +314,7 @@ Aggregate functions are many-to-one functions. They perform aggregate calculatio > select a, count(a) from root.sg group by ([10,100),10ms) > ``` -For the aggregation functions supported by IoTDB, see the document [Aggregate Functions](../SQL-Manual/Function-and-Expression.md#aggregate-functions). +For the aggregation functions supported by IoTDB, see the document [Aggregate Functions](../SQL-Manual/Function-and-Expression.md#_4-aggregate-functions). #### Time Series Generation Function @@ -339,7 +331,7 @@ See this documentation for a list of built-in functions supported in IoTDB. IoTDB supports function extension through User Defined Function (click for [User-Defined Function](../User-Manual/Database-Programming.md#udtfuser-defined-timeseries-generating-function)) capability. -### 5.4 Nested Expressions +### 4.4 Nested Expressions IoTDB supports the calculation of arbitrary nested expressions. Since time series query and aggregation query can not be used in a query statement at the same time, we divide nested expressions into two types, which are nested expressions with time series query and nested expressions with aggregation query. diff --git a/src/UserGuide/latest/SQL-Manual/SQL-Manual_apache.md b/src/UserGuide/latest/SQL-Manual/SQL-Manual_apache.md index b27cc3551..74a43ee19 100644 --- a/src/UserGuide/latest/SQL-Manual/SQL-Manual_apache.md +++ b/src/UserGuide/latest/SQL-Manual/SQL-Manual_apache.md @@ -915,7 +915,7 @@ For more details, see document [Operator-and-Expression](./Operator-and-Expressi ### 9.1 Arithmetic Operators -For details and examples, see the document [Arithmetic Operators and Functions](./Operator-and-Expression.md#arithmetic-operators). +For details and examples, see the document [Arithmetic Operators and Functions](./Operator-and-Expression.md#_1-1-arithmetic-operators). ```sql select s1, - s1, s2, + s2, s1 + s2, s1 - s2, s1 * s2, s1 / s2, s1 % s2 from root.sg.d1 @@ -923,7 +923,7 @@ select s1, - s1, s2, + s2, s1 + s2, s1 - s2, s1 * s2, s1 / s2, s1 % s2 from root ### 9.2 Comparison Operators -For details and examples, see the document [Comparison Operators and Functions](./Operator-and-Expression.md#comparison-operators). +For details and examples, see the document [Comparison Operators and Functions](./Operator-and-Expression.md#_1-2-comparison-operators). ```sql # Basic comparison operators @@ -954,7 +954,7 @@ select a, a in (1, 2) from root.test; ### 9.3 Logical Operators -For details and examples, see the document [Logical Operators](./Operator-and-Expression.md#logical-operators). +For details and examples, see the document [Logical Operators](./Operator-and-Expression.md#_1-3-logical-operators). ```sql select a, b, a > 10, a <= b, !(a <= b), a > 10 && a > b from root.test; @@ -962,11 +962,11 @@ select a, b, a > 10, a <= b, !(a <= b), a > 10 && a > b from root.test; ## 10. BUILT-IN FUNCTIONS -For more details, see document [Operator-and-Expression](./Operator-and-Expression.md#built-in-functions). +For more details, see document [Operator-and-Expression](./Operator-and-Expression.md#_2-built-in-functions). ### 10.1 Aggregate Functions -For details and examples, see the document [Aggregate Functions](./Operator-and-Expression.md#aggregate-functions). +For details and examples, see the document [Aggregate Functions](./Operator-and-Expression.md#_2-1-aggregate-functions). ```sql select count(status) from root.ln.wf01.wt01; @@ -979,7 +979,7 @@ select time_duration(s1) from root.db.d1; ### 10.2 Arithmetic Functions -For details and examples, see the document [Arithmetic Operators and Functions](./Operator-and-Expression.md#arithmetic-functions). +For details and examples, see the document [Arithmetic Operators and Functions](./Operator-and-Expression.md#_2-2-arithmetic-functions). ```sql select s1, sin(s1), cos(s1), tan(s1) from root.sg1.d1 limit 5 offset 1000; @@ -988,7 +988,7 @@ select s4,round(s4),round(s4,2),round(s4,-1) from root.sg1.d1; ### 10.3 Comparison Functions -For details and examples, see the document [Comparison Operators and Functions](./Operator-and-Expression.md#comparison-functions). +For details and examples, see the document [Comparison Operators and Functions](./Operator-and-Expression.md#_2-3-comparison-functions). ```sql select ts, on_off(ts, 'threshold'='2') from root.test; @@ -997,7 +997,7 @@ select ts, in_range(ts, 'lower'='2', 'upper'='3.1') from root.test; ### 10.4 String Processing Functions -For details and examples, see the document [String Processing](./Operator-and-Expression.md#string-processing-functions). +For details and examples, see the document [String Processing](./Operator-and-Expression.md#_2-4-string-processing-functions). ```sql select s1, string_contains(s1, 's'='warn') from root.sg1.d4; @@ -1025,7 +1025,7 @@ select regexsplit(s1, "regex"=",", "index"="3") from root.test.d1 ### 10.5 Data Type Conversion Function -For details and examples, see the document [Data Type Conversion Function](./Operator-and-Expression.md#data-type-conversion-function). +For details and examples, see the document [Data Type Conversion Function](./Operator-and-Expression.md#_2-5-data-type-conversion-function). ```sql SELECT cast(s1 as INT32) from root.sg @@ -1033,7 +1033,7 @@ SELECT cast(s1 as INT32) from root.sg ### 10.6 Constant Timeseries Generating Functions -For details and examples, see the document [Constant Timeseries Generating Functions](./Operator-and-Expression.md#constant-timeseries-generating-functions). +For details and examples, see the document [Constant Timeseries Generating Functions](./Operator-and-Expression.md#_2-6-constant-timeseries-generating-functions). ```sql select s1, s2, const(s1, 'value'='1024', 'type'='INT64'), pi(s2), e(s1, s2) from root.sg1.d1; @@ -1041,7 +1041,7 @@ select s1, s2, const(s1, 'value'='1024', 'type'='INT64'), pi(s2), e(s1, s2) from ### 10.7 Selector Functions -For details and examples, see the document [Selector Functions](./Operator-and-Expression.md#selector-functions). +For details and examples, see the document [Selector Functions](./Operator-and-Expression.md#_2-7-selector-functions). ```sql select s1, top_k(s1, 'k'='2'), bottom_k(s1, 'k'='2') from root.sg1.d2 where time > 2020-12-10T20:36:15.530+08:00; @@ -1049,7 +1049,7 @@ select s1, top_k(s1, 'k'='2'), bottom_k(s1, 'k'='2') from root.sg1.d2 where time ### 10.8 Continuous Interval Functions -For details and examples, see the document [Continuous Interval Functions](./Operator-and-Expression.md#continuous-interval-functions). +For details and examples, see the document [Continuous Interval Functions](./Operator-and-Expression.md#_2-8-continuous-interval-functions). ```sql select s1, zero_count(s1), non_zero_count(s2), zero_duration(s3), non_zero_duration(s4) from root.sg.d2; @@ -1057,7 +1057,7 @@ select s1, zero_count(s1), non_zero_count(s2), zero_duration(s3), non_zero_durat ### 10.9 Variation Trend Calculation Functions -For details and examples, see the document [Variation Trend Calculation Functions](./Operator-and-Expression.md#variation-trend-calculation-functions). +For details and examples, see the document [Variation Trend Calculation Functions](./Operator-and-Expression.md#_2-9-variation-trend-calculation-functions). ```sql select s1, time_difference(s1), difference(s1), non_negative_difference(s1), derivative(s1), non_negative_derivative(s1) from root.sg1.d1 limit 5 offset 1000; @@ -1068,7 +1068,7 @@ SELECT DIFF(s1, 'ignoreNull'='false'), DIFF(s2, 'ignoreNull'='false') from root. ### 10.10 Sample Functions -For details and examples, see the document [Sample Functions](./Operator-and-Expression.md#sample-functions). +For details and examples, see the document [Sample Functions](./Operator-and-Expression.md#_2-10-sample-functions). ```sql select equal_size_bucket_random_sample(temperature,'proportion'='0.1') as random_sample from root.ln.wf01.wt01; @@ -1082,7 +1082,7 @@ select M4(s1,'windowSize'='10') from root.vehicle.d1 ### 10.11 Change Points Function -For details and examples, see the document [Time-Series](./Operator-and-Expression.md#change-points-function). +For details and examples, see the document [Time-Series](./Operator-and-Expression.md#_2-11-change-points-function). ```sql select change_points(s1), change_points(s2), change_points(s3), change_points(s4), change_points(s5), change_points(s6) from root.testChangePoints.d1 @@ -1338,15 +1338,7 @@ select representation(s0,"tb"="3","vb"="2") from root.test.d0 select rm(s0, s1,"tb"="3","vb"="2") from root.test.d0 ``` -## 12. LAMBDA EXPRESSION - -For details and examples, see the document [Lambda](../SQL-Manual/UDF-Libraries.md#lambda-expression). - -```sql -select jexl(temperature, 'expr'='x -> {x + x}') as jexl1, jexl(temperature, 'expr'='x -> {x * 3}') as jexl2, jexl(temperature, 'expr'='x -> {x * x}') as jexl3, jexl(temperature, 'expr'='x -> {multiply(x, 100)}') as jexl4, jexl(temperature, st, 'expr'='(x, y) -> {x + y}') as jexl5, jexl(temperature, st, str, 'expr'='(x, y, z) -> {x + y + z}') as jexl6 from root.ln.wf01.wt01;``` -``` - -## 13. CONDITIONAL EXPRESSION +## 12. CONDITIONAL EXPRESSION For details and examples, see the document [Conditional Expressions](../SQL-Manual/UDF-Libraries.md#conditional-expressions). @@ -1384,11 +1376,11 @@ end as `result` from root.test4 ``` -## 14. TRIGGER +## 13. TRIGGER -For more details, see document [Database-Programming](../User-Manual/Database-Programming.md). +For more details, see document [TRIGGER](../User-Manual/Trigger.md). -### 14.1 Create Trigger +### 13.1 Create Trigger ```sql // Create Trigger @@ -1421,7 +1413,7 @@ triggerAttribute ; ``` -### 14.2 Drop Trigger +### 13.2 Drop Trigger ```sql // Drop Trigger @@ -1430,15 +1422,15 @@ dropTrigger ; ``` -### 14.3 Show Trigger +### 13.3 Show Trigger ```sql SHOW TRIGGERS ``` -## 15. CONTINUOUS QUERY (CQ) +## 14. CONTINUOUS QUERY (CQ) -For more details, see document [Operator-and-Expression](./Operator-and-Expression.md). +For more details, see document [CONTINUOUS QUERY](../User-Manual/Database-Programming.md). ```sql CREATE (CONTINUOUS QUERY | CQ) @@ -1461,7 +1453,7 @@ BEGIN END ``` -### 15.1 Configuring execution intervals +### 14.1 Configuring execution intervals ```sql CREATE CONTINUOUS QUERY cq1 @@ -1474,7 +1466,7 @@ SELECT max_value(temperature) END ``` -### 15.2 Configuring time range for resampling +### 14.2 Configuring time range for resampling ```sql CREATE CONTINUOUS QUERY cq2 @@ -1487,7 +1479,7 @@ BEGIN END ``` -### 15.3 Configuring execution intervals and CQ time ranges +### 14.3 Configuring execution intervals and CQ time ranges ```sql CREATE CONTINUOUS QUERY cq3 @@ -1501,7 +1493,7 @@ BEGIN END ``` -### 15.4 Configuring end_time_offset for CQ time range +### 14.4 Configuring end_time_offset for CQ time range ```sql CREATE CONTINUOUS QUERY cq4 @@ -1515,7 +1507,7 @@ BEGIN END ``` -### 15.5 CQ without group by clause +### 14.5 CQ without group by clause ```sql CREATE CONTINUOUS QUERY cq5 @@ -1528,7 +1520,7 @@ BEGIN END ``` -### 15.6 CQ Management +### 14.6 CQ Management #### Listing continuous queries @@ -1546,23 +1538,23 @@ DROP (CONTINUOUS QUERY | CQ) CQs can't be altered once they're created. To change a CQ, you must `DROP` and re`CREATE` it with the updated settings. -## 16. USER-DEFINED FUNCTION (UDF) +## 15. USER-DEFINED FUNCTION (UDF) -For more details, see document [Operator-and-Expression](../SQL-Manual/UDF-Libraries.md). +For more details, see document [UDF Libraries](../SQL-Manual/UDF-Libraries.md). -### 16.1 UDF Registration +### 15.1 UDF Registration ```sql CREATE FUNCTION AS (USING URI URI-STRING)? ``` -### 16.2 UDF Deregistration +### 15.2 UDF Deregistration ```sql DROP FUNCTION ``` -### 16.3 UDF Queries +### 15.3 UDF Queries ```sql SELECT example(*) from root.sg.d1 @@ -1578,17 +1570,17 @@ SELECT s1 * example(* / s1 + s2) FROM root.sg.d1; SELECT s1, s2, s1 + example(s1, s2), s1 - example(s1 + example(s1, s2) / s2) FROM root.sg.d1; ``` -### 16.4 Show All Registered UDFs +### 15.4 Show All Registered UDFs ```sql SHOW FUNCTIONS ``` -## 17. ADMINISTRATION MANAGEMENT +## 16. ADMINISTRATION MANAGEMENT -For more details, see document [Operator-and-Expression](./Operator-and-Expression.md). +For more details, see document [Authority Management](../User-Manual/Authority-Management_apache.md). -### 17.1 SQL Statements +### 16.1 SQL Statements - Create user (Requires MANAGE_USER permission) @@ -1679,7 +1671,7 @@ ALTER USER SET PASSWORD ; eg: ALTER USER tempuser SET PASSWORD 'newpwd'; ``` -### 17.2 Authorization and Deauthorization +### 16.2 Authorization and Deauthorization ```sql diff --git a/src/UserGuide/latest/SQL-Manual/SQL-Manual_timecho.md b/src/UserGuide/latest/SQL-Manual/SQL-Manual_timecho.md index 07363f7c6..5907c4b99 100644 --- a/src/UserGuide/latest/SQL-Manual/SQL-Manual_timecho.md +++ b/src/UserGuide/latest/SQL-Manual/SQL-Manual_timecho.md @@ -836,7 +836,7 @@ For more details, see document [Operator-and-Expression](./Operator-and-Expressi ### 8.1 Arithmetic Operators -For details and examples, see the document [Arithmetic Operators and Functions](./Operator-and-Expression.md#arithmetic-operators). +For details and examples, see the document [Arithmetic Operators and Functions](./Operator-and-Expression.md#_1-1-arithmetic-operators). ```sql select s1, - s1, s2, + s2, s1 + s2, s1 - s2, s1 * s2, s1 / s2, s1 % s2 from root.sg.d1 @@ -844,7 +844,7 @@ select s1, - s1, s2, + s2, s1 + s2, s1 - s2, s1 * s2, s1 / s2, s1 % s2 from root ### 8.2 Comparison Operators -For details and examples, see the document [Comparison Operators and Functions](./Operator-and-Expression.md#comparison-operators). +For details and examples, see the document [Comparison Operators and Functions](./Operator-and-Expression.md#_1-2-comparison-operators). ```sql # Basic comparison operators @@ -875,7 +875,7 @@ select a, a in (1, 2) from root.test; ### 8.3 Logical Operators -For details and examples, see the document [Logical Operators](./Operator-and-Expression.md#logical-operators). +For details and examples, see the document [Logical Operators](./Operator-and-Expression.md#_1-3-logical-operators). ```sql select a, b, a > 10, a <= b, !(a <= b), a > 10 && a > b from root.test; @@ -883,11 +883,11 @@ select a, b, a > 10, a <= b, !(a <= b), a > 10 && a > b from root.test; ## 9. BUILT-IN FUNCTIONS -For more details, see document [Operator-and-Expression](./Operator-and-Expression.md#built-in-functions). +For more details, see document [Operator-and-Expression](./Operator-and-Expression.md#_2-built-in-functions). ### 9.1 Aggregate Functions -For details and examples, see the document [Aggregate Functions](./Operator-and-Expression.md#aggregate-functions). +For details and examples, see the document [Aggregate Functions](./Operator-and-Expression.md#_2-1-aggregate-functions). ```sql select count(status) from root.ln.wf01.wt01; @@ -900,7 +900,7 @@ select time_duration(s1) from root.db.d1; ### 9.2 Arithmetic Functions -For details and examples, see the document [Arithmetic Operators and Functions](./Operator-and-Expression.md#arithmetic-functions). +For details and examples, see the document [Arithmetic Operators and Functions](./Operator-and-Expression.md#_2-2-arithmetic-functions). ```sql select s1, sin(s1), cos(s1), tan(s1) from root.sg1.d1 limit 5 offset 1000; @@ -909,7 +909,7 @@ select s4,round(s4),round(s4,2),round(s4,-1) from root.sg1.d1; ### 9.3 Comparison Functions -For details and examples, see the document [Comparison Operators and Functions](./Operator-and-Expression.md#comparison-functions). +For details and examples, see the document [Comparison Operators and Functions](./Operator-and-Expression.md#_2-3-comparison-functions). ```sql select ts, on_off(ts, 'threshold'='2') from root.test; @@ -918,7 +918,7 @@ select ts, in_range(ts, 'lower'='2', 'upper'='3.1') from root.test; ### 9.4 String Processing Functions -For details and examples, see the document [String Processing](./Operator-and-Expression.md#string-processing-functions). +For details and examples, see the document [String Processing](./Operator-and-Expression.md#_2-4-string-processing-functions). ```sql select s1, string_contains(s1, 's'='warn') from root.sg1.d4; @@ -946,7 +946,7 @@ select regexsplit(s1, "regex"=",", "index"="3") from root.test.d1 ### 9.5 Data Type Conversion Function -For details and examples, see the document [Data Type Conversion Function](./Operator-and-Expression.md#data-type-conversion-function). +For details and examples, see the document [Data Type Conversion Function](./Operator-and-Expression.md#_2-5-data-type-conversion-function). ```sql SELECT cast(s1 as INT32) from root.sg @@ -954,7 +954,7 @@ SELECT cast(s1 as INT32) from root.sg ### 9.6 Constant Timeseries Generating Functions -For details and examples, see the document [Constant Timeseries Generating Functions](./Operator-and-Expression.md#constant-timeseries-generating-functions). +For details and examples, see the document [Constant Timeseries Generating Functions](./Operator-and-Expression.md#_2-6-constant-timeseries-generating-functions). ```sql select s1, s2, const(s1, 'value'='1024', 'type'='INT64'), pi(s2), e(s1, s2) from root.sg1.d1; @@ -962,7 +962,7 @@ select s1, s2, const(s1, 'value'='1024', 'type'='INT64'), pi(s2), e(s1, s2) from ### 9.7 Selector Functions -For details and examples, see the document [Selector Functions](./Operator-and-Expression.md#selector-functions). +For details and examples, see the document [Selector Functions](./Operator-and-Expression.md#_2-7-selector-functions). ```sql select s1, top_k(s1, 'k'='2'), bottom_k(s1, 'k'='2') from root.sg1.d2 where time > 2020-12-10T20:36:15.530+08:00; @@ -970,7 +970,7 @@ select s1, top_k(s1, 'k'='2'), bottom_k(s1, 'k'='2') from root.sg1.d2 where time ### 9.8 Continuous Interval Functions -For details and examples, see the document [Continuous Interval Functions](./Operator-and-Expression.md#continuous-interval-functions). +For details and examples, see the document [Continuous Interval Functions](./Operator-and-Expression.md#_2-8-continuous-interval-functions). ```sql select s1, zero_count(s1), non_zero_count(s2), zero_duration(s3), non_zero_duration(s4) from root.sg.d2; @@ -978,7 +978,7 @@ select s1, zero_count(s1), non_zero_count(s2), zero_duration(s3), non_zero_durat ### 9.9 Variation Trend Calculation Functions -For details and examples, see the document [Variation Trend Calculation Functions](./Operator-and-Expression.md#variation-trend-calculation-functions). +For details and examples, see the document [Variation Trend Calculation Functions](./Operator-and-Expression.md#_2-9-variation-trend-calculation-functions). ```sql select s1, time_difference(s1), difference(s1), non_negative_difference(s1), derivative(s1), non_negative_derivative(s1) from root.sg1.d1 limit 5 offset 1000; @@ -989,7 +989,7 @@ SELECT DIFF(s1, 'ignoreNull'='false'), DIFF(s2, 'ignoreNull'='false') from root. ### 9.10 Sample Functions -For details and examples, see the document [Sample Functions](./Operator-and-Expression.md#sample-functions). +For details and examples, see the document [Sample Functions](./Operator-and-Expression.md#_2-10-sample-functions). ```sql select equal_size_bucket_random_sample(temperature,'proportion'='0.1') as random_sample from root.ln.wf01.wt01; @@ -1003,7 +1003,7 @@ select M4(s1,'windowSize'='10') from root.vehicle.d1 ### 9.11 Change Points Function -For details and examples, see the document [Time-Series](./Operator-and-Expression.md#change-points-function). +For details and examples, see the document [Time-Series](./Operator-and-Expression.md#_2-11-change-points-function). ```sql select change_points(s1), change_points(s2), change_points(s3), change_points(s4), change_points(s5), change_points(s6) from root.testChangePoints.d1 @@ -1259,15 +1259,8 @@ select representation(s0,"tb"="3","vb"="2") from root.test.d0 select rm(s0, s1,"tb"="3","vb"="2") from root.test.d0 ``` -## 11. LAMBDA EXPRESSION -For details and examples, see the document [Lambda](../SQL-Manual/UDF-Libraries.md#lambda-expression). - -```sql -select jexl(temperature, 'expr'='x -> {x + x}') as jexl1, jexl(temperature, 'expr'='x -> {x * 3}') as jexl2, jexl(temperature, 'expr'='x -> {x * x}') as jexl3, jexl(temperature, 'expr'='x -> {multiply(x, 100)}') as jexl4, jexl(temperature, st, 'expr'='(x, y) -> {x + y}') as jexl5, jexl(temperature, st, str, 'expr'='(x, y, z) -> {x + y + z}') as jexl6 from root.ln.wf01.wt01;``` -``` - -## 12. CONDITIONAL EXPRESSION +## 11. CONDITIONAL EXPRESSION For details and examples, see the document [Conditional Expressions](../SQL-Manual/UDF-Libraries.md#conditional-expressions). @@ -1305,11 +1298,11 @@ end as `result` from root.test4 ``` -## 13. TRIGGER +## 12. TRIGGER -For more details, see document [Database-Programming](../User-Manual/Database-Programming.md). +For more details, see document [TRIGGER](../User-Manual/Trigger.md). -### 13.1 Create Trigger +### 12.1 Create Trigger ```sql // Create Trigger @@ -1342,7 +1335,7 @@ triggerAttribute ; ``` -### 13.2 Drop Trigger +### 12.2 Drop Trigger ```sql // Drop Trigger @@ -1351,15 +1344,15 @@ dropTrigger ; ``` -### 13.3 Show Trigger +### 12.3 Show Trigger ```sql SHOW TRIGGERS ``` -## 14. CONTINUOUS QUERY (CQ) +## 13. CONTINUOUS QUERY (CQ) -For more details, see document [Operator-and-Expression](./Operator-and-Expression.md). +For more details, see document [CONTINUOUS QUERY](../User-Manual/Database-Programming.md). ```sql CREATE (CONTINUOUS QUERY | CQ) @@ -1382,7 +1375,7 @@ BEGIN END ``` -### 14.1 Configuring execution intervals +### 13.1 Configuring execution intervals ```sql CREATE CONTINUOUS QUERY cq1 @@ -1395,7 +1388,7 @@ SELECT max_value(temperature) END ``` -### 14.2 Configuring time range for resampling +### 13.2 Configuring time range for resampling ```sql CREATE CONTINUOUS QUERY cq2 @@ -1408,7 +1401,7 @@ BEGIN END ``` -### 14.3 Configuring execution intervals and CQ time ranges +### 13.3 Configuring execution intervals and CQ time ranges ```sql CREATE CONTINUOUS QUERY cq3 @@ -1422,7 +1415,7 @@ BEGIN END ``` -### 14.4 Configuring end_time_offset for CQ time range +### 13.4 Configuring end_time_offset for CQ time range ```sql CREATE CONTINUOUS QUERY cq4 @@ -1436,7 +1429,7 @@ BEGIN END ``` -### 14.5 CQ without group by clause +### 13.5 CQ without group by clause ```sql CREATE CONTINUOUS QUERY cq5 @@ -1449,7 +1442,7 @@ BEGIN END ``` -### 14.6 CQ Management +### 13.6 CQ Management #### Listing continuous queries @@ -1467,23 +1460,23 @@ DROP (CONTINUOUS QUERY | CQ) CQs can't be altered once they're created. To change a CQ, you must `DROP` and re`CREATE` it with the updated settings. -## 15. USER-DEFINED FUNCTION (UDF) +## 14. USER-DEFINED FUNCTION (UDF) -For more details, see document [Operator-and-Expression](../SQL-Manual/UDF-Libraries.md). +For more details, see document [UDF Libraries](../SQL-Manual/UDF-Libraries.md). -### 15.1 UDF Registration +### 14.1 UDF Registration ```sql CREATE FUNCTION AS (USING URI URI-STRING)? ``` -### 15.2 UDF Deregistration +### 14.2 UDF Deregistration ```sql DROP FUNCTION ``` -### 15.3 UDF Queries +### 14.3 UDF Queries ```sql SELECT example(*) from root.sg.d1 @@ -1499,17 +1492,17 @@ SELECT s1 * example(* / s1 + s2) FROM root.sg.d1; SELECT s1, s2, s1 + example(s1, s2), s1 - example(s1 + example(s1, s2) / s2) FROM root.sg.d1; ``` -### 15.4 Show All Registered UDFs +### 14.4 Show All Registered UDFs ```sql SHOW FUNCTIONS ``` -## 16. ADMINISTRATION MANAGEMENT +## 15. ADMINISTRATION MANAGEMENT -For more details, see document [Operator-and-Expression](./Operator-and-Expression.md). +For more details, see document [Authority Management](../User-Manual/Authority-Management_timecho.md). -### 16.1 SQL Statements +### 15.1 SQL Statements - Create user (Requires MANAGE_USER permission) @@ -1600,7 +1593,7 @@ ALTER USER SET PASSWORD ; eg: ALTER USER tempuser SET PASSWORD 'newpwd'; ``` -### 16.2 Authorization and Deauthorization +### 15.2 Authorization and Deauthorization ```sql diff --git a/src/zh/UserGuide/Master/Tree/SQL-Manual/Function-and-Expression.md b/src/zh/UserGuide/Master/Tree/SQL-Manual/Function-and-Expression.md index ef1f2fbe6..b21af4567 100644 --- a/src/zh/UserGuide/Master/Tree/SQL-Manual/Function-and-Expression.md +++ b/src/zh/UserGuide/Master/Tree/SQL-Manual/Function-and-Expression.md @@ -2773,113 +2773,10 @@ select change_points(s1), change_points(s2), change_points(s3), change_points(s4 +-----------------------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+ ``` - - -## 13. Lambda 表达式 - -### 13.1 JEXL 自定义函数 - -#### 函数简介 - -Java Expression Language (JEXL) 是一个表达式语言引擎。我们使用 JEXL 来扩展 UDF,在命令行中,通过简易的 lambda 表达式来实现 UDF。 - -lambda 表达式中支持的运算符详见链接 [JEXL 中 lambda 表达式支持的运算符](https://commons.apache.org/proper/commons-jexl/apidocs/org/apache/commons/jexl3/package-summary.html#customization) 。 - -| 函数名 | 可接收的输入序列类型 | 必要的属性参数 | 输出序列类型 | 功能类型 | -|----------|--------------------------------|---------------------------------------|------------|--------------------------------------------------| -| JEXL | INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | `expr`是一个支持标准的一元或多元参数的lambda表达式,符合`x -> {...}`或`(x, y, z) -> {...}`的格式,例如`x -> {x * 2}`, `(x, y, z) -> {x + y * z}`| INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | 返回将输入的时间序列通过lambda表达式变换的序列 | - -#### 使用示例 - -输入序列: -``` -IoTDB> select * from root.ln.wf01.wt01; -+-----------------------------+---------------------+--------------------+-----------------------------+ -| Time|root.ln.wf01.wt01.str|root.ln.wf01.wt01.st|root.ln.wf01.wt01.temperature| -+-----------------------------+---------------------+--------------------+-----------------------------+ -|1970-01-01T08:00:00.000+08:00| str| 10.0| 0.0| -|1970-01-01T08:00:00.001+08:00| str| 20.0| 1.0| -|1970-01-01T08:00:00.002+08:00| str| 30.0| 2.0| -|1970-01-01T08:00:00.003+08:00| str| 40.0| 3.0| -|1970-01-01T08:00:00.004+08:00| str| 50.0| 4.0| -|1970-01-01T08:00:00.005+08:00| str| 60.0| 5.0| -|1970-01-01T08:00:00.006+08:00| str| 70.0| 6.0| -|1970-01-01T08:00:00.007+08:00| str| 80.0| 7.0| -|1970-01-01T08:00:00.008+08:00| str| 90.0| 8.0| -|1970-01-01T08:00:00.009+08:00| str| 100.0| 9.0| -|1970-01-01T08:00:00.010+08:00| str| 110.0| 10.0| -+-----------------------------+---------------------+--------------------+-----------------------------+ -``` - -用于查询的SQL语句: -```sql -select jexl(temperature, 'expr'='x -> {x + x}') as jexl1, jexl(temperature, 'expr'='x -> {x * 3}') as jexl2, jexl(temperature, 'expr'='x -> {x * x}') as jexl3, jexl(temperature, 'expr'='x -> {multiply(x, 100)}') as jexl4, jexl(temperature, st, 'expr'='(x, y) -> {x + y}') as jexl5, jexl(temperature, st, str, 'expr'='(x, y, z) -> {x + y + z}') as jexl6 from root.ln.wf01.wt01; -``` - -输出序列: -``` -+-----------------------------+-----+-----+-----+------+-----+--------+ -| Time|jexl1|jexl2|jexl3| jexl4|jexl5| jexl6| -+-----------------------------+-----+-----+-----+------+-----+--------+ -|1970-01-01T08:00:00.000+08:00| 0.0| 0.0| 0.0| 0.0| 10.0| 10.0str| -|1970-01-01T08:00:00.001+08:00| 2.0| 3.0| 1.0| 100.0| 21.0| 21.0str| -|1970-01-01T08:00:00.002+08:00| 4.0| 6.0| 4.0| 200.0| 32.0| 32.0str| -|1970-01-01T08:00:00.003+08:00| 6.0| 9.0| 9.0| 300.0| 43.0| 43.0str| -|1970-01-01T08:00:00.004+08:00| 8.0| 12.0| 16.0| 400.0| 54.0| 54.0str| -|1970-01-01T08:00:00.005+08:00| 10.0| 15.0| 25.0| 500.0| 65.0| 65.0str| -|1970-01-01T08:00:00.006+08:00| 12.0| 18.0| 36.0| 600.0| 76.0| 76.0str| -|1970-01-01T08:00:00.007+08:00| 14.0| 21.0| 49.0| 700.0| 87.0| 87.0str| -|1970-01-01T08:00:00.008+08:00| 16.0| 24.0| 64.0| 800.0| 98.0| 98.0str| -|1970-01-01T08:00:00.009+08:00| 18.0| 27.0| 81.0| 900.0|109.0|109.0str| -|1970-01-01T08:00:00.010+08:00| 20.0| 30.0|100.0|1000.0|120.0|120.0str| -+-----------------------------+-----+-----+-----+------+-----+--------+ -Total line number = 11 -It costs 0.118s -``` - - -## 14. 条件表达式 +## 13. 条件表达式 -### 14.1 CASE +### 13.1 CASE CASE表达式是一种条件表达式,可用于根据特定条件返回不同的值,功能类似于其它语言中的if-else。 CASE表达式由以下部分组成: diff --git a/src/zh/UserGuide/Master/Tree/SQL-Manual/Operator-and-Expression.md b/src/zh/UserGuide/Master/Tree/SQL-Manual/Operator-and-Expression.md index c3c694dba..aa026b9b0 100644 --- a/src/zh/UserGuide/Master/Tree/SQL-Manual/Operator-and-Expression.md +++ b/src/zh/UserGuide/Master/Tree/SQL-Manual/Operator-and-Expression.md @@ -33,7 +33,7 @@ |`+` |加| |`-` |减| -详细说明及示例见文档 [算数运算符和函数](../SQL-Manual/Function-and-Expression.md#算数运算符)。 +详细说明及示例见文档 [算数运算符和函数](../SQL-Manual/Function-and-Expression.md#_2-1-算数运算符)。 ### 1.2 比较运算符 |运算符 |含义| @@ -55,7 +55,7 @@ |`IN` / `CONTAINS` |是指定列表中的值| |`NOT IN` / `NOT CONTAINS` |不是指定列表中的值| -详细说明及示例见文档 [比较运算符和函数](../SQL-Manual/Function-and-Expression.md#比较运算符和函数)。 +详细说明及示例见文档 [比较运算符和函数](../SQL-Manual/Function-and-Expression.md#_3-比较运算符和函数)。 ### 1.3 逻辑运算符 |运算符 |含义| @@ -64,7 +64,7 @@ |`AND` / `&` / `&&` |逻辑与| |`OR`/ | / || |逻辑或| -详细说明及示例见文档 [逻辑运算符](../SQL-Manual/Function-and-Expression.md#逻辑运算符)。 +详细说明及示例见文档 [逻辑运算符](../SQL-Manual/Function-and-Expression.md#_4-逻辑运算符)。 ### 1.4 运算符优先级 @@ -110,7 +110,7 @@ OR, |, || | MAX_BY | MAX_BY(x, y) 求二元输入 x 和 y 在 y 最大时对应的 x 的值。MAX_BY(time, x) 返回 x 取最大值时对应的时间戳。 | 第一个输入 x 可以是任意类型,第二个输入 y 只能是 INT32 INT64 FLOAT DOUBLE STRING TIMESTAMP DATE | 与第一个输入 x 的数据类型一致 | | MIN_BY | MIN_BY(x, y) 求二元输入 x 和 y 在 y 最小时对应的 x 的值。MIN_BY(time, x) 返回 x 取最小值时对应的时间戳。 | 第一个输入 x 可以是任意类型,第二个输入 y 只能是 INT32 INT64 FLOAT DOUBLE STRING TIMESTAMP DATE | 与第一个输入 x 的数据类型一致 | -详细说明及示例见文档 [聚合函数](../SQL-Manual/Function-and-Expression.md#聚合函数)。 +详细说明及示例见文档 [聚合函数](../SQL-Manual/Function-and-Expression.md#_1-聚合函数)。 ### 2.2 数学函数 @@ -138,7 +138,7 @@ OR, |, || | SQRT | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE | | Math#sqrt(double) | -详细说明及示例见文档 [数学函数](../SQL-Manual/Function-and-Expression.md#数学函数)。 +详细说明及示例见文档 [数学函数](../SQL-Manual/Function-and-Expression.md#_2-2-数学函数)。 ### 2.3 比较函数 @@ -147,7 +147,7 @@ OR, |, || | ON_OFF | INT32 / INT64 / FLOAT / DOUBLE | `threshold`:DOUBLE | BOOLEAN | 返回`ts_value >= threshold`的bool值 | | IN_RANGE | INT32 / INT64 / FLOAT / DOUBLE | `lower`:DOUBLE
`upper`:DOUBLE | BOOLEAN | 返回`ts_value >= lower && ts_value <= upper`的bool值 | | -详细说明及示例见文档 [比较运算符和函数](../SQL-Manual/Function-and-Expression.md#比较运算符和函数)。 +详细说明及示例见文档 [比较运算符和函数](../SQL-Manual/Function-and-Expression.md#_3-比较运算符和函数)。 ### 2.4 字符串函数 @@ -167,7 +167,7 @@ OR, |, || | TRIM | TEXT STRING | 无 | TEXT | 移除字符串前后的空格 | | STRCMP | TEXT STRING | 无 | TEXT | 用于比较两个输入序列,如果值相同返回 `0` , 序列1的值小于序列2的值返回一个`负数`,序列1的值大于序列2的值返回一个`正数` | -详细说明及示例见文档 [字符串处理函数](../SQL-Manual/Function-and-Expression.md#字符串处理)。 +详细说明及示例见文档 [字符串处理函数](../SQL-Manual/Function-and-Expression.md#_5-字符串处理)。 ### 2.5 数据类型转换函数 @@ -175,7 +175,7 @@ OR, |, || | ------ | ------------------------------------------------------------ | ------------------------ | ---------------------------------- | | CAST | `type`:输出的数据点的类型,只能是 INT32 / INT64 / FLOAT / DOUBLE / BOOLEAN / TEXT | 由输入属性参数`type`决定 | 将数据转换为`type`参数指定的类型。 | -详细说明及示例见文档 [数据类型转换](../SQL-Manual/Function-and-Expression.md#数据类型转换)。 +详细说明及示例见文档 [数据类型转换](../SQL-Manual/Function-and-Expression.md#_6-数据类型转换)。 ### 2.6 常序列生成函数 @@ -185,7 +185,7 @@ OR, |, || | PI | 无 | DOUBLE | 常序列的值:`π` 的 `double` 值,圆的周长与其直径的比值,即圆周率,等于 *Java标准库* 中的`Math.PI`。 | | E | 无 | DOUBLE | 常序列的值:`e` 的 `double` 值,自然对数的底,它等于 *Java 标准库* 中的 `Math.E`。 | -详细说明及示例见文档 [常序列生成函数](../SQL-Manual/Function-and-Expression.md#常序列生成函数)。 +详细说明及示例见文档 [常序列生成函数](../SQL-Manual/Function-and-Expression.md#_7-常序列生成函数)。 ### 2.7 选择函数 @@ -194,7 +194,7 @@ OR, |, || | TOP_K | INT32 / INT64 / FLOAT / DOUBLE / TEXT / STRING / DATE / TIEMSTAMP | `k`: 最多选择的数据点数,必须大于 0 小于等于 1000 | 与输入序列的实际类型一致 | 返回某时间序列中值最大的`k`个数据点。若多于`k`个数据点的值并列最大,则返回时间戳最小的数据点。 | | BOTTOM_K | INT32 / INT64 / FLOAT / DOUBLE / TEXT / STRING / DATE / TIEMSTAMP | `k`: 最多选择的数据点数,必须大于 0 小于等于 1000 | 与输入序列的实际类型一致 | 返回某时间序列中值最小的`k`个数据点。若多于`k`个数据点的值并列最小,则返回时间戳最小的数据点。 | -详细说明及示例见文档 [选择函数](../SQL-Manual/Function-and-Expression.md#选择函数)。 +详细说明及示例见文档 [选择函数](../SQL-Manual/Function-and-Expression.md#_8-选择函数)。 ### 2.8 区间查询函数 @@ -205,7 +205,7 @@ OR, |, || | ZERO_COUNT | INT32/ INT64/ FLOAT/ DOUBLE/ BOOLEAN | `min`:可选,默认值1
`max`:可选,默认值`Long.MAX_VALUE` | Long | 返回时间序列连续为0(false)的开始时间与其后数据点的个数,数据点个数n满足`n >= min && n <= max` | | | NON_ZERO_COUNT | INT32/ INT64/ FLOAT/ DOUBLE/ BOOLEAN | `min`:可选,默认值1
`max`:可选,默认值`Long.MAX_VALUE` | Long | 返回时间序列连续不为0(false)的开始时间与其后数据点的个数,数据点个数n满足`n >= min && n <= max` | | -详细说明及示例见文档 [区间查询函数](../SQL-Manual/Function-and-Expression.md#区间查询函数)。 +详细说明及示例见文档 [区间查询函数](../SQL-Manual/Function-and-Expression.md#_9-区间查询函数)。 ### 2.9 趋势计算函数 @@ -222,7 +222,7 @@ OR, |, || |------|--------------------------------|------------------------------------------------------------------------------------------------------------------------|--------|------------------------------------------------| | DIFF | INT32 / INT64 / FLOAT / DOUBLE | `ignoreNull`:可选,默认为true;为true时,前一个数据点值为null时,忽略该数据点继续向前找到第一个出现的不为null的值;为false时,如果前一个数据点为null,则不忽略,使用null进行相减,结果也为null | DOUBLE | 统计序列中某数据点的值与前一数据点的值的差。第一个数据点没有对应的结果输出,输出值为null | -详细说明及示例见文档 [趋势计算函数](../SQL-Manual/Function-and-Expression.md#趋势计算函数)。 +详细说明及示例见文档 [趋势计算函数](../SQL-Manual/Function-and-Expression.md#_10-趋势计算函数)。 ### 2.10 采样函数 @@ -234,33 +234,25 @@ OR, |, || | EQUAL_SIZE_BUCKET_OUTLIER_SAMPLE | INT32 / INT64 / FLOAT / DOUBLE | `proportion`取值范围为`(0, 1]`,默认为`0.1`
`type`取值为`avg`或`stendis`或`cos`或`prenextdis`,默认为`avg`
`number`取值应大于0,默认`3`| INT32 / INT64 / FLOAT / DOUBLE | 返回符合采样比例和桶内采样个数的等分桶离群值采样 | | M4 | INT32 / INT64 / FLOAT / DOUBLE | 包含固定点数的窗口和滑动时间窗口使用不同的属性参数。包含固定点数的窗口使用属性`windowSize`和`slidingStep`。滑动时间窗口使用属性`timeInterval`、`slidingStep`、`displayWindowBegin`和`displayWindowEnd`。更多细节见下文。 | INT32 / INT64 / FLOAT / DOUBLE | 返回每个窗口内的第一个点(`first`)、最后一个点(`last`)、最小值点(`bottom`)、最大值点(`top`)。在一个窗口内的聚合点输出之前,M4会将它们按照时间戳递增排序并且去重。 | -详细说明及示例见文档 [采样函数](../SQL-Manual/Function-and-Expression.md#采样函数)。 +详细说明及示例见文档 [采样函数](../SQL-Manual/Function-and-Expression.md#_11-采样函数)。 ### 2.11 时间序列处理函数 | 函数名 | 输入序列类型 | 参数 | 输出序列类型 | 功能描述 | | ------------- | ------------------------------ | ---- | ------------------------ | -------------------------- | | CHANGE_POINTS | INT32 / INT64 / FLOAT / DOUBLE | / | 与输入序列的实际类型一致 | 去除输入序列中的连续相同值 | -详细说明及示例见文档 [时间序列处理](../SQL-Manual/Function-and-Expression.md#时间序列处理)。 +详细说明及示例见文档 [时间序列处理](../SQL-Manual/Function-and-Expression.md#_12-时间序列处理)。 -## 3 Lambda 表达式 - -| 函数名 | 可接收的输入序列类型 | 必要的属性参数 | 输出序列类型 | 功能类型 | -| ------ | ----------------------------------------------- | ------------------------------------------------------------ | ----------------------------------------------- | ---------------------------------------------- | -| JEXL | INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | `expr`是一个支持标准的一元或多元参数的lambda表达式,符合`x -> {...}`或`(x, y, z) -> {...}`的格式,例如`x -> {x * 2}`, `(x, y, z) -> {x + y * z}` | INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | 返回将输入的时间序列通过lambda表达式变换的序列 | - -详细说明及示例见文档 [Lambda 表达式](../SQL-Manual/Function-and-Expression.md#Lambda表达式) - -## 4 条件表达式 +## 3. 条件表达式 | 表达式名称 | 含义 | |---------------------------|-----------| | `CASE` | 类似if else | -详细说明及示例见文档 [条件表达式](../SQL-Manual/Function-and-Expression.md#条件表达式) +详细说明及示例见文档 [条件表达式](../SQL-Manual/Function-and-Expression.md#_13-条件表达式) -## 5 SELECT 表达式 +## 4. SELECT 表达式 `SELECT` 子句指定查询的输出,由若干个 `selectExpr` 组成。 每个 `selectExpr` 定义了查询结果中的一列或多列。 @@ -296,7 +288,7 @@ select s1 as temperature, s2 as speed from root.ln.wf01.wt01; #### 运算符 -IoTDB 中支持的运算符列表见文档 [运算符和函数](../SQL-Manual/Function-and-Expression.md#算数运算符和函数)。 +IoTDB 中支持的运算符列表见文档 [运算符和函数](../SQL-Manual/Function-and-Expression.md#_2-算数运算符和函数)。 #### 函数 @@ -314,7 +306,7 @@ select sin(s1), count(s1) from root.sg.d1; select s1, count(s1) from root.sg.d1 group by ([10,100),10ms); ``` -IoTDB 支持的聚合函数见文档 [聚合函数](../SQL-Manual/Function-and-Expression.md#聚合函数)。 +IoTDB 支持的聚合函数见文档 [聚合函数](../SQL-Manual/Function-and-Expression.md#_1-聚合函数)。 ##### 时间序列生成函数 @@ -324,7 +316,7 @@ IoTDB 支持的聚合函数见文档 [聚合函数](../SQL-Manual/Function-and-E ###### 内置时间序列生成函数 -IoTDB 中支持的内置函数列表见文档 [运算符和函数](../SQL-Manual/Function-and-Expression.md#算数运算符)。 +IoTDB 中支持的内置函数列表见文档 [运算符和函数](../SQL-Manual/Function-and-Expression.md#_2-1-算数运算符)。 ###### 自定义时间序列生成函数 diff --git a/src/zh/UserGuide/Master/Tree/SQL-Manual/SQL-Manual_apache.md b/src/zh/UserGuide/Master/Tree/SQL-Manual/SQL-Manual_apache.md index a84b8ae08..64ae297f5 100644 --- a/src/zh/UserGuide/Master/Tree/SQL-Manual/SQL-Manual_apache.md +++ b/src/zh/UserGuide/Master/Tree/SQL-Manual/SQL-Manual_apache.md @@ -1036,7 +1036,7 @@ explain analyze select s1,s2 from root.sg.d1 order by s1 ### 6.1 算数运算符 -更多见文档 [Arithmetic Operators and Functions](./Operator-and-Expression.md#算数运算符) +更多见文档 [Arithmetic Operators and Functions](./Operator-and-Expression.md#_1-1-算数运算符) ```sql select s1, - s1, s2, + s2, s1 + s2, s1 - s2, s1 * s2, s1 / s2, s1 % s2 from root.sg.d1 @@ -1044,7 +1044,7 @@ select s1, - s1, s2, + s2, s1 + s2, s1 - s2, s1 * s2, s1 / s2, s1 % s2 from root ### 6.2 比较运算符 -更多见文档[Comparison Operators and Functions](./Operator-and-Expression.md#比较运算符) +更多见文档[Comparison Operators and Functions](./Operator-and-Expression.md#_1-2-比较运算符) ```sql # Basic comparison operators @@ -1075,7 +1075,7 @@ select a, a in (1, 2) from root.test; ### 6.3 逻辑运算符 -更多见文档[Logical Operators](./Operator-and-Expression.md#逻辑运算符) +更多见文档[Logical Operators](./Operator-and-Expression.md#_1-3-逻辑运算符) ```sql select a, b, a > 10, a <= b, !(a <= b), a > 10 && a > b from root.test; @@ -1083,11 +1083,11 @@ select a, b, a > 10, a <= b, !(a <= b), a > 10 && a > b from root.test; ## 7. 内置函数 -更多见文档[Operator-and-Expression](./Operator-and-Expression.md#聚合函数) +更多见文档[Operator-and-Expression](./Operator-and-Expression.md#_2-内置函数) ### 7.1 Aggregate Functions -更多见文档[Aggregate Functions](./Operator-and-Expression.md#聚合函数) +更多见文档[Aggregate Functions](./Operator-and-Expression.md#_2-1-聚合函数) ```sql select count(status) from root.ln.wf01.wt01; @@ -1100,7 +1100,7 @@ select time_duration(s1) from root.db.d1; ### 7.2 算数函数 -更多见文档[Arithmetic Operators and Functions](./Operator-and-Expression.md#数学函数) +更多见文档[Arithmetic Operators and Functions](./Operator-and-Expression.md#_2-2-数学函数) ```sql select s1, sin(s1), cos(s1), tan(s1) from root.sg1.d1 limit 5 offset 1000; @@ -1109,7 +1109,7 @@ select s4,round(s4),round(s4,2),round(s4,-1) from root.sg1.d1; ### 7.3 比较函数 -更多见文档[Comparison Operators and Functions](./Operator-and-Expression.md#比较函数) +更多见文档[Comparison Operators and Functions](./Operator-and-Expression.md#_2-3-比较函数) ```sql select ts, on_off(ts, 'threshold'='2') from root.test; @@ -1118,7 +1118,7 @@ select ts, in_range(ts, 'lower'='2', 'upper'='3.1') from root.test; ### 7.4 字符串处理函数 -更多见文档[String Processing](./Operator-and-Expression.md#字符串函数) +更多见文档[String Processing](./Operator-and-Expression.md#_2-4-字符串函数) ```sql select s1, string_contains(s1, 's'='warn') from root.sg1.d4; @@ -1146,7 +1146,7 @@ select regexsplit(s1, "regex"=",", "index"="3") from root.test.d1 ### 7.5 数据类型转换函数 -更多见文档[Data Type Conversion Function](./Operator-and-Expression.md#数据类型转换函数) +更多见文档[Data Type Conversion Function](./Operator-and-Expression.md#_2-5-数据类型转换函数) ```sql SELECT cast(s1 as INT32) from root.sg @@ -1154,7 +1154,7 @@ SELECT cast(s1 as INT32) from root.sg ### 7.6 常序列生成函数 -更多见文档[Constant Timeseries Generating Functions](./Operator-and-Expression.md#常序列生成函数) +更多见文档[Constant Timeseries Generating Functions](./Operator-and-Expression.md#_2-6-常序列生成函数) ```sql select s1, s2, const(s1, 'value'='1024', 'type'='INT64'), pi(s2), e(s1, s2) from root.sg1.d1; @@ -1162,7 +1162,7 @@ select s1, s2, const(s1, 'value'='1024', 'type'='INT64'), pi(s2), e(s1, s2) from ### 7.7 选择函数 -更多见文档[Selector Functions](./Operator-and-Expression.md#选择函数) +更多见文档[Selector Functions](./Operator-and-Expression.md#_2-7-选择函数) ```sql select s1, top_k(s1, 'k'='2'), bottom_k(s1, 'k'='2') from root.sg1.d2 where time > 2020-12-10T20:36:15.530+08:00; @@ -1170,7 +1170,7 @@ select s1, top_k(s1, 'k'='2'), bottom_k(s1, 'k'='2') from root.sg1.d2 where time ### 7.8 区间查询函数 -更多见文档[Continuous Interval Functions](./Operator-and-Expression.md#区间查询函数) +更多见文档[Continuous Interval Functions](./Operator-and-Expression.md#_2-8-区间查询函数) ```sql select s1, zero_count(s1), non_zero_count(s2), zero_duration(s3), non_zero_duration(s4) from root.sg.d2; @@ -1178,7 +1178,7 @@ select s1, zero_count(s1), non_zero_count(s2), zero_duration(s3), non_zero_durat ### 7.9 趋势计算函数 -更多见文档[Variation Trend Calculation Functions](./Operator-and-Expression.md#趋势计算函数) +更多见文档[Variation Trend Calculation Functions](./Operator-and-Expression.md#_2-9-趋势计算函数) ```sql select s1, time_difference(s1), difference(s1), non_negative_difference(s1), derivative(s1), non_negative_derivative(s1) from root.sg1.d1 limit 5 offset 1000; @@ -1189,10 +1189,7 @@ SELECT DIFF(s1, 'ignoreNull'='false'), DIFF(s2, 'ignoreNull'='false') from root. ### 7.10 采样函数 -更多见文档[Sample Functions](./Operator-and-Expression.md#采样函数)。 -### 7.11 时间序列处理函数 - -更多见文档[Sample Functions](./Operator-and-Expression.md#时间序列处理函数)。 +更多见文档[Sample Functions](./Operator-and-Expression.md#_2-10-采样函数)。 ```sql select equal_size_bucket_random_sample(temperature,'proportion'='0.1') as random_sample from root.ln.wf01.wt01; @@ -1204,9 +1201,9 @@ select M4(s1,'timeInterval'='25','displayWindowBegin'='0','displayWindowEnd'='10 select M4(s1,'windowSize'='10') from root.vehicle.d1 ``` -### 7.12 时间序列处理函数 +### 7.11 时间序列处理函数 -更多见文档[Time-Series](./Operator-and-Expression.md#时间序列处理函数) +更多见文档[Time-Series](./Operator-and-Expression.md#_2-11-时间序列处理函数) ```sql select change_points(s1), change_points(s2), change_points(s3), change_points(s4), change_points(s5), change_points(s6) from root.testChangePoints.d1 @@ -1462,17 +1459,9 @@ select representation(s0,"tb"="3","vb"="2") from root.test.d0 select rm(s0, s1,"tb"="3","vb"="2") from root.test.d0 ``` -## 9. Lambda 表达式 - -更多见文档[Lambda](./Operator-and-Expression.md#lambda-表达式) - -```sql -select jexl(temperature, 'expr'='x -> {x + x}') as jexl1, jexl(temperature, 'expr'='x -> {x * 3}') as jexl2, jexl(temperature, 'expr'='x -> {x * x}') as jexl3, jexl(temperature, 'expr'='x -> {multiply(x, 100)}') as jexl4, jexl(temperature, st, 'expr'='(x, y) -> {x + y}') as jexl5, jexl(temperature, st, str, 'expr'='(x, y, z) -> {x + y + z}') as jexl6 from root.ln.wf01.wt01;``` -``` - -## 10. 条件表达式 +## 9. 条件表达式 -更多见文档[Conditional Expressions](./Operator-and-Expression.md#条件表达式) +更多见文档[Conditional Expressions](./Operator-and-Expression.md#_3-条件表达式) ```sql select T, P, case @@ -1508,9 +1497,9 @@ end as `result` from root.test4 ``` -## 11. 触发器 +## 10. 触发器 -### 11.1 使用 SQL 语句注册该触发器 +### 10.1 使用 SQL 语句注册该触发器 ```sql // Create Trigger @@ -1588,7 +1577,7 @@ WITH ( ) ``` -### 11.2 卸载触发器 +### 10.2 卸载触发器 #### 卸载触发器的 SQL 语法如下: ```sql @@ -1604,13 +1593,13 @@ dropTrigger ```sql DROP TRIGGER triggerTest1 ``` -### 11.3 查询触发器 +### 10.3 查询触发器 ```sql SHOW TRIGGERS ``` -## 12. 连续查询(Continuous Query, CQ) +## 11. 连续查询(Continuous Query, CQ) -### 12.1 语法 +### 11.1 语法 ```sql CREATE (CONTINUOUS QUERY | CQ) diff --git a/src/zh/UserGuide/Master/Tree/SQL-Manual/SQL-Manual_timecho.md b/src/zh/UserGuide/Master/Tree/SQL-Manual/SQL-Manual_timecho.md index 55083e822..86df95a41 100644 --- a/src/zh/UserGuide/Master/Tree/SQL-Manual/SQL-Manual_timecho.md +++ b/src/zh/UserGuide/Master/Tree/SQL-Manual/SQL-Manual_timecho.md @@ -961,7 +961,7 @@ explain analyze select s1,s2 from root.sg.d1 order by s1 ### 6.1 算数运算符 -更多见文档 [Arithmetic Operators and Functions](./Operator-and-Expression.md#算数运算符) +更多见文档 [Arithmetic Operators and Functions](./Operator-and-Expression.md#_1-1-算数运算符) ```sql select s1, - s1, s2, + s2, s1 + s2, s1 - s2, s1 * s2, s1 / s2, s1 % s2 from root.sg.d1 @@ -969,7 +969,7 @@ select s1, - s1, s2, + s2, s1 + s2, s1 - s2, s1 * s2, s1 / s2, s1 % s2 from root ### 6.2 比较运算符 -更多见文档[Comparison Operators and Functions](./Operator-and-Expression.md#比较运算符) +更多见文档[Comparison Operators and Functions](./Operator-and-Expression.md#_1-2-比较运算符) ```sql # Basic comparison operators @@ -1000,7 +1000,7 @@ select a, a in (1, 2) from root.test; ### 6.3 逻辑运算符 -更多见文档[Logical Operators](./Operator-and-Expression.md#逻辑运算符) +更多见文档[Logical Operators](./Operator-and-Expression.md#_1-3-逻辑运算符) ```sql select a, b, a > 10, a <= b, !(a <= b), a > 10 && a > b from root.test; @@ -1008,11 +1008,11 @@ select a, b, a > 10, a <= b, !(a <= b), a > 10 && a > b from root.test; ## 7. 内置函数 -更多见文档[Operator-and-Expression](./Operator-and-Expression.md#聚合函数) +更多见文档[Operator-and-Expression](./Operator-and-Expression.md#_2-内置函数) ### 7.1 Aggregate Functions -更多见文档[Aggregate Functions](./Operator-and-Expression.md#聚合函数) +更多见文档[Aggregate Functions](./Operator-and-Expression.md#_2-1-聚合函数) ```sql select count(status) from root.ln.wf01.wt01; @@ -1025,7 +1025,7 @@ select time_duration(s1) from root.db.d1; ### 7.2 算数函数 -更多见文档[Arithmetic Operators and Functions](./Operator-and-Expression.md#数学函数) +更多见文档[Arithmetic Operators and Functions](./Operator-and-Expression.md#_2-2-数学函数) ```sql select s1, sin(s1), cos(s1), tan(s1) from root.sg1.d1 limit 5 offset 1000; @@ -1034,7 +1034,7 @@ select s4,round(s4),round(s4,2),round(s4,-1) from root.sg1.d1; ### 7.3 比较函数 -更多见文档[Comparison Operators and Functions](./Operator-and-Expression.md#比较函数) +更多见文档[Comparison Operators and Functions](./Operator-and-Expression.md#_2-3-比较函数) ```sql select ts, on_off(ts, 'threshold'='2') from root.test; @@ -1043,7 +1043,7 @@ select ts, in_range(ts, 'lower'='2', 'upper'='3.1') from root.test; ### 7.4 字符串处理函数 -更多见文档[String Processing](./Operator-and-Expression.md#字符串函数) +更多见文档[String Processing](./Operator-and-Expression.md#_2-4-字符串函数) ```sql select s1, string_contains(s1, 's'='warn') from root.sg1.d4; @@ -1071,7 +1071,7 @@ select regexsplit(s1, "regex"=",", "index"="3") from root.test.d1 ### 7.5 数据类型转换函数 -更多见文档[Data Type Conversion Function](./Operator-and-Expression.md#数据类型转换函数) +更多见文档[Data Type Conversion Function](./Operator-and-Expression.md#_2-5-数据类型转换函数) ```sql SELECT cast(s1 as INT32) from root.sg @@ -1079,7 +1079,7 @@ SELECT cast(s1 as INT32) from root.sg ### 7.6 常序列生成函数 -更多见文档[Constant Timeseries Generating Functions](./Operator-and-Expression.md#常序列生成函数) +更多见文档[Constant Timeseries Generating Functions](./Operator-and-Expression.md#_2-6-常序列生成函数) ```sql select s1, s2, const(s1, 'value'='1024', 'type'='INT64'), pi(s2), e(s1, s2) from root.sg1.d1; @@ -1087,7 +1087,7 @@ select s1, s2, const(s1, 'value'='1024', 'type'='INT64'), pi(s2), e(s1, s2) from ### 7.7 选择函数 -更多见文档[Selector Functions](./Operator-and-Expression.md#选择函数) +更多见文档[Selector Functions](./Operator-and-Expression.md#_2-7-选择函数) ```sql select s1, top_k(s1, 'k'='2'), bottom_k(s1, 'k'='2') from root.sg1.d2 where time > 2020-12-10T20:36:15.530+08:00; @@ -1095,7 +1095,7 @@ select s1, top_k(s1, 'k'='2'), bottom_k(s1, 'k'='2') from root.sg1.d2 where time ### 7.8 区间查询函数 -更多见文档[Continuous Interval Functions](./Operator-and-Expression.md#区间查询函数) +更多见文档[Continuous Interval Functions](./Operator-and-Expression.md#_2-8-区间查询函数) ```sql select s1, zero_count(s1), non_zero_count(s2), zero_duration(s3), non_zero_duration(s4) from root.sg.d2; @@ -1103,7 +1103,7 @@ select s1, zero_count(s1), non_zero_count(s2), zero_duration(s3), non_zero_durat ### 7.9 趋势计算函数 -更多见文档[Variation Trend Calculation Functions](./Operator-and-Expression.md#趋势计算函数) +更多见文档[Variation Trend Calculation Functions](./Operator-and-Expression.md#_2-9-趋势计算函数) ```sql select s1, time_difference(s1), difference(s1), non_negative_difference(s1), derivative(s1), non_negative_derivative(s1) from root.sg1.d1 limit 5 offset 1000; @@ -1114,10 +1114,7 @@ SELECT DIFF(s1, 'ignoreNull'='false'), DIFF(s2, 'ignoreNull'='false') from root. ### 7.10 采样函数 -更多见文档[Sample Functions](./Operator-and-Expression.md#采样函数)。 -### 7.11 时间序列处理函数 - -更多见文档[Sample Functions](./Operator-and-Expression.md#时间序列处理函数)。 +更多见文档[Sample Functions](./Operator-and-Expression.md#_2-10-采样函数)。 ```sql select equal_size_bucket_random_sample(temperature,'proportion'='0.1') as random_sample from root.ln.wf01.wt01; @@ -1131,7 +1128,7 @@ select M4(s1,'windowSize'='10') from root.vehicle.d1 ### 7.12 时间序列处理函数 -更多见文档[Time-Series](./Operator-and-Expression.md#时间序列处理函数) +更多见文档[Time-Series](./Operator-and-Expression.md#_2-11-时间序列处理函数) ```sql select change_points(s1), change_points(s2), change_points(s3), change_points(s4), change_points(s5), change_points(s6) from root.testChangePoints.d1 @@ -1387,17 +1384,9 @@ select representation(s0,"tb"="3","vb"="2") from root.test.d0 select rm(s0, s1,"tb"="3","vb"="2") from root.test.d0 ``` -## 9. Lambda 表达式 +## 9. 条件表达式 -更多见文档[Lambda](./Operator-and-Expression.md#lambda-表达式) - -```sql -select jexl(temperature, 'expr'='x -> {x + x}') as jexl1, jexl(temperature, 'expr'='x -> {x * 3}') as jexl2, jexl(temperature, 'expr'='x -> {x * x}') as jexl3, jexl(temperature, 'expr'='x -> {multiply(x, 100)}') as jexl4, jexl(temperature, st, 'expr'='(x, y) -> {x + y}') as jexl5, jexl(temperature, st, str, 'expr'='(x, y, z) -> {x + y + z}') as jexl6 from root.ln.wf01.wt01;``` -``` - -## 10. 条件表达式 - -更多见文档[Conditional Expressions](./Operator-and-Expression.md#条件表达式) +更多见文档[Conditional Expressions](./Operator-and-Expression.md#_3-条件表达式) ```sql select T, P, case @@ -1433,9 +1422,9 @@ end as `result` from root.test4 ``` -## 11. 触发器 +## 10. 触发器 -### 11.1 使用 SQL 语句注册该触发器 +### 10.1 使用 SQL 语句注册该触发器 ```sql // Create Trigger @@ -1513,7 +1502,7 @@ WITH ( ) ``` -### 11.2 卸载触发器 +### 10.2 卸载触发器 #### 卸载触发器的 SQL 语法如下: ```sql @@ -1529,15 +1518,15 @@ dropTrigger ```sql DROP TRIGGER triggerTest1 ``` -### 11.3 查询触发器 +### 10.3 查询触发器 ```sql SHOW TRIGGERS ``` -## 12. 连续查询(Continuous Query, CQ) +## 11. 连续查询(Continuous Query, CQ) -### 12.1 语法 +### 11.1 语法 -```sql +```Go CREATE (CONTINUOUS QUERY | CQ) [RESAMPLE [EVERY ] diff --git a/src/zh/UserGuide/V1.3.x/SQL-Manual/Function-and-Expression.md b/src/zh/UserGuide/V1.3.x/SQL-Manual/Function-and-Expression.md index 2ee77a3c8..f6985f56a 100644 --- a/src/zh/UserGuide/V1.3.x/SQL-Manual/Function-and-Expression.md +++ b/src/zh/UserGuide/V1.3.x/SQL-Manual/Function-and-Expression.md @@ -2774,110 +2774,6 @@ select change_points(s1), change_points(s2), change_points(s3), change_points(s4 +-----------------------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+ ``` - - -## Lambda 表达式 - -### JEXL 自定义函数 - -#### 函数简介 - -Java Expression Language (JEXL) 是一个表达式语言引擎。我们使用 JEXL 来扩展 UDF,在命令行中,通过简易的 lambda 表达式来实现 UDF。 - -lambda 表达式中支持的运算符详见链接 [JEXL 中 lambda 表达式支持的运算符](https://commons.apache.org/proper/commons-jexl/apidocs/org/apache/commons/jexl3/package-summary.html#customization) 。 - -| 函数名 | 可接收的输入序列类型 | 必要的属性参数 | 输出序列类型 | 功能类型 | -|----------|--------------------------------|---------------------------------------|------------|--------------------------------------------------| -| JEXL | INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | `expr`是一个支持标准的一元或多元参数的lambda表达式,符合`x -> {...}`或`(x, y, z) -> {...}`的格式,例如`x -> {x * 2}`, `(x, y, z) -> {x + y * z}`| INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | 返回将输入的时间序列通过lambda表达式变换的序列 | - -#### 使用示例 - -输入序列: -``` -IoTDB> select * from root.ln.wf01.wt01; -+-----------------------------+---------------------+--------------------+-----------------------------+ -| Time|root.ln.wf01.wt01.str|root.ln.wf01.wt01.st|root.ln.wf01.wt01.temperature| -+-----------------------------+---------------------+--------------------+-----------------------------+ -|1970-01-01T08:00:00.000+08:00| str| 10.0| 0.0| -|1970-01-01T08:00:00.001+08:00| str| 20.0| 1.0| -|1970-01-01T08:00:00.002+08:00| str| 30.0| 2.0| -|1970-01-01T08:00:00.003+08:00| str| 40.0| 3.0| -|1970-01-01T08:00:00.004+08:00| str| 50.0| 4.0| -|1970-01-01T08:00:00.005+08:00| str| 60.0| 5.0| -|1970-01-01T08:00:00.006+08:00| str| 70.0| 6.0| -|1970-01-01T08:00:00.007+08:00| str| 80.0| 7.0| -|1970-01-01T08:00:00.008+08:00| str| 90.0| 8.0| -|1970-01-01T08:00:00.009+08:00| str| 100.0| 9.0| -|1970-01-01T08:00:00.010+08:00| str| 110.0| 10.0| -+-----------------------------+---------------------+--------------------+-----------------------------+ -``` - -用于查询的SQL语句: -```sql -select jexl(temperature, 'expr'='x -> {x + x}') as jexl1, jexl(temperature, 'expr'='x -> {x * 3}') as jexl2, jexl(temperature, 'expr'='x -> {x * x}') as jexl3, jexl(temperature, 'expr'='x -> {multiply(x, 100)}') as jexl4, jexl(temperature, st, 'expr'='(x, y) -> {x + y}') as jexl5, jexl(temperature, st, str, 'expr'='(x, y, z) -> {x + y + z}') as jexl6 from root.ln.wf01.wt01; -``` - -输出序列: -``` -+-----------------------------+-----+-----+-----+------+-----+--------+ -| Time|jexl1|jexl2|jexl3| jexl4|jexl5| jexl6| -+-----------------------------+-----+-----+-----+------+-----+--------+ -|1970-01-01T08:00:00.000+08:00| 0.0| 0.0| 0.0| 0.0| 10.0| 10.0str| -|1970-01-01T08:00:00.001+08:00| 2.0| 3.0| 1.0| 100.0| 21.0| 21.0str| -|1970-01-01T08:00:00.002+08:00| 4.0| 6.0| 4.0| 200.0| 32.0| 32.0str| -|1970-01-01T08:00:00.003+08:00| 6.0| 9.0| 9.0| 300.0| 43.0| 43.0str| -|1970-01-01T08:00:00.004+08:00| 8.0| 12.0| 16.0| 400.0| 54.0| 54.0str| -|1970-01-01T08:00:00.005+08:00| 10.0| 15.0| 25.0| 500.0| 65.0| 65.0str| -|1970-01-01T08:00:00.006+08:00| 12.0| 18.0| 36.0| 600.0| 76.0| 76.0str| -|1970-01-01T08:00:00.007+08:00| 14.0| 21.0| 49.0| 700.0| 87.0| 87.0str| -|1970-01-01T08:00:00.008+08:00| 16.0| 24.0| 64.0| 800.0| 98.0| 98.0str| -|1970-01-01T08:00:00.009+08:00| 18.0| 27.0| 81.0| 900.0|109.0|109.0str| -|1970-01-01T08:00:00.010+08:00| 20.0| 30.0|100.0|1000.0|120.0|120.0str| -+-----------------------------+-----+-----+-----+------+-----+--------+ -Total line number = 11 -It costs 0.118s -``` - - - ## 条件表达式 ### CASE diff --git a/src/zh/UserGuide/V1.3.x/SQL-Manual/Operator-and-Expression.md b/src/zh/UserGuide/V1.3.x/SQL-Manual/Operator-and-Expression.md index d544c9ba1..a51ad6fe7 100644 --- a/src/zh/UserGuide/V1.3.x/SQL-Manual/Operator-and-Expression.md +++ b/src/zh/UserGuide/V1.3.x/SQL-Manual/Operator-and-Expression.md @@ -244,14 +244,6 @@ OR, |, || 详细说明及示例见文档 [时间序列处理](../SQL-Manual/Function-and-Expression.md#时间序列处理)。 -## Lambda 表达式 - -| 函数名 | 可接收的输入序列类型 | 必要的属性参数 | 输出序列类型 | 功能类型 | -| ------ | ----------------------------------------------- | ------------------------------------------------------------ | ----------------------------------------------- | ---------------------------------------------- | -| JEXL | INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | `expr`是一个支持标准的一元或多元参数的lambda表达式,符合`x -> {...}`或`(x, y, z) -> {...}`的格式,例如`x -> {x * 2}`, `(x, y, z) -> {x + y * z}` | INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | 返回将输入的时间序列通过lambda表达式变换的序列 | - -详细说明及示例见文档 [Lambda 表达式](../SQL-Manual/Function-and-Expression.md#lambda-表达式) - ## 条件表达式 | 表达式名称 | 含义 | diff --git a/src/zh/UserGuide/V1.3.x/SQL-Manual/SQL-Manual.md b/src/zh/UserGuide/V1.3.x/SQL-Manual/SQL-Manual.md index d2ce1557a..3cd3395b8 100644 --- a/src/zh/UserGuide/V1.3.x/SQL-Manual/SQL-Manual.md +++ b/src/zh/UserGuide/V1.3.x/SQL-Manual/SQL-Manual.md @@ -1462,13 +1462,6 @@ select representation(s0,"tb"="3","vb"="2") from root.test.d0 select rm(s0, s1,"tb"="3","vb"="2") from root.test.d0 ``` -## Lambda 表达式 - -更多见文档[Lambda](./Operator-and-Expression.md#lambda-表达式) - -```sql -select jexl(temperature, 'expr'='x -> {x + x}') as jexl1, jexl(temperature, 'expr'='x -> {x * 3}') as jexl2, jexl(temperature, 'expr'='x -> {x * x}') as jexl3, jexl(temperature, 'expr'='x -> {multiply(x, 100)}') as jexl4, jexl(temperature, st, 'expr'='(x, y) -> {x + y}') as jexl5, jexl(temperature, st, str, 'expr'='(x, y, z) -> {x + y + z}') as jexl6 from root.ln.wf01.wt01;``` -``` ## 条件表达式 diff --git a/src/zh/UserGuide/dev-1.3/SQL-Manual/Function-and-Expression.md b/src/zh/UserGuide/dev-1.3/SQL-Manual/Function-and-Expression.md index 416c1b330..ce558c306 100644 --- a/src/zh/UserGuide/dev-1.3/SQL-Manual/Function-and-Expression.md +++ b/src/zh/UserGuide/dev-1.3/SQL-Manual/Function-and-Expression.md @@ -2774,110 +2774,6 @@ select change_points(s1), change_points(s2), change_points(s3), change_points(s4 +-----------------------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+ ``` - - -## Lambda 表达式 - -### JEXL 自定义函数 - -#### 函数简介 - -Java Expression Language (JEXL) 是一个表达式语言引擎。我们使用 JEXL 来扩展 UDF,在命令行中,通过简易的 lambda 表达式来实现 UDF。 - -lambda 表达式中支持的运算符详见链接 [JEXL 中 lambda 表达式支持的运算符](https://commons.apache.org/proper/commons-jexl/apidocs/org/apache/commons/jexl3/package-summary.html#customization) 。 - -| 函数名 | 可接收的输入序列类型 | 必要的属性参数 | 输出序列类型 | 功能类型 | -|----------|--------------------------------|---------------------------------------|------------|--------------------------------------------------| -| JEXL | INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | `expr`是一个支持标准的一元或多元参数的lambda表达式,符合`x -> {...}`或`(x, y, z) -> {...}`的格式,例如`x -> {x * 2}`, `(x, y, z) -> {x + y * z}`| INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | 返回将输入的时间序列通过lambda表达式变换的序列 | - -#### 使用示例 - -输入序列: -``` -IoTDB> select * from root.ln.wf01.wt01; -+-----------------------------+---------------------+--------------------+-----------------------------+ -| Time|root.ln.wf01.wt01.str|root.ln.wf01.wt01.st|root.ln.wf01.wt01.temperature| -+-----------------------------+---------------------+--------------------+-----------------------------+ -|1970-01-01T08:00:00.000+08:00| str| 10.0| 0.0| -|1970-01-01T08:00:00.001+08:00| str| 20.0| 1.0| -|1970-01-01T08:00:00.002+08:00| str| 30.0| 2.0| -|1970-01-01T08:00:00.003+08:00| str| 40.0| 3.0| -|1970-01-01T08:00:00.004+08:00| str| 50.0| 4.0| -|1970-01-01T08:00:00.005+08:00| str| 60.0| 5.0| -|1970-01-01T08:00:00.006+08:00| str| 70.0| 6.0| -|1970-01-01T08:00:00.007+08:00| str| 80.0| 7.0| -|1970-01-01T08:00:00.008+08:00| str| 90.0| 8.0| -|1970-01-01T08:00:00.009+08:00| str| 100.0| 9.0| -|1970-01-01T08:00:00.010+08:00| str| 110.0| 10.0| -+-----------------------------+---------------------+--------------------+-----------------------------+ -``` - -用于查询的SQL语句: -```sql -select jexl(temperature, 'expr'='x -> {x + x}') as jexl1, jexl(temperature, 'expr'='x -> {x * 3}') as jexl2, jexl(temperature, 'expr'='x -> {x * x}') as jexl3, jexl(temperature, 'expr'='x -> {multiply(x, 100)}') as jexl4, jexl(temperature, st, 'expr'='(x, y) -> {x + y}') as jexl5, jexl(temperature, st, str, 'expr'='(x, y, z) -> {x + y + z}') as jexl6 from root.ln.wf01.wt01; -``` - -输出序列: -``` -+-----------------------------+-----+-----+-----+------+-----+--------+ -| Time|jexl1|jexl2|jexl3| jexl4|jexl5| jexl6| -+-----------------------------+-----+-----+-----+------+-----+--------+ -|1970-01-01T08:00:00.000+08:00| 0.0| 0.0| 0.0| 0.0| 10.0| 10.0str| -|1970-01-01T08:00:00.001+08:00| 2.0| 3.0| 1.0| 100.0| 21.0| 21.0str| -|1970-01-01T08:00:00.002+08:00| 4.0| 6.0| 4.0| 200.0| 32.0| 32.0str| -|1970-01-01T08:00:00.003+08:00| 6.0| 9.0| 9.0| 300.0| 43.0| 43.0str| -|1970-01-01T08:00:00.004+08:00| 8.0| 12.0| 16.0| 400.0| 54.0| 54.0str| -|1970-01-01T08:00:00.005+08:00| 10.0| 15.0| 25.0| 500.0| 65.0| 65.0str| -|1970-01-01T08:00:00.006+08:00| 12.0| 18.0| 36.0| 600.0| 76.0| 76.0str| -|1970-01-01T08:00:00.007+08:00| 14.0| 21.0| 49.0| 700.0| 87.0| 87.0str| -|1970-01-01T08:00:00.008+08:00| 16.0| 24.0| 64.0| 800.0| 98.0| 98.0str| -|1970-01-01T08:00:00.009+08:00| 18.0| 27.0| 81.0| 900.0|109.0|109.0str| -|1970-01-01T08:00:00.010+08:00| 20.0| 30.0|100.0|1000.0|120.0|120.0str| -+-----------------------------+-----+-----+-----+------+-----+--------+ -Total line number = 11 -It costs 0.118s -``` - - - ## 条件表达式 ### CASE diff --git a/src/zh/UserGuide/dev-1.3/SQL-Manual/Operator-and-Expression.md b/src/zh/UserGuide/dev-1.3/SQL-Manual/Operator-and-Expression.md index 049880eda..3543aa297 100644 --- a/src/zh/UserGuide/dev-1.3/SQL-Manual/Operator-and-Expression.md +++ b/src/zh/UserGuide/dev-1.3/SQL-Manual/Operator-and-Expression.md @@ -244,14 +244,6 @@ OR, |, || 详细说明及示例见文档 [时间序列处理](../SQL-Manual/Function-and-Expression.md#时间序列处理)。 -## Lambda 表达式 - -| 函数名 | 可接收的输入序列类型 | 必要的属性参数 | 输出序列类型 | 功能类型 | -| ------ | ----------------------------------------------- | ------------------------------------------------------------ | ----------------------------------------------- | ---------------------------------------------- | -| JEXL | INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | `expr`是一个支持标准的一元或多元参数的lambda表达式,符合`x -> {...}`或`(x, y, z) -> {...}`的格式,例如`x -> {x * 2}`, `(x, y, z) -> {x + y * z}` | INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | 返回将输入的时间序列通过lambda表达式变换的序列 | - -详细说明及示例见文档 [Lambda 表达式](../SQL-Manual/Function-and-Expression.md#Lambda表达式) - ## 条件表达式 | 表达式名称 | 含义 | diff --git a/src/zh/UserGuide/dev-1.3/SQL-Manual/SQL-Manual.md b/src/zh/UserGuide/dev-1.3/SQL-Manual/SQL-Manual.md index d2ce1557a..3cd3395b8 100644 --- a/src/zh/UserGuide/dev-1.3/SQL-Manual/SQL-Manual.md +++ b/src/zh/UserGuide/dev-1.3/SQL-Manual/SQL-Manual.md @@ -1462,13 +1462,6 @@ select representation(s0,"tb"="3","vb"="2") from root.test.d0 select rm(s0, s1,"tb"="3","vb"="2") from root.test.d0 ``` -## Lambda 表达式 - -更多见文档[Lambda](./Operator-and-Expression.md#lambda-表达式) - -```sql -select jexl(temperature, 'expr'='x -> {x + x}') as jexl1, jexl(temperature, 'expr'='x -> {x * 3}') as jexl2, jexl(temperature, 'expr'='x -> {x * x}') as jexl3, jexl(temperature, 'expr'='x -> {multiply(x, 100)}') as jexl4, jexl(temperature, st, 'expr'='(x, y) -> {x + y}') as jexl5, jexl(temperature, st, str, 'expr'='(x, y, z) -> {x + y + z}') as jexl6 from root.ln.wf01.wt01;``` -``` ## 条件表达式 diff --git a/src/zh/UserGuide/latest/SQL-Manual/Function-and-Expression.md b/src/zh/UserGuide/latest/SQL-Manual/Function-and-Expression.md index ef1f2fbe6..b21af4567 100644 --- a/src/zh/UserGuide/latest/SQL-Manual/Function-and-Expression.md +++ b/src/zh/UserGuide/latest/SQL-Manual/Function-and-Expression.md @@ -2773,113 +2773,10 @@ select change_points(s1), change_points(s2), change_points(s3), change_points(s4 +-----------------------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+ ``` - - -## 13. Lambda 表达式 - -### 13.1 JEXL 自定义函数 - -#### 函数简介 - -Java Expression Language (JEXL) 是一个表达式语言引擎。我们使用 JEXL 来扩展 UDF,在命令行中,通过简易的 lambda 表达式来实现 UDF。 - -lambda 表达式中支持的运算符详见链接 [JEXL 中 lambda 表达式支持的运算符](https://commons.apache.org/proper/commons-jexl/apidocs/org/apache/commons/jexl3/package-summary.html#customization) 。 - -| 函数名 | 可接收的输入序列类型 | 必要的属性参数 | 输出序列类型 | 功能类型 | -|----------|--------------------------------|---------------------------------------|------------|--------------------------------------------------| -| JEXL | INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | `expr`是一个支持标准的一元或多元参数的lambda表达式,符合`x -> {...}`或`(x, y, z) -> {...}`的格式,例如`x -> {x * 2}`, `(x, y, z) -> {x + y * z}`| INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | 返回将输入的时间序列通过lambda表达式变换的序列 | - -#### 使用示例 - -输入序列: -``` -IoTDB> select * from root.ln.wf01.wt01; -+-----------------------------+---------------------+--------------------+-----------------------------+ -| Time|root.ln.wf01.wt01.str|root.ln.wf01.wt01.st|root.ln.wf01.wt01.temperature| -+-----------------------------+---------------------+--------------------+-----------------------------+ -|1970-01-01T08:00:00.000+08:00| str| 10.0| 0.0| -|1970-01-01T08:00:00.001+08:00| str| 20.0| 1.0| -|1970-01-01T08:00:00.002+08:00| str| 30.0| 2.0| -|1970-01-01T08:00:00.003+08:00| str| 40.0| 3.0| -|1970-01-01T08:00:00.004+08:00| str| 50.0| 4.0| -|1970-01-01T08:00:00.005+08:00| str| 60.0| 5.0| -|1970-01-01T08:00:00.006+08:00| str| 70.0| 6.0| -|1970-01-01T08:00:00.007+08:00| str| 80.0| 7.0| -|1970-01-01T08:00:00.008+08:00| str| 90.0| 8.0| -|1970-01-01T08:00:00.009+08:00| str| 100.0| 9.0| -|1970-01-01T08:00:00.010+08:00| str| 110.0| 10.0| -+-----------------------------+---------------------+--------------------+-----------------------------+ -``` - -用于查询的SQL语句: -```sql -select jexl(temperature, 'expr'='x -> {x + x}') as jexl1, jexl(temperature, 'expr'='x -> {x * 3}') as jexl2, jexl(temperature, 'expr'='x -> {x * x}') as jexl3, jexl(temperature, 'expr'='x -> {multiply(x, 100)}') as jexl4, jexl(temperature, st, 'expr'='(x, y) -> {x + y}') as jexl5, jexl(temperature, st, str, 'expr'='(x, y, z) -> {x + y + z}') as jexl6 from root.ln.wf01.wt01; -``` - -输出序列: -``` -+-----------------------------+-----+-----+-----+------+-----+--------+ -| Time|jexl1|jexl2|jexl3| jexl4|jexl5| jexl6| -+-----------------------------+-----+-----+-----+------+-----+--------+ -|1970-01-01T08:00:00.000+08:00| 0.0| 0.0| 0.0| 0.0| 10.0| 10.0str| -|1970-01-01T08:00:00.001+08:00| 2.0| 3.0| 1.0| 100.0| 21.0| 21.0str| -|1970-01-01T08:00:00.002+08:00| 4.0| 6.0| 4.0| 200.0| 32.0| 32.0str| -|1970-01-01T08:00:00.003+08:00| 6.0| 9.0| 9.0| 300.0| 43.0| 43.0str| -|1970-01-01T08:00:00.004+08:00| 8.0| 12.0| 16.0| 400.0| 54.0| 54.0str| -|1970-01-01T08:00:00.005+08:00| 10.0| 15.0| 25.0| 500.0| 65.0| 65.0str| -|1970-01-01T08:00:00.006+08:00| 12.0| 18.0| 36.0| 600.0| 76.0| 76.0str| -|1970-01-01T08:00:00.007+08:00| 14.0| 21.0| 49.0| 700.0| 87.0| 87.0str| -|1970-01-01T08:00:00.008+08:00| 16.0| 24.0| 64.0| 800.0| 98.0| 98.0str| -|1970-01-01T08:00:00.009+08:00| 18.0| 27.0| 81.0| 900.0|109.0|109.0str| -|1970-01-01T08:00:00.010+08:00| 20.0| 30.0|100.0|1000.0|120.0|120.0str| -+-----------------------------+-----+-----+-----+------+-----+--------+ -Total line number = 11 -It costs 0.118s -``` - - -## 14. 条件表达式 +## 13. 条件表达式 -### 14.1 CASE +### 13.1 CASE CASE表达式是一种条件表达式,可用于根据特定条件返回不同的值,功能类似于其它语言中的if-else。 CASE表达式由以下部分组成: diff --git a/src/zh/UserGuide/latest/SQL-Manual/Operator-and-Expression.md b/src/zh/UserGuide/latest/SQL-Manual/Operator-and-Expression.md index c3c694dba..aa026b9b0 100644 --- a/src/zh/UserGuide/latest/SQL-Manual/Operator-and-Expression.md +++ b/src/zh/UserGuide/latest/SQL-Manual/Operator-and-Expression.md @@ -33,7 +33,7 @@ |`+` |加| |`-` |减| -详细说明及示例见文档 [算数运算符和函数](../SQL-Manual/Function-and-Expression.md#算数运算符)。 +详细说明及示例见文档 [算数运算符和函数](../SQL-Manual/Function-and-Expression.md#_2-1-算数运算符)。 ### 1.2 比较运算符 |运算符 |含义| @@ -55,7 +55,7 @@ |`IN` / `CONTAINS` |是指定列表中的值| |`NOT IN` / `NOT CONTAINS` |不是指定列表中的值| -详细说明及示例见文档 [比较运算符和函数](../SQL-Manual/Function-and-Expression.md#比较运算符和函数)。 +详细说明及示例见文档 [比较运算符和函数](../SQL-Manual/Function-and-Expression.md#_3-比较运算符和函数)。 ### 1.3 逻辑运算符 |运算符 |含义| @@ -64,7 +64,7 @@ |`AND` / `&` / `&&` |逻辑与| |`OR`/ | / || |逻辑或| -详细说明及示例见文档 [逻辑运算符](../SQL-Manual/Function-and-Expression.md#逻辑运算符)。 +详细说明及示例见文档 [逻辑运算符](../SQL-Manual/Function-and-Expression.md#_4-逻辑运算符)。 ### 1.4 运算符优先级 @@ -110,7 +110,7 @@ OR, |, || | MAX_BY | MAX_BY(x, y) 求二元输入 x 和 y 在 y 最大时对应的 x 的值。MAX_BY(time, x) 返回 x 取最大值时对应的时间戳。 | 第一个输入 x 可以是任意类型,第二个输入 y 只能是 INT32 INT64 FLOAT DOUBLE STRING TIMESTAMP DATE | 与第一个输入 x 的数据类型一致 | | MIN_BY | MIN_BY(x, y) 求二元输入 x 和 y 在 y 最小时对应的 x 的值。MIN_BY(time, x) 返回 x 取最小值时对应的时间戳。 | 第一个输入 x 可以是任意类型,第二个输入 y 只能是 INT32 INT64 FLOAT DOUBLE STRING TIMESTAMP DATE | 与第一个输入 x 的数据类型一致 | -详细说明及示例见文档 [聚合函数](../SQL-Manual/Function-and-Expression.md#聚合函数)。 +详细说明及示例见文档 [聚合函数](../SQL-Manual/Function-and-Expression.md#_1-聚合函数)。 ### 2.2 数学函数 @@ -138,7 +138,7 @@ OR, |, || | SQRT | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE | | Math#sqrt(double) | -详细说明及示例见文档 [数学函数](../SQL-Manual/Function-and-Expression.md#数学函数)。 +详细说明及示例见文档 [数学函数](../SQL-Manual/Function-and-Expression.md#_2-2-数学函数)。 ### 2.3 比较函数 @@ -147,7 +147,7 @@ OR, |, || | ON_OFF | INT32 / INT64 / FLOAT / DOUBLE | `threshold`:DOUBLE | BOOLEAN | 返回`ts_value >= threshold`的bool值 | | IN_RANGE | INT32 / INT64 / FLOAT / DOUBLE | `lower`:DOUBLE
`upper`:DOUBLE | BOOLEAN | 返回`ts_value >= lower && ts_value <= upper`的bool值 | | -详细说明及示例见文档 [比较运算符和函数](../SQL-Manual/Function-and-Expression.md#比较运算符和函数)。 +详细说明及示例见文档 [比较运算符和函数](../SQL-Manual/Function-and-Expression.md#_3-比较运算符和函数)。 ### 2.4 字符串函数 @@ -167,7 +167,7 @@ OR, |, || | TRIM | TEXT STRING | 无 | TEXT | 移除字符串前后的空格 | | STRCMP | TEXT STRING | 无 | TEXT | 用于比较两个输入序列,如果值相同返回 `0` , 序列1的值小于序列2的值返回一个`负数`,序列1的值大于序列2的值返回一个`正数` | -详细说明及示例见文档 [字符串处理函数](../SQL-Manual/Function-and-Expression.md#字符串处理)。 +详细说明及示例见文档 [字符串处理函数](../SQL-Manual/Function-and-Expression.md#_5-字符串处理)。 ### 2.5 数据类型转换函数 @@ -175,7 +175,7 @@ OR, |, || | ------ | ------------------------------------------------------------ | ------------------------ | ---------------------------------- | | CAST | `type`:输出的数据点的类型,只能是 INT32 / INT64 / FLOAT / DOUBLE / BOOLEAN / TEXT | 由输入属性参数`type`决定 | 将数据转换为`type`参数指定的类型。 | -详细说明及示例见文档 [数据类型转换](../SQL-Manual/Function-and-Expression.md#数据类型转换)。 +详细说明及示例见文档 [数据类型转换](../SQL-Manual/Function-and-Expression.md#_6-数据类型转换)。 ### 2.6 常序列生成函数 @@ -185,7 +185,7 @@ OR, |, || | PI | 无 | DOUBLE | 常序列的值:`π` 的 `double` 值,圆的周长与其直径的比值,即圆周率,等于 *Java标准库* 中的`Math.PI`。 | | E | 无 | DOUBLE | 常序列的值:`e` 的 `double` 值,自然对数的底,它等于 *Java 标准库* 中的 `Math.E`。 | -详细说明及示例见文档 [常序列生成函数](../SQL-Manual/Function-and-Expression.md#常序列生成函数)。 +详细说明及示例见文档 [常序列生成函数](../SQL-Manual/Function-and-Expression.md#_7-常序列生成函数)。 ### 2.7 选择函数 @@ -194,7 +194,7 @@ OR, |, || | TOP_K | INT32 / INT64 / FLOAT / DOUBLE / TEXT / STRING / DATE / TIEMSTAMP | `k`: 最多选择的数据点数,必须大于 0 小于等于 1000 | 与输入序列的实际类型一致 | 返回某时间序列中值最大的`k`个数据点。若多于`k`个数据点的值并列最大,则返回时间戳最小的数据点。 | | BOTTOM_K | INT32 / INT64 / FLOAT / DOUBLE / TEXT / STRING / DATE / TIEMSTAMP | `k`: 最多选择的数据点数,必须大于 0 小于等于 1000 | 与输入序列的实际类型一致 | 返回某时间序列中值最小的`k`个数据点。若多于`k`个数据点的值并列最小,则返回时间戳最小的数据点。 | -详细说明及示例见文档 [选择函数](../SQL-Manual/Function-and-Expression.md#选择函数)。 +详细说明及示例见文档 [选择函数](../SQL-Manual/Function-and-Expression.md#_8-选择函数)。 ### 2.8 区间查询函数 @@ -205,7 +205,7 @@ OR, |, || | ZERO_COUNT | INT32/ INT64/ FLOAT/ DOUBLE/ BOOLEAN | `min`:可选,默认值1
`max`:可选,默认值`Long.MAX_VALUE` | Long | 返回时间序列连续为0(false)的开始时间与其后数据点的个数,数据点个数n满足`n >= min && n <= max` | | | NON_ZERO_COUNT | INT32/ INT64/ FLOAT/ DOUBLE/ BOOLEAN | `min`:可选,默认值1
`max`:可选,默认值`Long.MAX_VALUE` | Long | 返回时间序列连续不为0(false)的开始时间与其后数据点的个数,数据点个数n满足`n >= min && n <= max` | | -详细说明及示例见文档 [区间查询函数](../SQL-Manual/Function-and-Expression.md#区间查询函数)。 +详细说明及示例见文档 [区间查询函数](../SQL-Manual/Function-and-Expression.md#_9-区间查询函数)。 ### 2.9 趋势计算函数 @@ -222,7 +222,7 @@ OR, |, || |------|--------------------------------|------------------------------------------------------------------------------------------------------------------------|--------|------------------------------------------------| | DIFF | INT32 / INT64 / FLOAT / DOUBLE | `ignoreNull`:可选,默认为true;为true时,前一个数据点值为null时,忽略该数据点继续向前找到第一个出现的不为null的值;为false时,如果前一个数据点为null,则不忽略,使用null进行相减,结果也为null | DOUBLE | 统计序列中某数据点的值与前一数据点的值的差。第一个数据点没有对应的结果输出,输出值为null | -详细说明及示例见文档 [趋势计算函数](../SQL-Manual/Function-and-Expression.md#趋势计算函数)。 +详细说明及示例见文档 [趋势计算函数](../SQL-Manual/Function-and-Expression.md#_10-趋势计算函数)。 ### 2.10 采样函数 @@ -234,33 +234,25 @@ OR, |, || | EQUAL_SIZE_BUCKET_OUTLIER_SAMPLE | INT32 / INT64 / FLOAT / DOUBLE | `proportion`取值范围为`(0, 1]`,默认为`0.1`
`type`取值为`avg`或`stendis`或`cos`或`prenextdis`,默认为`avg`
`number`取值应大于0,默认`3`| INT32 / INT64 / FLOAT / DOUBLE | 返回符合采样比例和桶内采样个数的等分桶离群值采样 | | M4 | INT32 / INT64 / FLOAT / DOUBLE | 包含固定点数的窗口和滑动时间窗口使用不同的属性参数。包含固定点数的窗口使用属性`windowSize`和`slidingStep`。滑动时间窗口使用属性`timeInterval`、`slidingStep`、`displayWindowBegin`和`displayWindowEnd`。更多细节见下文。 | INT32 / INT64 / FLOAT / DOUBLE | 返回每个窗口内的第一个点(`first`)、最后一个点(`last`)、最小值点(`bottom`)、最大值点(`top`)。在一个窗口内的聚合点输出之前,M4会将它们按照时间戳递增排序并且去重。 | -详细说明及示例见文档 [采样函数](../SQL-Manual/Function-and-Expression.md#采样函数)。 +详细说明及示例见文档 [采样函数](../SQL-Manual/Function-and-Expression.md#_11-采样函数)。 ### 2.11 时间序列处理函数 | 函数名 | 输入序列类型 | 参数 | 输出序列类型 | 功能描述 | | ------------- | ------------------------------ | ---- | ------------------------ | -------------------------- | | CHANGE_POINTS | INT32 / INT64 / FLOAT / DOUBLE | / | 与输入序列的实际类型一致 | 去除输入序列中的连续相同值 | -详细说明及示例见文档 [时间序列处理](../SQL-Manual/Function-and-Expression.md#时间序列处理)。 +详细说明及示例见文档 [时间序列处理](../SQL-Manual/Function-and-Expression.md#_12-时间序列处理)。 -## 3 Lambda 表达式 - -| 函数名 | 可接收的输入序列类型 | 必要的属性参数 | 输出序列类型 | 功能类型 | -| ------ | ----------------------------------------------- | ------------------------------------------------------------ | ----------------------------------------------- | ---------------------------------------------- | -| JEXL | INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | `expr`是一个支持标准的一元或多元参数的lambda表达式,符合`x -> {...}`或`(x, y, z) -> {...}`的格式,例如`x -> {x * 2}`, `(x, y, z) -> {x + y * z}` | INT32 / INT64 / FLOAT / DOUBLE / TEXT / BOOLEAN | 返回将输入的时间序列通过lambda表达式变换的序列 | - -详细说明及示例见文档 [Lambda 表达式](../SQL-Manual/Function-and-Expression.md#Lambda表达式) - -## 4 条件表达式 +## 3. 条件表达式 | 表达式名称 | 含义 | |---------------------------|-----------| | `CASE` | 类似if else | -详细说明及示例见文档 [条件表达式](../SQL-Manual/Function-and-Expression.md#条件表达式) +详细说明及示例见文档 [条件表达式](../SQL-Manual/Function-and-Expression.md#_13-条件表达式) -## 5 SELECT 表达式 +## 4. SELECT 表达式 `SELECT` 子句指定查询的输出,由若干个 `selectExpr` 组成。 每个 `selectExpr` 定义了查询结果中的一列或多列。 @@ -296,7 +288,7 @@ select s1 as temperature, s2 as speed from root.ln.wf01.wt01; #### 运算符 -IoTDB 中支持的运算符列表见文档 [运算符和函数](../SQL-Manual/Function-and-Expression.md#算数运算符和函数)。 +IoTDB 中支持的运算符列表见文档 [运算符和函数](../SQL-Manual/Function-and-Expression.md#_2-算数运算符和函数)。 #### 函数 @@ -314,7 +306,7 @@ select sin(s1), count(s1) from root.sg.d1; select s1, count(s1) from root.sg.d1 group by ([10,100),10ms); ``` -IoTDB 支持的聚合函数见文档 [聚合函数](../SQL-Manual/Function-and-Expression.md#聚合函数)。 +IoTDB 支持的聚合函数见文档 [聚合函数](../SQL-Manual/Function-and-Expression.md#_1-聚合函数)。 ##### 时间序列生成函数 @@ -324,7 +316,7 @@ IoTDB 支持的聚合函数见文档 [聚合函数](../SQL-Manual/Function-and-E ###### 内置时间序列生成函数 -IoTDB 中支持的内置函数列表见文档 [运算符和函数](../SQL-Manual/Function-and-Expression.md#算数运算符)。 +IoTDB 中支持的内置函数列表见文档 [运算符和函数](../SQL-Manual/Function-and-Expression.md#_2-1-算数运算符)。 ###### 自定义时间序列生成函数 diff --git a/src/zh/UserGuide/latest/SQL-Manual/SQL-Manual_apache.md b/src/zh/UserGuide/latest/SQL-Manual/SQL-Manual_apache.md index a84b8ae08..64ae297f5 100644 --- a/src/zh/UserGuide/latest/SQL-Manual/SQL-Manual_apache.md +++ b/src/zh/UserGuide/latest/SQL-Manual/SQL-Manual_apache.md @@ -1036,7 +1036,7 @@ explain analyze select s1,s2 from root.sg.d1 order by s1 ### 6.1 算数运算符 -更多见文档 [Arithmetic Operators and Functions](./Operator-and-Expression.md#算数运算符) +更多见文档 [Arithmetic Operators and Functions](./Operator-and-Expression.md#_1-1-算数运算符) ```sql select s1, - s1, s2, + s2, s1 + s2, s1 - s2, s1 * s2, s1 / s2, s1 % s2 from root.sg.d1 @@ -1044,7 +1044,7 @@ select s1, - s1, s2, + s2, s1 + s2, s1 - s2, s1 * s2, s1 / s2, s1 % s2 from root ### 6.2 比较运算符 -更多见文档[Comparison Operators and Functions](./Operator-and-Expression.md#比较运算符) +更多见文档[Comparison Operators and Functions](./Operator-and-Expression.md#_1-2-比较运算符) ```sql # Basic comparison operators @@ -1075,7 +1075,7 @@ select a, a in (1, 2) from root.test; ### 6.3 逻辑运算符 -更多见文档[Logical Operators](./Operator-and-Expression.md#逻辑运算符) +更多见文档[Logical Operators](./Operator-and-Expression.md#_1-3-逻辑运算符) ```sql select a, b, a > 10, a <= b, !(a <= b), a > 10 && a > b from root.test; @@ -1083,11 +1083,11 @@ select a, b, a > 10, a <= b, !(a <= b), a > 10 && a > b from root.test; ## 7. 内置函数 -更多见文档[Operator-and-Expression](./Operator-and-Expression.md#聚合函数) +更多见文档[Operator-and-Expression](./Operator-and-Expression.md#_2-内置函数) ### 7.1 Aggregate Functions -更多见文档[Aggregate Functions](./Operator-and-Expression.md#聚合函数) +更多见文档[Aggregate Functions](./Operator-and-Expression.md#_2-1-聚合函数) ```sql select count(status) from root.ln.wf01.wt01; @@ -1100,7 +1100,7 @@ select time_duration(s1) from root.db.d1; ### 7.2 算数函数 -更多见文档[Arithmetic Operators and Functions](./Operator-and-Expression.md#数学函数) +更多见文档[Arithmetic Operators and Functions](./Operator-and-Expression.md#_2-2-数学函数) ```sql select s1, sin(s1), cos(s1), tan(s1) from root.sg1.d1 limit 5 offset 1000; @@ -1109,7 +1109,7 @@ select s4,round(s4),round(s4,2),round(s4,-1) from root.sg1.d1; ### 7.3 比较函数 -更多见文档[Comparison Operators and Functions](./Operator-and-Expression.md#比较函数) +更多见文档[Comparison Operators and Functions](./Operator-and-Expression.md#_2-3-比较函数) ```sql select ts, on_off(ts, 'threshold'='2') from root.test; @@ -1118,7 +1118,7 @@ select ts, in_range(ts, 'lower'='2', 'upper'='3.1') from root.test; ### 7.4 字符串处理函数 -更多见文档[String Processing](./Operator-and-Expression.md#字符串函数) +更多见文档[String Processing](./Operator-and-Expression.md#_2-4-字符串函数) ```sql select s1, string_contains(s1, 's'='warn') from root.sg1.d4; @@ -1146,7 +1146,7 @@ select regexsplit(s1, "regex"=",", "index"="3") from root.test.d1 ### 7.5 数据类型转换函数 -更多见文档[Data Type Conversion Function](./Operator-and-Expression.md#数据类型转换函数) +更多见文档[Data Type Conversion Function](./Operator-and-Expression.md#_2-5-数据类型转换函数) ```sql SELECT cast(s1 as INT32) from root.sg @@ -1154,7 +1154,7 @@ SELECT cast(s1 as INT32) from root.sg ### 7.6 常序列生成函数 -更多见文档[Constant Timeseries Generating Functions](./Operator-and-Expression.md#常序列生成函数) +更多见文档[Constant Timeseries Generating Functions](./Operator-and-Expression.md#_2-6-常序列生成函数) ```sql select s1, s2, const(s1, 'value'='1024', 'type'='INT64'), pi(s2), e(s1, s2) from root.sg1.d1; @@ -1162,7 +1162,7 @@ select s1, s2, const(s1, 'value'='1024', 'type'='INT64'), pi(s2), e(s1, s2) from ### 7.7 选择函数 -更多见文档[Selector Functions](./Operator-and-Expression.md#选择函数) +更多见文档[Selector Functions](./Operator-and-Expression.md#_2-7-选择函数) ```sql select s1, top_k(s1, 'k'='2'), bottom_k(s1, 'k'='2') from root.sg1.d2 where time > 2020-12-10T20:36:15.530+08:00; @@ -1170,7 +1170,7 @@ select s1, top_k(s1, 'k'='2'), bottom_k(s1, 'k'='2') from root.sg1.d2 where time ### 7.8 区间查询函数 -更多见文档[Continuous Interval Functions](./Operator-and-Expression.md#区间查询函数) +更多见文档[Continuous Interval Functions](./Operator-and-Expression.md#_2-8-区间查询函数) ```sql select s1, zero_count(s1), non_zero_count(s2), zero_duration(s3), non_zero_duration(s4) from root.sg.d2; @@ -1178,7 +1178,7 @@ select s1, zero_count(s1), non_zero_count(s2), zero_duration(s3), non_zero_durat ### 7.9 趋势计算函数 -更多见文档[Variation Trend Calculation Functions](./Operator-and-Expression.md#趋势计算函数) +更多见文档[Variation Trend Calculation Functions](./Operator-and-Expression.md#_2-9-趋势计算函数) ```sql select s1, time_difference(s1), difference(s1), non_negative_difference(s1), derivative(s1), non_negative_derivative(s1) from root.sg1.d1 limit 5 offset 1000; @@ -1189,10 +1189,7 @@ SELECT DIFF(s1, 'ignoreNull'='false'), DIFF(s2, 'ignoreNull'='false') from root. ### 7.10 采样函数 -更多见文档[Sample Functions](./Operator-and-Expression.md#采样函数)。 -### 7.11 时间序列处理函数 - -更多见文档[Sample Functions](./Operator-and-Expression.md#时间序列处理函数)。 +更多见文档[Sample Functions](./Operator-and-Expression.md#_2-10-采样函数)。 ```sql select equal_size_bucket_random_sample(temperature,'proportion'='0.1') as random_sample from root.ln.wf01.wt01; @@ -1204,9 +1201,9 @@ select M4(s1,'timeInterval'='25','displayWindowBegin'='0','displayWindowEnd'='10 select M4(s1,'windowSize'='10') from root.vehicle.d1 ``` -### 7.12 时间序列处理函数 +### 7.11 时间序列处理函数 -更多见文档[Time-Series](./Operator-and-Expression.md#时间序列处理函数) +更多见文档[Time-Series](./Operator-and-Expression.md#_2-11-时间序列处理函数) ```sql select change_points(s1), change_points(s2), change_points(s3), change_points(s4), change_points(s5), change_points(s6) from root.testChangePoints.d1 @@ -1462,17 +1459,9 @@ select representation(s0,"tb"="3","vb"="2") from root.test.d0 select rm(s0, s1,"tb"="3","vb"="2") from root.test.d0 ``` -## 9. Lambda 表达式 - -更多见文档[Lambda](./Operator-and-Expression.md#lambda-表达式) - -```sql -select jexl(temperature, 'expr'='x -> {x + x}') as jexl1, jexl(temperature, 'expr'='x -> {x * 3}') as jexl2, jexl(temperature, 'expr'='x -> {x * x}') as jexl3, jexl(temperature, 'expr'='x -> {multiply(x, 100)}') as jexl4, jexl(temperature, st, 'expr'='(x, y) -> {x + y}') as jexl5, jexl(temperature, st, str, 'expr'='(x, y, z) -> {x + y + z}') as jexl6 from root.ln.wf01.wt01;``` -``` - -## 10. 条件表达式 +## 9. 条件表达式 -更多见文档[Conditional Expressions](./Operator-and-Expression.md#条件表达式) +更多见文档[Conditional Expressions](./Operator-and-Expression.md#_3-条件表达式) ```sql select T, P, case @@ -1508,9 +1497,9 @@ end as `result` from root.test4 ``` -## 11. 触发器 +## 10. 触发器 -### 11.1 使用 SQL 语句注册该触发器 +### 10.1 使用 SQL 语句注册该触发器 ```sql // Create Trigger @@ -1588,7 +1577,7 @@ WITH ( ) ``` -### 11.2 卸载触发器 +### 10.2 卸载触发器 #### 卸载触发器的 SQL 语法如下: ```sql @@ -1604,13 +1593,13 @@ dropTrigger ```sql DROP TRIGGER triggerTest1 ``` -### 11.3 查询触发器 +### 10.3 查询触发器 ```sql SHOW TRIGGERS ``` -## 12. 连续查询(Continuous Query, CQ) +## 11. 连续查询(Continuous Query, CQ) -### 12.1 语法 +### 11.1 语法 ```sql CREATE (CONTINUOUS QUERY | CQ) diff --git a/src/zh/UserGuide/latest/SQL-Manual/SQL-Manual_timecho.md b/src/zh/UserGuide/latest/SQL-Manual/SQL-Manual_timecho.md index 256e2794d..86df95a41 100644 --- a/src/zh/UserGuide/latest/SQL-Manual/SQL-Manual_timecho.md +++ b/src/zh/UserGuide/latest/SQL-Manual/SQL-Manual_timecho.md @@ -961,7 +961,7 @@ explain analyze select s1,s2 from root.sg.d1 order by s1 ### 6.1 算数运算符 -更多见文档 [Arithmetic Operators and Functions](./Operator-and-Expression.md#算数运算符) +更多见文档 [Arithmetic Operators and Functions](./Operator-and-Expression.md#_1-1-算数运算符) ```sql select s1, - s1, s2, + s2, s1 + s2, s1 - s2, s1 * s2, s1 / s2, s1 % s2 from root.sg.d1 @@ -969,7 +969,7 @@ select s1, - s1, s2, + s2, s1 + s2, s1 - s2, s1 * s2, s1 / s2, s1 % s2 from root ### 6.2 比较运算符 -更多见文档[Comparison Operators and Functions](./Operator-and-Expression.md#比较运算符) +更多见文档[Comparison Operators and Functions](./Operator-and-Expression.md#_1-2-比较运算符) ```sql # Basic comparison operators @@ -1000,7 +1000,7 @@ select a, a in (1, 2) from root.test; ### 6.3 逻辑运算符 -更多见文档[Logical Operators](./Operator-and-Expression.md#逻辑运算符) +更多见文档[Logical Operators](./Operator-and-Expression.md#_1-3-逻辑运算符) ```sql select a, b, a > 10, a <= b, !(a <= b), a > 10 && a > b from root.test; @@ -1008,11 +1008,11 @@ select a, b, a > 10, a <= b, !(a <= b), a > 10 && a > b from root.test; ## 7. 内置函数 -更多见文档[Operator-and-Expression](./Operator-and-Expression.md#聚合函数) +更多见文档[Operator-and-Expression](./Operator-and-Expression.md#_2-内置函数) ### 7.1 Aggregate Functions -更多见文档[Aggregate Functions](./Operator-and-Expression.md#聚合函数) +更多见文档[Aggregate Functions](./Operator-and-Expression.md#_2-1-聚合函数) ```sql select count(status) from root.ln.wf01.wt01; @@ -1025,7 +1025,7 @@ select time_duration(s1) from root.db.d1; ### 7.2 算数函数 -更多见文档[Arithmetic Operators and Functions](./Operator-and-Expression.md#数学函数) +更多见文档[Arithmetic Operators and Functions](./Operator-and-Expression.md#_2-2-数学函数) ```sql select s1, sin(s1), cos(s1), tan(s1) from root.sg1.d1 limit 5 offset 1000; @@ -1034,7 +1034,7 @@ select s4,round(s4),round(s4,2),round(s4,-1) from root.sg1.d1; ### 7.3 比较函数 -更多见文档[Comparison Operators and Functions](./Operator-and-Expression.md#比较函数) +更多见文档[Comparison Operators and Functions](./Operator-and-Expression.md#_2-3-比较函数) ```sql select ts, on_off(ts, 'threshold'='2') from root.test; @@ -1043,7 +1043,7 @@ select ts, in_range(ts, 'lower'='2', 'upper'='3.1') from root.test; ### 7.4 字符串处理函数 -更多见文档[String Processing](./Operator-and-Expression.md#字符串函数) +更多见文档[String Processing](./Operator-and-Expression.md#_2-4-字符串函数) ```sql select s1, string_contains(s1, 's'='warn') from root.sg1.d4; @@ -1071,7 +1071,7 @@ select regexsplit(s1, "regex"=",", "index"="3") from root.test.d1 ### 7.5 数据类型转换函数 -更多见文档[Data Type Conversion Function](./Operator-and-Expression.md#数据类型转换函数) +更多见文档[Data Type Conversion Function](./Operator-and-Expression.md#_2-5-数据类型转换函数) ```sql SELECT cast(s1 as INT32) from root.sg @@ -1079,7 +1079,7 @@ SELECT cast(s1 as INT32) from root.sg ### 7.6 常序列生成函数 -更多见文档[Constant Timeseries Generating Functions](./Operator-and-Expression.md#常序列生成函数) +更多见文档[Constant Timeseries Generating Functions](./Operator-and-Expression.md#_2-6-常序列生成函数) ```sql select s1, s2, const(s1, 'value'='1024', 'type'='INT64'), pi(s2), e(s1, s2) from root.sg1.d1; @@ -1087,7 +1087,7 @@ select s1, s2, const(s1, 'value'='1024', 'type'='INT64'), pi(s2), e(s1, s2) from ### 7.7 选择函数 -更多见文档[Selector Functions](./Operator-and-Expression.md#选择函数) +更多见文档[Selector Functions](./Operator-and-Expression.md#_2-7-选择函数) ```sql select s1, top_k(s1, 'k'='2'), bottom_k(s1, 'k'='2') from root.sg1.d2 where time > 2020-12-10T20:36:15.530+08:00; @@ -1095,7 +1095,7 @@ select s1, top_k(s1, 'k'='2'), bottom_k(s1, 'k'='2') from root.sg1.d2 where time ### 7.8 区间查询函数 -更多见文档[Continuous Interval Functions](./Operator-and-Expression.md#区间查询函数) +更多见文档[Continuous Interval Functions](./Operator-and-Expression.md#_2-8-区间查询函数) ```sql select s1, zero_count(s1), non_zero_count(s2), zero_duration(s3), non_zero_duration(s4) from root.sg.d2; @@ -1103,7 +1103,7 @@ select s1, zero_count(s1), non_zero_count(s2), zero_duration(s3), non_zero_durat ### 7.9 趋势计算函数 -更多见文档[Variation Trend Calculation Functions](./Operator-and-Expression.md#趋势计算函数) +更多见文档[Variation Trend Calculation Functions](./Operator-and-Expression.md#_2-9-趋势计算函数) ```sql select s1, time_difference(s1), difference(s1), non_negative_difference(s1), derivative(s1), non_negative_derivative(s1) from root.sg1.d1 limit 5 offset 1000; @@ -1114,10 +1114,7 @@ SELECT DIFF(s1, 'ignoreNull'='false'), DIFF(s2, 'ignoreNull'='false') from root. ### 7.10 采样函数 -更多见文档[Sample Functions](./Operator-and-Expression.md#采样函数)。 -### 7.11 时间序列处理函数 - -更多见文档[Sample Functions](./Operator-and-Expression.md#时间序列处理函数)。 +更多见文档[Sample Functions](./Operator-and-Expression.md#_2-10-采样函数)。 ```sql select equal_size_bucket_random_sample(temperature,'proportion'='0.1') as random_sample from root.ln.wf01.wt01; @@ -1131,7 +1128,7 @@ select M4(s1,'windowSize'='10') from root.vehicle.d1 ### 7.12 时间序列处理函数 -更多见文档[Time-Series](./Operator-and-Expression.md#时间序列处理函数) +更多见文档[Time-Series](./Operator-and-Expression.md#_2-11-时间序列处理函数) ```sql select change_points(s1), change_points(s2), change_points(s3), change_points(s4), change_points(s5), change_points(s6) from root.testChangePoints.d1 @@ -1387,17 +1384,9 @@ select representation(s0,"tb"="3","vb"="2") from root.test.d0 select rm(s0, s1,"tb"="3","vb"="2") from root.test.d0 ``` -## 9. Lambda 表达式 - -更多见文档[Lambda](./Operator-and-Expression.md#lambda-表达式) - -```sql -select jexl(temperature, 'expr'='x -> {x + x}') as jexl1, jexl(temperature, 'expr'='x -> {x * 3}') as jexl2, jexl(temperature, 'expr'='x -> {x * x}') as jexl3, jexl(temperature, 'expr'='x -> {multiply(x, 100)}') as jexl4, jexl(temperature, st, 'expr'='(x, y) -> {x + y}') as jexl5, jexl(temperature, st, str, 'expr'='(x, y, z) -> {x + y + z}') as jexl6 from root.ln.wf01.wt01;``` -``` - -## 10. 条件表达式 +## 9. 条件表达式 -更多见文档[Conditional Expressions](./Operator-and-Expression.md#条件表达式) +更多见文档[Conditional Expressions](./Operator-and-Expression.md#_3-条件表达式) ```sql select T, P, case @@ -1433,9 +1422,9 @@ end as `result` from root.test4 ``` -## 11. 触发器 +## 10. 触发器 -### 11.1 使用 SQL 语句注册该触发器 +### 10.1 使用 SQL 语句注册该触发器 ```sql // Create Trigger @@ -1513,7 +1502,7 @@ WITH ( ) ``` -### 11.2 卸载触发器 +### 10.2 卸载触发器 #### 卸载触发器的 SQL 语法如下: ```sql @@ -1529,13 +1518,13 @@ dropTrigger ```sql DROP TRIGGER triggerTest1 ``` -### 11.3 查询触发器 +### 10.3 查询触发器 ```sql SHOW TRIGGERS ``` -## 12. 连续查询(Continuous Query, CQ) +## 11. 连续查询(Continuous Query, CQ) -### 12.1 语法 +### 11.1 语法 ```Go CREATE (CONTINUOUS QUERY | CQ)