diff --git a/docs/UserGuide/Operation Manual/Administration.md b/docs/UserGuide/Operation Manual/Administration.md
index 3e08f540cdaa..e8d0bceabd4d 100644
--- a/docs/UserGuide/Operation Manual/Administration.md
+++ b/docs/UserGuide/Operation Manual/Administration.md
@@ -62,7 +62,17 @@ LIST USER
```
As can be seen from the result shown below, the two users have been created:
-
+```
++---------------+
+| user|
++---------------+
+| ln_write_user|
+| root|
+|sgcc_write_user|
++---------------+
+Total line number = 3
+It costs 0.004s
+```
### Grant User Privilege
@@ -73,7 +83,9 @@ INSERT INTO root.ln.wf01.wt01(timestamp,status) values(1509465600000,true)
```
The SQL statement will not be executed and the corresponding error prompt is given as follows:
-
+```
+Msg: 602: No permissions for this operation INSERT
+```
Now, we grant the two users write privileges to the corresponding storage groups, and try to write data again. The SQL statement is:
@@ -83,7 +95,15 @@ GRANT USER sgcc_write_user PRIVILEGES 'INSERT_TIMESERIES' on root.sgcc
INSERT INTO root.ln.wf01.wt01(timestamp, status) values(1509465600000, true)
```
The execution result is as follows:
-
+
+```
+IoTDB> GRANT USER ln_write_user PRIVILEGES 'INSERT_TIMESERIES' on root.ln
+Msg: The statement is executed successfully.
+IoTDB> GRANT USER sgcc_write_user PRIVILEGES 'INSERT_TIMESERIES' on root.sgcc
+Msg: The statement is executed successfully.
+IoTDB> INSERT INTO root.ln.wf01.wt01(timestamp, status) values(1509465600000, true)
+Msg: The statement is executed successfully.
+```
## Other Instructions
diff --git a/docs/UserGuide/Operation Manual/DDL Data Definition Language.md b/docs/UserGuide/Operation Manual/DDL Data Definition Language.md
index f9c90d4ce27a..750363b2347b 100644
--- a/docs/UserGuide/Operation Manual/DDL Data Definition Language.md
+++ b/docs/UserGuide/Operation Manual/DDL Data Definition Language.md
@@ -41,7 +41,7 @@ Msg: org.apache.iotdb.exception.MetadataException: org.apache.iotdb.exception.Me
## Show Storage Group
-After the storage group is created, we can use the [SHOW STORAGE GROUP](../Operation%20Manual/SQL%20Reference.md) statement and [SHOW STORAGE GROUP \](../Operation%20Manual/SQL%20Reference.md) to view the storage groups. The SQL statements are as follows:
+After creating the storage group, we can use the [SHOW STORAGE GROUP](../Operation%20Manual/SQL%20Reference.md) statement and [SHOW STORAGE GROUP \](../Operation%20Manual/SQL%20Reference.md) to view the storage groups. The SQL statements are as follows:
```
IoTDB> show storage group
@@ -49,7 +49,17 @@ IoTDB> show storage group root.ln
```
The result is as follows:
-
+
+```
++-------------+
+|storage group|
++-------------+
+| root.sgcc|
+| root.ln|
++-------------+
+Total line number = 2
+It costs 0.060s
+```
## Delete Storage Group
@@ -111,7 +121,7 @@ ALTER timeseries root.turbine.d1.s1 RENAME tag1 TO newTag1
```
* reset the tag/attribute value
```
-ALTER timeseries root.turbine.d1.s1 SET tag1=newV1, attr1=newV1
+ALTER timeseries root.turbine.d1.s1 SET newTag1=newV1, attr1=newV1
```
* delete the existing tag/attribute
```
@@ -156,20 +166,63 @@ IoTDB> show timeseries root.ln
The results are shown below respectively:
-
-
+```
++-------------------------------+--------+-------------+--------+--------+-----------+-------------------------------------------+--------------------------------------------------------+
+| timeseries| alias|storage group|dataType|encoding|compression| tags| attributes|
++-------------------------------+--------+-------------+--------+--------+-----------+-------------------------------------------+--------------------------------------------------------+
+|root.sgcc.wf03.wt01.temperature| null| root.sgcc| FLOAT| RLE| SNAPPY| null| null|
+| root.sgcc.wf03.wt01.status| null| root.sgcc| BOOLEAN| PLAIN| SNAPPY| null| null|
+| root.turbine.d1.s1|newAlias| root.turbine| FLOAT| RLE| SNAPPY|{"newTag1":"newV1","tag4":"v4","tag3":"v3"}|{"attr2":"v2","attr1":"newV1","attr4":"v4","attr3":"v3"}|
+| root.ln.wf02.wt02.hardware| null| root.ln| TEXT| PLAIN| SNAPPY| null| null|
+| root.ln.wf02.wt02.status| null| root.ln| BOOLEAN| PLAIN| SNAPPY| null| null|
+| root.ln.wf01.wt01.temperature| null| root.ln| FLOAT| RLE| SNAPPY| null| null|
+| root.ln.wf01.wt01.status| null| root.ln| BOOLEAN| PLAIN| SNAPPY| null| null|
++-------------------------------+--------+-------------+--------+--------+-----------+-------------------------------------------+--------------------------------------------------------+
+Total line number = 7
+It costs 0.016s
+
++-----------------------------+-----+-------------+--------+--------+-----------+----+----------+
+| timeseries|alias|storage group|dataType|encoding|compression|tags|attributes|
++-----------------------------+-----+-------------+--------+--------+-----------+----+----------+
+| root.ln.wf02.wt02.hardware| null| root.ln| TEXT| PLAIN| SNAPPY|null| null|
+| root.ln.wf02.wt02.status| null| root.ln| BOOLEAN| PLAIN| SNAPPY|null| null|
+|root.ln.wf01.wt01.temperature| null| root.ln| FLOAT| RLE| SNAPPY|null| null|
+| root.ln.wf01.wt01.status| null| root.ln| BOOLEAN| PLAIN| SNAPPY|null| null|
++-----------------------------+-----+-------------+--------+--------+-----------+----+----------+
+Total line number = 4
+It costs 0.004s
+```
* SHOW TIMESERIES (<`PrefixPath`>)? WhereClause
returns all the timeseries information that satisfy the where condition and start with the prefixPath SQL statements are as follows:
```
+ALTER timeseries root.ln.wf02.wt02.hardware ADD TAGS unit=c
+ALTER timeseries root.ln.wf02.wt02.status ADD TAGS description=test1
show timeseries root.ln where unit=c
show timeseries root.ln where description contains 'test1'
```
The results are shown below respectly:
-
+
+```
++--------------------------+-----+-------------+--------+--------+-----------+------------+----------+
+| timeseries|alias|storage group|dataType|encoding|compression| tags|attributes|
++--------------------------+-----+-------------+--------+--------+-----------+------------+----------+
+|root.ln.wf02.wt02.hardware| null| root.ln| TEXT| PLAIN| SNAPPY|{"unit":"c"}| null|
++--------------------------+-----+-------------+--------+--------+-----------+------------+----------+
+Total line number = 1
+It costs 0.005s
+
++------------------------+-----+-------------+--------+--------+-----------+-----------------------+----------+
+| timeseries|alias|storage group|dataType|encoding|compression| tags|attributes|
++------------------------+-----+-------------+--------+--------+-----------+-----------------------+----------+
+|root.ln.wf02.wt02.status| null| root.ln| BOOLEAN| PLAIN| SNAPPY|{"description":"test1"}| null|
++------------------------+-----+-------------+--------+--------+-----------+-----------------------+----------+
+Total line number = 1
+It costs 0.004s
+```
> Notice that, we only support one condition in the where clause. Either it's an equal filter or it is an `contains` filter. In both case, the property in the where condition must be a tag.
@@ -202,18 +255,11 @@ Example:
|root.ln.wf01|
|root.ln.wf02|
+------------+
+Total line number = 2
+It costs 0.002s
```
-* get all paths in form of root.xx.xx.xx:show child paths root.\*.\*
-
-```
-+---------------+
-| child paths|
-+---------------+
-|root.ln.wf01.s1|
-|root.ln.wf02.s2|
-+---------------+
-```
+> get all paths in form of root.xx.xx.xx:show child paths root.xx.xx
## Count Timeseries
@@ -229,9 +275,25 @@ IoTDB > COUNT TIMESERIES root.ln.wf01.wt01.status
Besides, `LEVEL` could be defined to show count the number of timeseries of each node at the given level in current Metadata Tree. This could be used to query the number of sensors under each device. The grammar is: `COUNT TIMESERIES GROUP BY LEVEL=`.
For example, if there are several timeseries (use `show timeseries` to show all timeseries):
-
+
+```
++-------------------------------+--------+-------------+--------+--------+-----------+-------------------------------------------+--------------------------------------------------------+
+| timeseries| alias|storage group|dataType|encoding|compression| tags| attributes|
++-------------------------------+--------+-------------+--------+--------+-----------+-------------------------------------------+--------------------------------------------------------+
+|root.sgcc.wf03.wt01.temperature| null| root.sgcc| FLOAT| RLE| SNAPPY| null| null|
+| root.sgcc.wf03.wt01.status| null| root.sgcc| BOOLEAN| PLAIN| SNAPPY| null| null|
+| root.turbine.d1.s1|newAlias| root.turbine| FLOAT| RLE| SNAPPY|{"newTag1":"newV1","tag4":"v4","tag3":"v3"}|{"attr2":"v2","attr1":"newV1","attr4":"v4","attr3":"v3"}|
+| root.ln.wf02.wt02.hardware| null| root.ln| TEXT| PLAIN| SNAPPY| {"unit":"c"}| null|
+| root.ln.wf02.wt02.status| null| root.ln| BOOLEAN| PLAIN| SNAPPY| {"description":"test1"}| null|
+| root.ln.wf01.wt01.temperature| null| root.ln| FLOAT| RLE| SNAPPY| null| null|
+| root.ln.wf01.wt01.status| null| root.ln| BOOLEAN| PLAIN| SNAPPY| null| null|
++-------------------------------+--------+-------------+--------+--------+-----------+-------------------------------------------+--------------------------------------------------------+
+Total line number = 7
+It costs 0.004s
+```
Then the Metadata Tree will be as below:
+
As can be seen, `root` is considered as `LEVEL=0`. So when you enter statements such as:
@@ -244,7 +306,34 @@ IoTDB > COUNT TIMESERIES root.ln.wf01 GROUP BY LEVEL=2
You will get following results:
-
+```
++------------+-----+
+| column|count|
++------------+-----+
+| root.sgcc| 2|
+|root.turbine| 1|
+| root.ln| 4|
++------------+-----+
+Total line number = 3
+It costs 0.002s
+
++------------+-----+
+| column|count|
++------------+-----+
+|root.ln.wf02| 2|
+|root.ln.wf01| 2|
++------------+-----+
+Total line number = 2
+It costs 0.002s
+
++------------+-----+
+| column|count|
++------------+-----+
+|root.ln.wf01| 2|
++------------+-----+
+Total line number = 1
+It costs 0.002s
+```
> Note: The path of timeseries is just a filter condition, which has no relationship with the definition of level.
@@ -260,7 +349,31 @@ IoTDB > COUNT NODES root.ln.wf01 LEVEL=3
As for the above mentioned example and Metadata tree, you can get following results:
-
+```
++-----+
+|count|
++-----+
+| 4|
++-----+
+Total line number = 1
+It costs 0.003s
+
++-----+
+|count|
++-----+
+| 2|
++-----+
+Total line number = 1
+It costs 0.002s
+
++-----+
+|count|
++-----+
+| 1|
++-----+
+Total line number = 1
+It costs 0.002s
+```
> Note: The path of timeseries is just a filter condition, which has no relationship with the definition of level.
`PrefixPath` could contains `*`, but all nodes after `*` would be ignored. Only the prefix path before `*` is valid.
@@ -291,6 +404,30 @@ IoTDB> show devices
IoTDB> show devices root.ln
```
+You can get results below:
+
+```
++-------------------+
+| devices|
++-------------------+
+| root.ln.wf01.wt01|
+| root.ln.wf02.wt02|
+|root.sgcc.wf03.wt01|
+| root.turbine.d1|
++-------------------+
+Total line number = 4
+It costs 0.002s
+
++-----------------+
+| devices|
++-----------------+
+|root.ln.wf01.wt01|
+|root.ln.wf02.wt02|
++-----------------+
+Total line number = 2
+It costs 0.001s
+```
+
# TTL
IoTDB supports storage-level TTL settings, which means it is able to delete old data automatically and periodically. The benefit of using TTL is that hopefully you can control the total disk space usage and prevent the machine from running out of disks. Moreover, the query performance may downgrade as the total number of files goes up and the memory usage also increase as there are more files. Timely removing such files helps to keep at a high query performance level and reduce memory usage.
@@ -317,7 +454,7 @@ After unset TTL, all data will be accepted in `root.ln`
## Show TTL
-To Show TTL, we can use follwing SQL statement:
+To Show TTL, we can use following SQL statement:
```
IoTDB> SHOW ALL TTL
diff --git a/docs/UserGuide/Operation Manual/DML Data Manipulation Language.md b/docs/UserGuide/Operation Manual/DML Data Manipulation Language.md
index 994f4e920781..6e5543314964 100644
--- a/docs/UserGuide/Operation Manual/DML Data Manipulation Language.md
+++ b/docs/UserGuide/Operation Manual/DML Data Manipulation Language.md
@@ -57,29 +57,15 @@ IoTDB > select * from root.ln.wf02 where time < 3
The result is shown below. The query result shows that the insertion statements of single column and multi column data are performed correctly.
-
-
-### Error Handling of INSERT Statements
-If the user inserts data into a non-existent timeseries, for example, execute the following commands:
-
-```
-IoTDB > insert into root.ln.wf02.wt02(timestamp, temperature) values(1,"v1")
-```
-
-Because `root.ln.wf02.wt02. temperature` does not exist, the system will return the following ERROR information:
-
-```
-Msg: The resultDataType or encoding or compression of the last node temperature is conflicting in the storage group root.ln
```
-If the data type inserted by the user is inconsistent with the corresponding data type of the timeseries, for example, execute the following command:
-
-```
-IoTDB > insert into root.ln.wf02.wt02(timestamp,hardware) values(1,100)
-```
-The system will return the following ERROR information:
-
-```
-error: The TEXT data type should be covered by " or '
++-----------------------------+--------------------------+------------------------+
+| Time|root.ln.wf02.wt02.hardware|root.ln.wf02.wt02.status|
++-----------------------------+--------------------------+------------------------+
+|1970-01-01T08:00:00.001+08:00| v1| true|
+|1970-01-01T08:00:00.002+08:00| v2| false|
++-----------------------------+--------------------------+------------------------+
+Total line number = 2
+It costs 0.170s
```
## SELECT
@@ -101,7 +87,22 @@ The selected device is ln group wf01 plant wt01 device; the selected timeseries
The execution result of this SQL statement is as follows:
-
+```
++-----------------------------+-----------------------------+
+| Time|root.ln.wf01.wt01.temperature|
++-----------------------------+-----------------------------+
+|2017-11-01T00:00:00.000+08:00| 25.96|
+|2017-11-01T00:01:00.000+08:00| 24.36|
+|2017-11-01T00:02:00.000+08:00| 20.09|
+|2017-11-01T00:03:00.000+08:00| 20.18|
+|2017-11-01T00:04:00.000+08:00| 21.13|
+|2017-11-01T00:05:00.000+08:00| 22.72|
+|2017-11-01T00:06:00.000+08:00| 20.71|
+|2017-11-01T00:07:00.000+08:00| 21.45|
++-----------------------------+-----------------------------+
+Total line number = 8
+It costs 0.026s
+```
#### Select Multiple Columns of Data Based on a Time Interval
@@ -115,7 +116,21 @@ which means:
The selected device is ln group wf01 plant wt01 device; the selected timeseries is "status" and "temperature". The SQL statement requires that the status and temperature sensor values between the time point of "2017-11-01T00:05:00.000" and "2017-11-01T00:12:00.000" be selected.
The execution result of this SQL statement is as follows:
-
+
+```
++-----------------------------+------------------------+-----------------------------+
+| Time|root.ln.wf01.wt01.status|root.ln.wf01.wt01.temperature|
++-----------------------------+------------------------+-----------------------------+
+|2017-11-01T00:06:00.000+08:00| false| 20.71|
+|2017-11-01T00:07:00.000+08:00| false| 21.45|
+|2017-11-01T00:08:00.000+08:00| false| 22.58|
+|2017-11-01T00:09:00.000+08:00| false| 20.98|
+|2017-11-01T00:10:00.000+08:00| true| 25.52|
+|2017-11-01T00:11:00.000+08:00| false| 22.91|
++-----------------------------+------------------------+-----------------------------+
+Total line number = 6
+It costs 0.018s
+```
#### Select Multiple Columns of Data for the Same Device According to Multiple Time Intervals
@@ -129,7 +144,23 @@ which means:
The selected device is ln group wf01 plant wt01 device; the selected timeseries is "status" and "temperature"; the statement specifies two different time intervals, namely "2017-11-01T00:05:00.000 to 2017-11-01T00:12:00.000" and "2017-11-01T16:35:00.000 to 2017-11-01T16:37:00.000". The SQL statement requires that the values of selected timeseries satisfying any time interval be selected.
The execution result of this SQL statement is as follows:
-
+```
++-----------------------------+------------------------+-----------------------------+
+| Time|root.ln.wf01.wt01.status|root.ln.wf01.wt01.temperature|
++-----------------------------+------------------------+-----------------------------+
+|2017-11-01T00:06:00.000+08:00| false| 20.71|
+|2017-11-01T00:07:00.000+08:00| false| 21.45|
+|2017-11-01T00:08:00.000+08:00| false| 22.58|
+|2017-11-01T00:09:00.000+08:00| false| 20.98|
+|2017-11-01T00:10:00.000+08:00| true| 25.52|
+|2017-11-01T00:11:00.000+08:00| false| 22.91|
+|2017-11-01T16:35:00.000+08:00| true| 23.44|
+|2017-11-01T16:36:00.000+08:00| false| 21.98|
+|2017-11-01T16:37:00.000+08:00| false| 21.93|
++-----------------------------+------------------------+-----------------------------+
+Total line number = 9
+It costs 0.018s
+```
#### Choose Multiple Columns of Data for Different Devices According to Multiple Time Intervals
@@ -144,8 +175,24 @@ which means:
The selected timeseries are "the power supply status of ln group wf01 plant wt01 device" and "the hardware version of ln group wf02 plant wt02 device"; the statement specifies two different time intervals, namely "2017-11-01T00:05:00.000 to 2017-11-01T00:12:00.000" and "2017-11-01T16:35:00.000 to 2017-11-01T16:37:00.000". The SQL statement requires that the values of selected timeseries satisfying any time interval be selected.
The execution result of this SQL statement is as follows:
-
+```
++-----------------------------+------------------------+--------------------------+
+| Time|root.ln.wf01.wt01.status|root.ln.wf02.wt02.hardware|
++-----------------------------+------------------------+--------------------------+
+|2017-11-01T00:06:00.000+08:00| false| v1|
+|2017-11-01T00:07:00.000+08:00| false| v1|
+|2017-11-01T00:08:00.000+08:00| false| v1|
+|2017-11-01T00:09:00.000+08:00| false| v1|
+|2017-11-01T00:10:00.000+08:00| true| v2|
+|2017-11-01T00:11:00.000+08:00| false| v1|
+|2017-11-01T16:35:00.000+08:00| true| v2|
+|2017-11-01T16:36:00.000+08:00| false| v1|
+|2017-11-01T16:37:00.000+08:00| false| v1|
++-----------------------------+------------------------+--------------------------+
+Total line number = 9
+It costs 0.014s
+```
#### Order By Time Query
IoTDB supports the 'order by time' statement since 0.11, it's used to display results in descending order by time.
@@ -154,6 +201,26 @@ For example, the SQL statement is:
```sql
select * from root.ln where time > 1 order by time desc limit 10;
```
+The execution result of this SQL statement is as follows:
+
+```
++-----------------------------+--------------------------+------------------------+-----------------------------+------------------------+
+| Time|root.ln.wf02.wt02.hardware|root.ln.wf02.wt02.status|root.ln.wf01.wt01.temperature|root.ln.wf01.wt01.status|
++-----------------------------+--------------------------+------------------------+-----------------------------+------------------------+
+|2017-11-07T23:59:00.000+08:00| v1| false| 21.07| false|
+|2017-11-07T23:58:00.000+08:00| v1| false| 22.93| false|
+|2017-11-07T23:57:00.000+08:00| v2| true| 24.39| true|
+|2017-11-07T23:56:00.000+08:00| v2| true| 24.44| true|
+|2017-11-07T23:55:00.000+08:00| v2| true| 25.9| true|
+|2017-11-07T23:54:00.000+08:00| v1| false| 22.52| false|
+|2017-11-07T23:53:00.000+08:00| v2| true| 24.58| true|
+|2017-11-07T23:52:00.000+08:00| v1| false| 20.18| false|
+|2017-11-07T23:51:00.000+08:00| v1| false| 22.24| false|
+|2017-11-07T23:50:00.000+08:00| v2| true| 23.7| true|
++-----------------------------+--------------------------+------------------------+-----------------------------+------------------------+
+Total line number = 10
+It costs 0.016s
+```
### Aggregate Query
This section mainly introduces the related examples of aggregate query.
@@ -163,11 +230,17 @@ This section mainly introduces the related examples of aggregate query.
```
select count(status) from root.ln.wf01.wt01;
```
+Result:
-| count(root.ln.wf01.wt01.status) |
-| -------------- |
-| 4 |
-
+```
++-------------------------------+
+|count(root.ln.wf01.wt01.status)|
++-------------------------------+
+| 10080|
++-------------------------------+
+Total line number = 1
+It costs 0.016s
+```
##### Aggregation By Level
@@ -182,9 +255,15 @@ select count(status) from root.ln.wf01.* group by level=2
```
Result:
-| count(root.ln.wf01.*.status) |
-| ---------------------------- |
-| 7 |
+```
++----------------------------+
+|COUNT(root.ln.wf01.*.status)|
++----------------------------+
+| 10080|
++----------------------------+
+Total line number = 1
+It costs 0.003s
+```
Assuming another timeseries is added, called "root.ln.wf02.wt01.status".
@@ -194,9 +273,15 @@ select count(status) from root.ln.*.* group by level=2
```
Result:
-| count(root.ln.wf01.*.status) | count(root.ln.wf02.*.status) |
-| ---------------------------- | ---------------------------- |
-| 7 | 4
+```
++----------------------------+----------------------------+
+|COUNT(root.ln.wf01.*.status)|COUNT(root.ln.wf02.*.status)|
++----------------------------+----------------------------+
+| 10080| 10082|
++----------------------------+----------------------------+
+Total line number = 1
+It costs 0.003s
+```
All supported aggregation functions are: count, sum, avg, last_value, first_value, min_time, max_time, min_value, max_value.
When using four aggregations: sum, avg, min_value and max_value, please make sure all the aggregated series have exactly the same data type.
@@ -247,7 +332,21 @@ Then the system will use the time and value filtering condition in the WHERE cla
Since there is data for each time period in the result range to be displayed, the execution result of the SQL statement is shown below:
-
+```
++-----------------------------+-------------------------------+----------------------------------------+
+| Time|count(root.ln.wf01.wt01.status)|max_value(root.ln.wf01.wt01.temperature)|
++-----------------------------+-------------------------------+----------------------------------------+
+|2017-11-01T00:00:00.000+08:00| 1440| 26.0|
+|2017-11-02T00:00:00.000+08:00| 1440| 26.0|
+|2017-11-03T00:00:00.000+08:00| 1440| 25.99|
+|2017-11-04T00:00:00.000+08:00| 1440| 26.0|
+|2017-11-05T00:00:00.000+08:00| 1440| 26.0|
+|2017-11-06T00:00:00.000+08:00| 1440| 25.99|
+|2017-11-07T00:00:00.000+08:00| 1380| 26.0|
++-----------------------------+-------------------------------+----------------------------------------+
+Total line number = 7
+It costs 0.024s
+```
#### Down-Frequency Aggregate Query Specifying the Sliding Step Length
@@ -273,7 +372,21 @@ Then the system will use the time and value filtering condition in the WHERE cla
Since there is data for each time period in the result range to be displayed, the execution result of the SQL statement is shown below:
-
+```
++-----------------------------+-------------------------------+----------------------------------------+
+| Time|count(root.ln.wf01.wt01.status)|max_value(root.ln.wf01.wt01.temperature)|
++-----------------------------+-------------------------------+----------------------------------------+
+|2017-11-01T00:00:00.000+08:00| 180| 25.98|
+|2017-11-02T00:00:00.000+08:00| 180| 25.98|
+|2017-11-03T00:00:00.000+08:00| 180| 25.96|
+|2017-11-04T00:00:00.000+08:00| 180| 25.96|
+|2017-11-05T00:00:00.000+08:00| 180| 26.0|
+|2017-11-06T00:00:00.000+08:00| 180| 25.85|
+|2017-11-07T00:00:00.000+08:00| 180| 25.99|
++-----------------------------+-------------------------------+----------------------------------------+
+Total line number = 7
+It costs 0.006s
+```
#### Down-Frequency Aggregate Query Specifying the value Filtering Conditions
@@ -294,29 +407,49 @@ The third parameter of the GROUP BY statement above is the sliding step for each
Then the system will use the time and value filtering condition in the WHERE clause and the first parameter of the GROUP BY statement as the data filtering condition to obtain the data satisfying the filtering condition (which in this case is the data in the range of (2017-11-01T01:00:00, 2017-11-07T23:00:00] and satisfying root.ln.wf01.wt01.temperature > 20), and map these data to the previously segmented time axis (in this case there are mapped data in every 3-hour period for each day from 2017-11-01T00:00:00 to 2017-11-07T23:00:00).
-
+```
++-----------------------------+-------------------------------+----------------------------------------+
+| Time|count(root.ln.wf01.wt01.status)|max_value(root.ln.wf01.wt01.temperature)|
++-----------------------------+-------------------------------+----------------------------------------+
+|2017-11-01T00:00:00.000+08:00| 119| 25.98|
+|2017-11-02T00:00:00.000+08:00| 179| 25.98|
+|2017-11-03T00:00:00.000+08:00| 180| 25.96|
+|2017-11-04T00:00:00.000+08:00| 180| 25.96|
+|2017-11-05T00:00:00.000+08:00| 180| 26.0|
+|2017-11-06T00:00:00.000+08:00| 180| 25.85|
+|2017-11-07T00:00:00.000+08:00| 180| 25.99|
++-----------------------------+-------------------------------+----------------------------------------+
+Total line number = 7
+It costs 0.018s
+```
#### Left Open And Right Close Range
The SQL statement is:
```
-select count(status) from root.ln.wf01.wt01 group by((5, 40], 5ms);
+select count(status) from root.ln.wf01.wt01 group by ((2017-11-01T00:00:00, 2017-11-07T23:00:00],1d);
```
-In this sql, the time interval is left open and right close, so we won't include the value of timestamp 5 and instead we will include the value of timestamp 40.
+In this sql, the time interval is left open and right close, so we won't include the value of timestamp 2017-11-01T00:00:00 and instead we will include the value of timestamp 2017-11-07T23:00:00.
We will get the result like following:
-| Time | count(root.ln.wf01.wt01.status) |
-| ------ | ------------------------------- |
-| 10 | 1 |
-| 15 | 2 |
-| 20 | 3 |
-| 25 | 4 |
-| 30 | 4 |
-| 35 | 3 |
-| 40 | 5 |
+```
++-----------------------------+-------------------------------+
+| Time|count(root.ln.wf01.wt01.status)|
++-----------------------------+-------------------------------+
+|2017-11-02T00:00:00.000+08:00| 1440|
+|2017-11-03T00:00:00.000+08:00| 1440|
+|2017-11-04T00:00:00.000+08:00| 1440|
+|2017-11-05T00:00:00.000+08:00| 1440|
+|2017-11-06T00:00:00.000+08:00| 1440|
+|2017-11-07T00:00:00.000+08:00| 1440|
+|2017-11-07T23:00:00.000+08:00| 1380|
++-----------------------------+-------------------------------+
+Total line number = 7
+It costs 0.004s
+```
#### Down-Frequency Aggregate Query with Level Clause
@@ -330,36 +463,49 @@ The SQL statement is:
Get down-frequency aggregate query by level.
```
-select count(status) from root.ln.wf01.wt01 group by ([0,20),3ms), level=1;
+select count(status) from root.ln.wf01.wt01 group by ((2017-11-01T00:00:00, 2017-11-07T23:00:00],1d), level=1;
```
+Result:
-
-| Time | count(root.ln) |
-| ------ | -------------- |
-| 0 | 1 |
-| 3 | 0 |
-| 6 | 0 |
-| 9 | 1 |
-| 12 | 3 |
-| 15 | 0 |
-| 18 | 0 |
+```
++-----------------------------+-------------------------+
+| Time|COUNT(root.ln.*.*.status)|
++-----------------------------+-------------------------+
+|2017-11-02T00:00:00.000+08:00| 1440|
+|2017-11-03T00:00:00.000+08:00| 1440|
+|2017-11-04T00:00:00.000+08:00| 1440|
+|2017-11-05T00:00:00.000+08:00| 1440|
+|2017-11-06T00:00:00.000+08:00| 1440|
+|2017-11-07T00:00:00.000+08:00| 1440|
+|2017-11-07T23:00:00.000+08:00| 1380|
++-----------------------------+-------------------------+
+Total line number = 7
+It costs 0.006s
+```
Down-frequency aggregate query with sliding step and by level.
```
-select count(status) from root.ln.wf01.wt01 group by ([0,20),2ms,3ms), level=1;
+select count(status) from root.ln.wf01.wt01 group by ([2017-11-01 00:00:00, 2017-11-07 23:00:00), 3h, 1d), level=1;
```
+Result:
-| Time | count(root.ln) |
-| ------ | -------------- |
-| 0 | 1 |
-| 3 | 0 |
-| 6 | 0 |
-| 9 | 0 |
-| 12 | 2 |
-| 15 | 0 |
-| 18 | 0 |
+```
++-----------------------------+-------------------------+
+| Time|COUNT(root.ln.*.*.status)|
++-----------------------------+-------------------------+
+|2017-11-01T00:00:00.000+08:00| 180|
+|2017-11-02T00:00:00.000+08:00| 180|
+|2017-11-03T00:00:00.000+08:00| 180|
+|2017-11-04T00:00:00.000+08:00| 180|
+|2017-11-05T00:00:00.000+08:00| 180|
+|2017-11-06T00:00:00.000+08:00| 180|
+|2017-11-07T00:00:00.000+08:00| 180|
++-----------------------------+-------------------------+
+Total line number = 7
+It costs 0.004s
+```
#### Down-Frequency Aggregate Query with Fill Clause
@@ -375,21 +521,79 @@ Linear fill is not supported in group by fill.
* PREVIOUS will fill any null value as long as there exist value is not null before it.
* PREVIOUSUNTILLAST won't fill the result whose time is after the last time of that time series.
-The SQL statement is:
-
-```
-SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([8, 39), 5m) FILL (int32[PREVIOUSUNTILLAST])
-SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([8, 39), 5m) FILL (int32[PREVIOUSUNTILLAST, 3m])
+first, we check value root.ln.wf01.wt01.temperature when time after 2017-11-07T23:50:00.
+
+```
+IoTDB> SELECT temperature FROM root.ln.wf01.wt01 where time >= 2017-11-07T23:50:00
++-----------------------------+-----------------------------+
+| Time|root.ln.wf01.wt01.temperature|
++-----------------------------+-----------------------------+
+|2017-11-07T23:50:00.000+08:00| 23.7|
+|2017-11-07T23:51:00.000+08:00| 22.24|
+|2017-11-07T23:52:00.000+08:00| 20.18|
+|2017-11-07T23:53:00.000+08:00| 24.58|
+|2017-11-07T23:54:00.000+08:00| 22.52|
+|2017-11-07T23:55:00.000+08:00| 25.9|
+|2017-11-07T23:56:00.000+08:00| 24.44|
+|2017-11-07T23:57:00.000+08:00| 24.39|
+|2017-11-07T23:58:00.000+08:00| 22.93|
+|2017-11-07T23:59:00.000+08:00| 21.07|
++-----------------------------+-----------------------------+
+Total line number = 10
+It costs 0.002s
+```
+
+we will find the last time and value of root.ln.wf01.wt01.temperature are 2017-11-07T23:59:00 and 21.07 respectively.
+
+Then execute SQL statements:
+
+```
+SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-08T00:01:00),1m) FILL (float[PREVIOUSUNTILLAST]);
+SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-08T00:01:00),1m) FILL (float[PREVIOUS]);
+```
+
+result:
+```
++-----------------------------+-----------------------------------------+
+| Time|last_value(root.ln.wf01.wt01.temperature)|
++-----------------------------+-----------------------------------------+
+|2017-11-07T23:50:00.000+08:00| 23.7|
+|2017-11-07T23:51:00.000+08:00| 22.24|
+|2017-11-07T23:52:00.000+08:00| 20.18|
+|2017-11-07T23:53:00.000+08:00| 24.58|
+|2017-11-07T23:54:00.000+08:00| 22.52|
+|2017-11-07T23:55:00.000+08:00| 25.9|
+|2017-11-07T23:56:00.000+08:00| 24.44|
+|2017-11-07T23:57:00.000+08:00| 24.39|
+|2017-11-07T23:58:00.000+08:00| 22.93|
+|2017-11-07T23:59:00.000+08:00| 21.07|
+|2017-11-08T00:00:00.000+08:00| null|
++-----------------------------+-----------------------------------------+
+Total line number = 11
+It costs 0.005s
+
++-----------------------------+-----------------------------------------+
+| Time|last_value(root.ln.wf01.wt01.temperature)|
++-----------------------------+-----------------------------------------+
+|2017-11-07T23:50:00.000+08:00| 23.7|
+|2017-11-07T23:51:00.000+08:00| 22.24|
+|2017-11-07T23:52:00.000+08:00| 20.18|
+|2017-11-07T23:53:00.000+08:00| 24.58|
+|2017-11-07T23:54:00.000+08:00| 22.52|
+|2017-11-07T23:55:00.000+08:00| 25.9|
+|2017-11-07T23:56:00.000+08:00| 24.44|
+|2017-11-07T23:57:00.000+08:00| 24.39|
+|2017-11-07T23:58:00.000+08:00| 22.93|
+|2017-11-07T23:59:00.000+08:00| 21.07|
+|2017-11-08T00:00:00.000+08:00| 21.07|
++-----------------------------+-----------------------------------------+
+Total line number = 11
+It costs 0.006s
```
-which means:
-
-using PREVIOUSUNTILLAST Fill way to fill the origin down-frequency aggregate query result.
+which means:
-
-The path after SELECT in GROUP BY statement must be aggregate function, otherwise the system will give the corresponding error prompt, as shown below:
-
-
+using PREVIOUSUNTILLAST won't fill time after 2017-11-07T23:59.
### Last point Query
@@ -413,27 +617,32 @@ The result will be returned in a three column table format.
| Time | Path | Value |
```
-Example 1: get the last point of root.ln.wf01.wt01.speed:
+Example 1: get the last point of root.ln.wf01.wt01.status:
```
-> select last speed from root.ln.wf01.wt01
-
-| Time | Path | Value |
-| --- | ----------------------- | ----- |
-| 5 | root.ln.wf01.wt01.speed | 100 |
+IoTDB> select last status from root.ln.wf01.wt01
++-----------------------------+------------------------+-----+
+| Time| timeseries|value|
++-----------------------------+------------------------+-----+
+|2017-11-07T23:59:00.000+08:00|root.ln.wf01.wt01.status|false|
++-----------------------------+------------------------+-----+
+Total line number = 1
+It costs 0.000s
```
-Example 2: get the last speed, status and temperature points of root.ln.wf01.wt01,
-whose timestamp larger or equal to 5.
+Example 2: get the last status and temperature points of root.ln.wf01.wt01,
+whose timestamp larger or equal to 2017-11-07T23:50:00。
```
-> select last speed, status, temperature from root.ln.wf01.wt01 where time >= 5
-
-| Time | Path | Value |
-| --- | ---------------------------- | ----- |
-| 5 | root.ln.wf01.wt01.speed | 100 |
-| 7 | root.ln.wf01.wt01.status | true |
-| 9 | root.ln.wf01.wt01.temperature| 35.7 |
+IoTDB> select last status, temperature from root.ln.wf01.wt01 where time >= 2017-11-07T23:50:00
++-----------------------------+-----------------------------+---------+
+| Time| timeseries| value|
++-----------------------------+-----------------------------+---------+
+|2017-11-07T23:59:00.000+08:00| root.ln.wf01.wt01.status| false|
+|2017-11-07T23:59:00.000+08:00|root.ln.wf01.wt01.temperature|21.067368|
++-----------------------------+-----------------------------+---------+
+Total line number = 2
+It costs 0.002s
```
@@ -470,17 +679,36 @@ Detailed descriptions of all parameters are given in Table 3-4.
Here we give an example of filling null values using the previous method. The SQL statement is as follows:
```
-select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(float[previous, 1m])
+select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(float[previous, 1s])
```
which means:
Because the timeseries root.sgcc.wf03.wt01.temperature is null at 2017-11-01T16:37:50.000, the system uses the previous timestamp 2017-11-01T16:37:00.000 (and the timestamp is in the [2017-11-01T16:36:50.000, 2017-11-01T16:37:50.000] time range) for fill and display.
On the [sample data](https://github.com/thulab/iotdb/files/4438687/OtherMaterial-Sample.Data.txt), the execution result of this statement is shown below:
-
+
+```
++-----------------------------+-------------------------------+
+| Time|root.sgcc.wf03.wt01.temperature|
++-----------------------------+-------------------------------+
+|2017-11-01T16:37:50.000+08:00| 21.93|
++-----------------------------+-------------------------------+
+Total line number = 1
+It costs 0.016s
+```
It is worth noting that if there is no value in the specified valid time range, the system will not fill the null value, as shown below:
-
+
+```
+IoTDB> select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(float[previous, 1s])
++-----------------------------+-------------------------------+
+| Time|root.sgcc.wf03.wt01.temperature|
++-----------------------------+-------------------------------+
+|2017-11-01T16:37:50.000+08:00| null|
++-----------------------------+-------------------------------+
+Total line number = 1
+It costs 0.004s
+```
* Linear Method
@@ -514,7 +742,16 @@ which means:
Because the timeseries root.sgcc.wf03.wt01.temperature is null at 2017-11-01T16:37:50.000, the system uses the previous timestamp 2017-11-01T16:37:00.000 (and the timestamp is in the [2017-11-01T16:36:50.000, 2017-11-01T16:37:50.000] time range) and its value 21.927326, the next timestamp 2017-11-01T16:38:00.000 (and the timestamp is in the [2017-11-01T16:37:50.000, 2017-11-01T16:38:50.000] time range) and its value 25.311783 to perform linear fitting calculation: 21.927326 + (25.311783-21.927326)/60s * 50s = 24.747707
On the [sample data](https://github.com/thulab/iotdb/files/4438687/OtherMaterial-Sample.Data.txt), the execution result of this statement is shown below:
-
+
+```
++-----------------------------+-------------------------------+
+| Time|root.sgcc.wf03.wt01.temperature|
++-----------------------------+-------------------------------+
+|2017-11-01T16:37:50.000+08:00| 24.746666|
++-----------------------------+-------------------------------+
+Total line number = 1
+It costs 0.017s
+```
#### Correspondence between Data Type and Fill Method
@@ -532,10 +769,6 @@ Data types and the supported fill methods are shown in Table 3-6.
|text|previous|
-It is worth noting that IoTDB will give error prompts for fill methods that are not supported by data types, as shown below:
-
-
-
When the fill method is not specified, each data type bears its own default fill methods and parameters. The corresponding relationship is shown in Table 3-7.
**Table 3-7 Default fill methods and parameters for various data types**
@@ -580,7 +813,24 @@ The selected device is ln group wf01 plant wt01 device; the selected timeseries
The result is shown below:
-
+```
++-----------------------------+------------------------+-----------------------------+
+| Time|root.ln.wf01.wt01.status|root.ln.wf01.wt01.temperature|
++-----------------------------+------------------------+-----------------------------+
+|2017-11-01T00:00:00.000+08:00| true| 25.96|
+|2017-11-01T00:01:00.000+08:00| true| 24.36|
+|2017-11-01T00:02:00.000+08:00| false| 20.09|
+|2017-11-01T00:03:00.000+08:00| false| 20.18|
+|2017-11-01T00:04:00.000+08:00| false| 21.13|
+|2017-11-01T00:05:00.000+08:00| false| 22.72|
+|2017-11-01T00:06:00.000+08:00| false| 20.71|
+|2017-11-01T00:07:00.000+08:00| false| 21.45|
+|2017-11-01T00:08:00.000+08:00| false| 22.58|
+|2017-11-01T00:09:00.000+08:00| false| 20.98|
++-----------------------------+------------------------+-----------------------------+
+Total line number = 10
+It costs 0.000s
+```
* Example 2: LIMIT clause with OFFSET
@@ -595,7 +845,19 @@ The selected device is ln group wf01 plant wt01 device; the selected timeseries
The result is shown below:
-
+```
++-----------------------------+------------------------+-----------------------------+
+| Time|root.ln.wf01.wt01.status|root.ln.wf01.wt01.temperature|
++-----------------------------+------------------------+-----------------------------+
+|2017-11-01T00:03:00.000+08:00| false| 20.18|
+|2017-11-01T00:04:00.000+08:00| false| 21.13|
+|2017-11-01T00:05:00.000+08:00| false| 22.72|
+|2017-11-01T00:06:00.000+08:00| false| 20.71|
+|2017-11-01T00:07:00.000+08:00| false| 21.45|
++-----------------------------+------------------------+-----------------------------+
+Total line number = 5
+It costs 0.342s
+```
* Example 3: LIMIT clause combined with WHERE clause
@@ -610,7 +872,19 @@ The selected device is ln group wf01 plant wt01 device; the selected timeseries
The result is shown below:
-
+```
++-----------------------------+------------------------+-----------------------------+
+| Time|root.ln.wf01.wt01.status|root.ln.wf01.wt01.temperature|
++-----------------------------+------------------------+-----------------------------+
+|2017-11-01T00:03:00.000+08:00| false| 20.18|
+|2017-11-01T00:04:00.000+08:00| false| 21.13|
+|2017-11-01T00:05:00.000+08:00| false| 22.72|
+|2017-11-01T00:06:00.000+08:00| false| 20.71|
+|2017-11-01T00:07:00.000+08:00| false| 21.45|
++-----------------------------+------------------------+-----------------------------+
+Total line number = 5
+It costs 0.000s
+```
* Example 4: LIMIT clause combined with GROUP BY clause
@@ -625,7 +899,18 @@ The SQL statement clause requires rows 3 to 7 of the query result be returned (w
The result is shown below:
-
+```
++-----------------------------+-------------------------------+----------------------------------------+
+| Time|count(root.ln.wf01.wt01.status)|max_value(root.ln.wf01.wt01.temperature)|
++-----------------------------+-------------------------------+----------------------------------------+
+|2017-11-04T00:00:00.000+08:00| 1440| 26.0|
+|2017-11-05T00:00:00.000+08:00| 1440| 26.0|
+|2017-11-06T00:00:00.000+08:00| 1440| 25.99|
+|2017-11-07T00:00:00.000+08:00| 1380| 26.0|
++-----------------------------+-------------------------------+----------------------------------------+
+Total line number = 4
+It costs 0.016s
+```
It is worth noting that because the current FILL clause can only fill in the missing value of timeseries at a certain time point, that is to say, the execution result of FILL clause is exactly one line, so LIMIT and OFFSET are not expected to be used in combination with FILL clause, otherwise errors will be prompted. For example, executing the following SQL statement:
@@ -635,7 +920,9 @@ select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000
The SQL statement will not be executed and the corresponding error prompt is given as follows:
-
+```
+Msg: 401: line 1:107 mismatched input 'limit' expecting {, SLIMIT, SOFFSET, GROUP, DISABLE, ALIGN}
+```
#### Column Control over Query Results
@@ -654,7 +941,20 @@ The selected device is ln group wf01 plant wt01 device; the selected timeseries
The result is shown below:
-
+```
++-----------------------------+-----------------------------+
+| Time|root.ln.wf01.wt01.temperature|
++-----------------------------+-----------------------------+
+|2017-11-01T00:06:00.000+08:00| 20.71|
+|2017-11-01T00:07:00.000+08:00| 21.45|
+|2017-11-01T00:08:00.000+08:00| 22.58|
+|2017-11-01T00:09:00.000+08:00| 20.98|
+|2017-11-01T00:10:00.000+08:00| 25.52|
+|2017-11-01T00:11:00.000+08:00| 22.91|
++-----------------------------+-----------------------------+
+Total line number = 6
+It costs 0.000s
+```
* Example 2: SLIMIT clause with SOFFSET
@@ -669,7 +969,20 @@ The selected device is ln group wf01 plant wt01 device; the selected timeseries
The result is shown below:
-
+```
++-----------------------------+------------------------+
+| Time|root.ln.wf01.wt01.status|
++-----------------------------+------------------------+
+|2017-11-01T00:06:00.000+08:00| false|
+|2017-11-01T00:07:00.000+08:00| false|
+|2017-11-01T00:08:00.000+08:00| false|
+|2017-11-01T00:09:00.000+08:00| false|
+|2017-11-01T00:10:00.000+08:00| true|
+|2017-11-01T00:11:00.000+08:00| false|
++-----------------------------+------------------------+
+Total line number = 6
+It costs 0.003s
+```
* Example 3: SLIMIT clause combined with GROUP BY clause
@@ -681,14 +994,28 @@ select max_value(*) from root.ln.wf01.wt01 group by ([2017-11-01T00:00:00, 2017-
The result is shown below:
-
+```
++-----------------------------+-----------------------------------+
+| Time|max_value(root.ln.wf01.wt01.status)|
++-----------------------------+-----------------------------------+
+|2017-11-01T00:00:00.000+08:00| true|
+|2017-11-02T00:00:00.000+08:00| true|
+|2017-11-03T00:00:00.000+08:00| true|
+|2017-11-04T00:00:00.000+08:00| true|
+|2017-11-05T00:00:00.000+08:00| true|
+|2017-11-06T00:00:00.000+08:00| true|
+|2017-11-07T00:00:00.000+08:00| true|
++-----------------------------+-----------------------------------+
+Total line number = 7
+It costs 0.000s
+```
* Example 4: SLIMIT clause combined with FILL clause
The SQL statement is:
```
-select * from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(float[previous, 1m]) slimit 1 soffset 1
+select * from root.sgcc.wf03.wt01 where time = 2017-11-01T16:35:00 fill(float[previous, 1m]) slimit 1 soffset 1
```
which means:
@@ -696,17 +1023,16 @@ The selected device is ln group wf01 plant wt01 device; the selected timeseries
The result is shown below:
-
-
-It is worth noting that SLIMIT clause is expected to be used in conjunction with star path or prefix path, and the system will prompt errors when SLIMIT clause is used in conjunction with complete path query. For example, executing the following SQL statement:
-
```
-select status,temperature from root.ln.wf01.wt01 where time > 2017-11-01T00:05:00.000 and time < 2017-11-01T00:12:00.000 slimit 1
++-----------------------------+--------------------------+
+| Time|root.sgcc.wf03.wt01.status|
++-----------------------------+--------------------------+
+|2017-11-01T16:35:00.000+08:00| true|
++-----------------------------+--------------------------+
+Total line number = 1
+It costs 0.007s
```
-The SQL statement will not be executed and the corresponding error prompt is given as follows:
-
-
#### Row and Column Control over Query Results
In addition to row or column control over query results, IoTDB allows users to control both rows and columns of query results. Here is a complete example with both LIMIT clauses and SLIMIT clauses.
@@ -722,7 +1048,24 @@ The selected device is ln group wf01 plant wt01 device; the selected timeseries
The result is shown below:
-
+```
++-----------------------------+-----------------------------+------------------------+
+| Time|root.ln.wf01.wt01.temperature|root.ln.wf01.wt01.status|
++-----------------------------+-----------------------------+------------------------+
+|2017-11-01T01:40:00.000+08:00| 21.19| false|
+|2017-11-01T01:41:00.000+08:00| 22.79| false|
+|2017-11-01T01:42:00.000+08:00| 22.98| false|
+|2017-11-01T01:43:00.000+08:00| 21.52| false|
+|2017-11-01T01:44:00.000+08:00| 23.45| true|
+|2017-11-01T01:45:00.000+08:00| 24.06| true|
+|2017-11-01T01:46:00.000+08:00| 22.6| false|
+|2017-11-01T01:47:00.000+08:00| 23.78| true|
+|2017-11-01T01:48:00.000+08:00| 24.72| true|
+|2017-11-01T01:49:00.000+08:00| 24.68| true|
++-----------------------------+-----------------------------+------------------------+
+Total line number = 10
+It costs 0.009s
+```
### Use Alias
@@ -749,9 +1092,27 @@ The 'align by device' indicates that the deviceId is considered as a column. The
The SQL statement is:
```
-select s1,s2 from root.sg1.* align by device
+select * from root.ln.* where time <= 2017-11-01T00:01:00 align by device
```
+The result shows below:
+
+```
++-----------------------------+-----------------+-----------+------+--------+
+| Time| Device|temperature|status|hardware|
++-----------------------------+-----------------+-----------+------+--------+
+|2017-11-01T00:00:00.000+08:00|root.ln.wf01.wt01| 25.96| true| null|
+|2017-11-01T00:01:00.000+08:00|root.ln.wf01.wt01| 24.36| true| null|
+|1970-01-01T08:00:00.001+08:00|root.ln.wf02.wt02| null| true| v1|
+|1970-01-01T08:00:00.002+08:00|root.ln.wf02.wt02| null| false| v2|
+|2017-11-01T00:00:00.000+08:00|root.ln.wf02.wt02| null| true| v2|
+|2017-11-01T00:01:00.000+08:00|root.ln.wf02.wt02| null| true| v2|
++-----------------------------+-----------------+-----------+------+--------+
+Total line number = 6
+It costs 0.012s
+```
+
+
For more syntax description, please read [SQL Reference](../Operation%20Manual/SQL%20Reference.md).
The 'disable align' indicates that there are 2 columns for each time series in the result set. Disable Align Clause can only be used at the end of a query statement. Disable Align Clause cannot be used with Aggregation, Fill Statements, Group By or Group By Device Statements, but can with Limit Statements. The display principle of the result table is that only when the column (or row) has existing data will the column (or row) be shown, with nonexistent cells being empty.
@@ -759,9 +1120,25 @@ The 'disable align' indicates that there are 2 columns for each time series in t
The SQL statement is:
```
-select * from root.sg1 where time > 10 disable align
+select * from root.ln.* where time <= 2017-11-01T00:01:00 disable align
```
+The result shows below:
+
+```
++-----------------------------+--------------------------+-----------------------------+------------------------+-----------------------------+-----------------------------+-----------------------------+------------------------+
+| Time|root.ln.wf02.wt02.hardware| Time|root.ln.wf02.wt02.status| Time|root.ln.wf01.wt01.temperature| Time|root.ln.wf01.wt01.status|
++-----------------------------+--------------------------+-----------------------------+------------------------+-----------------------------+-----------------------------+-----------------------------+------------------------+
+|1970-01-01T08:00:00.001+08:00| v1|1970-01-01T08:00:00.001+08:00| true|2017-11-01T00:00:00.000+08:00| 25.96|2017-11-01T00:00:00.000+08:00| true|
+|1970-01-01T08:00:00.002+08:00| v2|1970-01-01T08:00:00.002+08:00| false|2017-11-01T00:01:00.000+08:00| 24.36|2017-11-01T00:01:00.000+08:00| true|
+|2017-11-01T00:00:00.000+08:00| v2|2017-11-01T00:00:00.000+08:00| true| null| null| null| null|
+|2017-11-01T00:01:00.000+08:00| v2|2017-11-01T00:01:00.000+08:00| true| null| null| null| null|
++-----------------------------+--------------------------+-----------------------------+------------------------+-----------------------------+-----------------------------+-----------------------------+------------------------+
+Total line number = 4
+It costs 0.018s
+```
+
+
For more syntax description, please read [SQL Reference](../Operation%20Manual/SQL%20Reference.md).
#### Error Handling
@@ -773,7 +1150,20 @@ select status,temperature from root.ln.wf01.wt01 where time > 2017-11-01T00:05:0
```
The result is shown below:
-
+```
++-----------------------------+------------------------+-----------------------------+
+| Time|root.ln.wf01.wt01.status|root.ln.wf01.wt01.temperature|
++-----------------------------+------------------------+-----------------------------+
+|2017-11-01T00:06:00.000+08:00| false| 20.71|
+|2017-11-01T00:07:00.000+08:00| false| 21.45|
+|2017-11-01T00:08:00.000+08:00| false| 22.58|
+|2017-11-01T00:09:00.000+08:00| false| 20.98|
+|2017-11-01T00:10:00.000+08:00| true| 25.52|
+|2017-11-01T00:11:00.000+08:00| false| 22.91|
++-----------------------------+------------------------+-----------------------------+
+Total line number = 6
+It costs 0.005s
+```
If the parameter N/SN of LIMIT/SLIMIT clause exceeds the allowable maximum value (N/SN is of type int32), the system prompts errors. For example, executing the following SQL statement:
@@ -782,7 +1172,9 @@ select status,temperature from root.ln.wf01.wt01 where time > 2017-11-01T00:05:0
```
The SQL statement will not be executed and the corresponding error prompt is given as follows:
-
+```
+Msg: 303: check metadata error: Out of range. LIMIT : N should be Int32.
+```
If the parameter N/SN of LIMIT/SLIMIT clause is not a positive intege, the system prompts errors. For example, executing the following SQL statement:
@@ -792,7 +1184,9 @@ select status,temperature from root.ln.wf01.wt01 where time > 2017-11-01T00:05:0
The SQL statement will not be executed and the corresponding error prompt is given as follows:
-
+```
+Msg: 401: line 1:129 mismatched input '.' expecting {, SLIMIT, OFFSET, SOFFSET, GROUP, DISABLE, ALIGN}
+```
If the parameter OFFSET of LIMIT clause exceeds the size of the result set, IoTDB will return an empty result set. For example, executing the following SQL statement:
@@ -800,7 +1194,14 @@ If the parameter OFFSET of LIMIT clause exceeds the size of the result set, IoTD
select status,temperature from root.ln.wf01.wt01 where time > 2017-11-01T00:05:00.000 and time < 2017-11-01T00:12:00.000 limit 2 offset 6
```
The result is shown below:
-
+```
++----+------------------------+-----------------------------+
+|Time|root.ln.wf01.wt01.status|root.ln.wf01.wt01.temperature|
++----+------------------------+-----------------------------+
++----+------------------------+-----------------------------+
+Empty set.
+It costs 0.005s
+```
If the parameter SOFFSET of SLIMIT clause is not smaller than the number of available timeseries, the system prompts errors. For example, executing the following SQL statement:
@@ -808,8 +1209,10 @@ If the parameter SOFFSET of SLIMIT clause is not smaller than the number of avai
select * from root.ln.wf01.wt01 where time > 2017-11-01T00:05:00.000 and time < 2017-11-01T00:12:00.000 slimit 1 soffset 2
```
The SQL statement will not be executed and the corresponding error prompt is given as follows:
-
+```
+Msg: 411: Meet error in query process: The value of SOFFSET (2) is equal to or exceeds the number of sequences (2) that can actually be returned.
+```
## DELETE
diff --git a/docs/zh/UserGuide/Operation Manual/DDL Data Definition Language.md b/docs/zh/UserGuide/Operation Manual/DDL Data Definition Language.md
index ba083e032a20..bd7b185f0e78 100644
--- a/docs/zh/UserGuide/Operation Manual/DDL Data Definition Language.md
+++ b/docs/zh/UserGuide/Operation Manual/DDL Data Definition Language.md
@@ -49,7 +49,17 @@ IoTDB> show storage group root.ln
```
执行结果为:
-
+
+```
++-------------+
+|storage group|
++-------------+
+| root.sgcc|
+| root.ln|
++-------------+
+Total line number = 2
+It costs 0.060s
+```
## 删除存储组
@@ -109,7 +119,7 @@ ALTER timeseries root.turbine.d1.s1 RENAME tag1 TO newTag1
```
* 重新设置标签或属性的值
```
-ALTER timeseries root.turbine.d1.s1 SET tag1=newV1, attr1=newV1
+ALTER timeseries root.turbine.d1.s1 SET newTag1=newV1, attr1=newV1
```
* 删除已经存在的标签或属性
```
@@ -154,20 +164,63 @@ IoTDB> show timeseries root.ln
执行结果分别为:
-
-
+```
++-------------------------------+--------+-------------+--------+--------+-----------+-------------------------------------------+--------------------------------------------------------+
+| timeseries| alias|storage group|dataType|encoding|compression| tags| attributes|
++-------------------------------+--------+-------------+--------+--------+-----------+-------------------------------------------+--------------------------------------------------------+
+|root.sgcc.wf03.wt01.temperature| null| root.sgcc| FLOAT| RLE| SNAPPY| null| null|
+| root.sgcc.wf03.wt01.status| null| root.sgcc| BOOLEAN| PLAIN| SNAPPY| null| null|
+| root.turbine.d1.s1|newAlias| root.turbine| FLOAT| RLE| SNAPPY|{"newTag1":"newV1","tag4":"v4","tag3":"v3"}|{"attr2":"v2","attr1":"newV1","attr4":"v4","attr3":"v3"}|
+| root.ln.wf02.wt02.hardware| null| root.ln| TEXT| PLAIN| SNAPPY| null| null|
+| root.ln.wf02.wt02.status| null| root.ln| BOOLEAN| PLAIN| SNAPPY| null| null|
+| root.ln.wf01.wt01.temperature| null| root.ln| FLOAT| RLE| SNAPPY| null| null|
+| root.ln.wf01.wt01.status| null| root.ln| BOOLEAN| PLAIN| SNAPPY| null| null|
++-------------------------------+--------+-------------+--------+--------+-----------+-------------------------------------------+--------------------------------------------------------+
+Total line number = 7
+It costs 0.016s
+
++-----------------------------+-----+-------------+--------+--------+-----------+----+----------+
+| timeseries|alias|storage group|dataType|encoding|compression|tags|attributes|
++-----------------------------+-----+-------------+--------+--------+-----------+----+----------+
+| root.ln.wf02.wt02.hardware| null| root.ln| TEXT| PLAIN| SNAPPY|null| null|
+| root.ln.wf02.wt02.status| null| root.ln| BOOLEAN| PLAIN| SNAPPY|null| null|
+|root.ln.wf01.wt01.temperature| null| root.ln| FLOAT| RLE| SNAPPY|null| null|
+| root.ln.wf01.wt01.status| null| root.ln| BOOLEAN| PLAIN| SNAPPY|null| null|
++-----------------------------+-----+-------------+--------+--------+-----------+----+----------+
+Total line number = 4
+It costs 0.004s
+```
* SHOW TIMESERIES (<`PrefixPath`>)? WhereClause
返回给定路径的下的所有满足条件的时间序列信息,SQL语句如下所示:
```
+ALTER timeseries root.ln.wf02.wt02.hardware ADD TAGS unit=c
+ALTER timeseries root.ln.wf02.wt02.status ADD TAGS description=test1
show timeseries root.ln where unit=c
show timeseries root.ln where description contains 'test1'
```
执行结果分别为:
-
+
+```
++--------------------------+-----+-------------+--------+--------+-----------+------------+----------+
+| timeseries|alias|storage group|dataType|encoding|compression| tags|attributes|
++--------------------------+-----+-------------+--------+--------+-----------+------------+----------+
+|root.ln.wf02.wt02.hardware| null| root.ln| TEXT| PLAIN| SNAPPY|{"unit":"c"}| null|
++--------------------------+-----+-------------+--------+--------+-----------+------------+----------+
+Total line number = 1
+It costs 0.005s
+
++------------------------+-----+-------------+--------+--------+-----------+-----------------------+----------+
+| timeseries|alias|storage group|dataType|encoding|compression| tags|attributes|
++------------------------+-----+-------------+--------+--------+-----------+-----------------------+----------+
+|root.ln.wf02.wt02.status| null| root.ln| BOOLEAN| PLAIN| SNAPPY|{"description":"test1"}| null|
++------------------------+-----+-------------+--------+--------+-----------+-----------------------+----------+
+Total line number = 1
+It costs 0.004s
+```
> 注意,现在我们只支持一个查询条件,要么是等值条件查询,要么是包含条件查询。当然where子句中涉及的必须是标签值,而不能是属性值。
@@ -228,7 +281,21 @@ IoTDB > COUNT TIMESERIES root.ln.wf01.wt01.status
例如有如下时间序列(可以使用`show timeseries`展示所有时间序列):
-
+```
++-------------------------------+--------+-------------+--------+--------+-----------+-------------------------------------------+--------------------------------------------------------+
+| timeseries| alias|storage group|dataType|encoding|compression| tags| attributes|
++-------------------------------+--------+-------------+--------+--------+-----------+-------------------------------------------+--------------------------------------------------------+
+|root.sgcc.wf03.wt01.temperature| null| root.sgcc| FLOAT| RLE| SNAPPY| null| null|
+| root.sgcc.wf03.wt01.status| null| root.sgcc| BOOLEAN| PLAIN| SNAPPY| null| null|
+| root.turbine.d1.s1|newAlias| root.turbine| FLOAT| RLE| SNAPPY|{"newTag1":"newV1","tag4":"v4","tag3":"v3"}|{"attr2":"v2","attr1":"newV1","attr4":"v4","attr3":"v3"}|
+| root.ln.wf02.wt02.hardware| null| root.ln| TEXT| PLAIN| SNAPPY| {"unit":"c"}| null|
+| root.ln.wf02.wt02.status| null| root.ln| BOOLEAN| PLAIN| SNAPPY| {"description":"test1"}| null|
+| root.ln.wf01.wt01.temperature| null| root.ln| FLOAT| RLE| SNAPPY| null| null|
+| root.ln.wf01.wt01.status| null| root.ln| BOOLEAN| PLAIN| SNAPPY| null| null|
++-------------------------------+--------+-------------+--------+--------+-----------+-------------------------------------------+--------------------------------------------------------+
+Total line number = 7
+It costs 0.004s
+```
那么Metadata Tree如下所示:
@@ -258,7 +325,32 @@ IoTDB > COUNT NODES root.ln.wf01 LEVEL=3
```
对于上面提到的例子和Metadata Tree,你可以获得如下结果:
-
+
+```
++-----+
+|count|
++-----+
+| 4|
++-----+
+Total line number = 1
+It costs 0.003s
+
++-----+
+|count|
++-----+
+| 2|
++-----+
+Total line number = 1
+It costs 0.002s
+
++-----+
+|count|
++-----+
+| 1|
++-----+
+Total line number = 1
+It costs 0.002s
+```
> 注意:时间序列的路径只是过滤条件,与level的定义无关。
其中`PrefixPath`可以包含`*`,但是`*`及其后的所有节点将被忽略,仅在`*`前的前缀路径有效。
@@ -284,6 +376,29 @@ IoTDB> show devices
IoTDB> show devices root.ln
```
+你可以获得如下数据:
+```
++-------------------+
+| devices|
++-------------------+
+| root.ln.wf01.wt01|
+| root.ln.wf02.wt02|
+|root.sgcc.wf03.wt01|
+| root.turbine.d1|
++-------------------+
+Total line number = 4
+It costs 0.002s
+
++-----------------+
+| devices|
++-----------------+
+|root.ln.wf01.wt01|
+|root.ln.wf02.wt02|
++-----------------+
+Total line number = 2
+It costs 0.001s
+```
+
# TTL
IoTDB支持对存储组级别设置数据存活时间(TTL),这使得IoTDB可以定期、自动地删除一定时间之前的数据。合理使用TTL
diff --git a/docs/zh/UserGuide/Operation Manual/DML Data Manipulation Language.md b/docs/zh/UserGuide/Operation Manual/DML Data Manipulation Language.md
index f021162d8413..8db2a90c2be0 100644
--- a/docs/zh/UserGuide/Operation Manual/DML Data Manipulation Language.md
+++ b/docs/zh/UserGuide/Operation Manual/DML Data Manipulation Language.md
@@ -57,32 +57,16 @@ IoTDB > select * from root.ln.wf02 where time < 3
```
结果如图所示。由查询结果可以看出,单列、多列数据的插入操作正确执行。
-
-
-### INSERT语句的错误处理
-
-若用户向一个不存在的时间序列中插入数据,例如执行以下命令:
-
-```
-IoTDB > insert into root.ln.wf02.wt02(timestamp, temperature) values(1,"v1")
-```
-
-由于`root.ln.wf02.wt02. temperature`时间序列不存在,系统将会返回以下ERROR告知该Timeseries路径不存在:
-
-```
-Msg: The resultDataType or encoding or compression of the last node temperature is conflicting in the storage group root.ln
-```
-
-若用户插入的数据类型与该Timeseries对应的数据类型不一致,例如执行以下命令:
-
-```
-IoTDB > insert into root.ln.wf02.wt02(timestamp,hardware) values(1,100)
-```
-
-系统将会返回以下ERROR告知数据类型有误:
```
-error: The TEXT data type should be covered by " or '
++-----------------------------+--------------------------+------------------------+
+| Time|root.ln.wf02.wt02.hardware|root.ln.wf02.wt02.status|
++-----------------------------+--------------------------+------------------------+
+|1970-01-01T08:00:00.001+08:00| v1| true|
+|1970-01-01T08:00:00.002+08:00| v2| false|
++-----------------------------+--------------------------+------------------------+
+Total line number = 2
+It costs 0.170s
```
## 数据查询
@@ -105,7 +89,22 @@ select temperature from root.ln.wf01.wt01 where time < 2017-11-01T00:08:00.000
该SQL语句的执行结果如下:
-
+```
++-----------------------------+-----------------------------+
+| Time|root.ln.wf01.wt01.temperature|
++-----------------------------+-----------------------------+
+|2017-11-01T00:00:00.000+08:00| 25.96|
+|2017-11-01T00:01:00.000+08:00| 24.36|
+|2017-11-01T00:02:00.000+08:00| 20.09|
+|2017-11-01T00:03:00.000+08:00| 20.18|
+|2017-11-01T00:04:00.000+08:00| 21.13|
+|2017-11-01T00:05:00.000+08:00| 22.72|
+|2017-11-01T00:06:00.000+08:00| 20.71|
+|2017-11-01T00:07:00.000+08:00| 21.45|
++-----------------------------+-----------------------------+
+Total line number = 8
+It costs 0.026s
+```
#### 根据一个时间区间选择多列数据
@@ -121,7 +120,20 @@ select status, temperature from root.ln.wf01.wt01 where time > 2017-11-01T00:05:
该SQL语句的执行结果如下:
-
+```
++-----------------------------+------------------------+-----------------------------+
+| Time|root.ln.wf01.wt01.status|root.ln.wf01.wt01.temperature|
++-----------------------------+------------------------+-----------------------------+
+|2017-11-01T00:06:00.000+08:00| false| 20.71|
+|2017-11-01T00:07:00.000+08:00| false| 21.45|
+|2017-11-01T00:08:00.000+08:00| false| 22.58|
+|2017-11-01T00:09:00.000+08:00| false| 20.98|
+|2017-11-01T00:10:00.000+08:00| true| 25.52|
+|2017-11-01T00:11:00.000+08:00| false| 22.91|
++-----------------------------+------------------------+-----------------------------+
+Total line number = 6
+It costs 0.018s
+```
#### 按照多个时间区间选择同一设备的多列数据
@@ -138,7 +150,24 @@ select status,temperature from root.ln.wf01.wt01 where (time > 2017-11-01T00:05:
被选择的设备为ln集团wf01子站wt01设备;被选择的时间序列为“供电状态(status)”和“温度传感器(temperature)”;该语句指定了两个不同的时间区间,分别为“2017-11-01T00:05:00.000至2017-11-01T00:12:00.000”和“2017-11-01T16:35:00.000至2017-11-01T16:37:00.000”;该语句要求选择出满足任一时间区间的被选时间序列的值。
该SQL语句的执行结果如下:
-
+
+```
++-----------------------------+------------------------+-----------------------------+
+| Time|root.ln.wf01.wt01.status|root.ln.wf01.wt01.temperature|
++-----------------------------+------------------------+-----------------------------+
+|2017-11-01T00:06:00.000+08:00| false| 20.71|
+|2017-11-01T00:07:00.000+08:00| false| 21.45|
+|2017-11-01T00:08:00.000+08:00| false| 22.58|
+|2017-11-01T00:09:00.000+08:00| false| 20.98|
+|2017-11-01T00:10:00.000+08:00| true| 25.52|
+|2017-11-01T00:11:00.000+08:00| false| 22.91|
+|2017-11-01T16:35:00.000+08:00| true| 23.44|
+|2017-11-01T16:36:00.000+08:00| false| 21.98|
+|2017-11-01T16:37:00.000+08:00| false| 21.93|
++-----------------------------+------------------------+-----------------------------+
+Total line number = 9
+It costs 0.018s
+```
#### 按照多个时间区间选择不同设备的多列数据
@@ -154,13 +183,50 @@ select wf01.wt01.status,wf02.wt02.hardware from root.ln where (time > 2017-11-01
被选择的时间序列为“ln集团wf01子站wt01设备的供电状态”以及“ln集团wf02子站wt02设备的硬件版本”;该语句指定了两个时间区间,分别为“2017-11-01T00:05:00.000至2017-11-01T00:12:00.000”和“2017-11-01T16:35:00.000至2017-11-01T16:37:00.000”;该语句要求选择出满足任意时间区间的被选时间序列的值。
该SQL语句的执行结果如下:
-
+
+```
++-----------------------------+------------------------+--------------------------+
+| Time|root.ln.wf01.wt01.status|root.ln.wf02.wt02.hardware|
++-----------------------------+------------------------+--------------------------+
+|2017-11-01T00:06:00.000+08:00| false| v1|
+|2017-11-01T00:07:00.000+08:00| false| v1|
+|2017-11-01T00:08:00.000+08:00| false| v1|
+|2017-11-01T00:09:00.000+08:00| false| v1|
+|2017-11-01T00:10:00.000+08:00| true| v2|
+|2017-11-01T00:11:00.000+08:00| false| v1|
+|2017-11-01T16:35:00.000+08:00| true| v2|
+|2017-11-01T16:36:00.000+08:00| false| v1|
+|2017-11-01T16:37:00.000+08:00| false| v1|
++-----------------------------+------------------------+--------------------------+
+Total line number = 9
+It costs 0.014s
+```
#### 根据时间降序返回
IoTDB 在 0.11 版本开始支持 'order by time' 语句, 用于对结果按照时间进行降序展示。例如,SQL语句为:
```sql
select * from root.ln where time > 1 order by time desc limit 10;
```
+语句执行的结果为:
+
+```
++-----------------------------+--------------------------+------------------------+-----------------------------+------------------------+
+| Time|root.ln.wf02.wt02.hardware|root.ln.wf02.wt02.status|root.ln.wf01.wt01.temperature|root.ln.wf01.wt01.status|
++-----------------------------+--------------------------+------------------------+-----------------------------+------------------------+
+|2017-11-07T23:59:00.000+08:00| v1| false| 21.07| false|
+|2017-11-07T23:58:00.000+08:00| v1| false| 22.93| false|
+|2017-11-07T23:57:00.000+08:00| v2| true| 24.39| true|
+|2017-11-07T23:56:00.000+08:00| v2| true| 24.44| true|
+|2017-11-07T23:55:00.000+08:00| v2| true| 25.9| true|
+|2017-11-07T23:54:00.000+08:00| v1| false| 22.52| false|
+|2017-11-07T23:53:00.000+08:00| v2| true| 24.58| true|
+|2017-11-07T23:52:00.000+08:00| v1| false| 20.18| false|
+|2017-11-07T23:51:00.000+08:00| v1| false| 22.24| false|
+|2017-11-07T23:50:00.000+08:00| v2| true| 23.7| true|
++-----------------------------+--------------------------+------------------------+-----------------------------+------------------------+
+Total line number = 10
+It costs 0.016s
+```
更多语法请参照 [SQL REFERENCE](../Operation%20Manual/SQL%20Reference.md).
@@ -171,7 +237,23 @@ IoTDB支持另外两种结果返回形式: 按设备时间对齐 'align by devic
'align by device' 对齐方式下,设备ID会单独作为一列出现。在 select 子句中写了多少列,最终结果就会有该列数+2 (时间列和设备名字列)。SQL形如:
```
-select s1,s2 from root.sg1.* align by device
+select * from root.ln.* where time <= 2017-11-01T00:01:00 align by device
+```
+结果如下:
+
+```
++-----------------------------+-----------------+-----------+------+--------+
+| Time| Device|temperature|status|hardware|
++-----------------------------+-----------------+-----------+------+--------+
+|2017-11-01T00:00:00.000+08:00|root.ln.wf01.wt01| 25.96| true| null|
+|2017-11-01T00:01:00.000+08:00|root.ln.wf01.wt01| 24.36| true| null|
+|1970-01-01T08:00:00.001+08:00|root.ln.wf02.wt02| null| true| v1|
+|1970-01-01T08:00:00.002+08:00|root.ln.wf02.wt02| null| false| v2|
+|2017-11-01T00:00:00.000+08:00|root.ln.wf02.wt02| null| true| v2|
+|2017-11-01T00:01:00.000+08:00|root.ln.wf02.wt02| null| true| v2|
++-----------------------------+-----------------+-----------+------+--------+
+Total line number = 6
+It costs 0.012s
```
'disable align' 意味着每条时序就有 2 列存在。Disable Align只能用于查询语句句尾,不能用于聚合查询、Fill语句、Group by或Group by device语句,但可用于Limit语句。结果显示若无数据显示为空白。
@@ -179,7 +261,22 @@ select s1,s2 from root.sg1.* align by device
SQL形如:
```
-select * from root.sg1 where time > 10 disable align
+select * from root.ln.* where time <= 2017-11-01T00:01:00 disable align
+```
+
+结果如下:
+
+```
++-----------------------------+--------------------------+-----------------------------+------------------------+-----------------------------+-----------------------------+-----------------------------+------------------------+
+| Time|root.ln.wf02.wt02.hardware| Time|root.ln.wf02.wt02.status| Time|root.ln.wf01.wt01.temperature| Time|root.ln.wf01.wt01.status|
++-----------------------------+--------------------------+-----------------------------+------------------------+-----------------------------+-----------------------------+-----------------------------+------------------------+
+|1970-01-01T08:00:00.001+08:00| v1|1970-01-01T08:00:00.001+08:00| true|2017-11-01T00:00:00.000+08:00| 25.96|2017-11-01T00:00:00.000+08:00| true|
+|1970-01-01T08:00:00.002+08:00| v2|1970-01-01T08:00:00.002+08:00| false|2017-11-01T00:01:00.000+08:00| 24.36|2017-11-01T00:01:00.000+08:00| true|
+|2017-11-01T00:00:00.000+08:00| v2|2017-11-01T00:00:00.000+08:00| true| null| null| null| null|
+|2017-11-01T00:01:00.000+08:00| v2|2017-11-01T00:01:00.000+08:00| true| null| null| null| null|
++-----------------------------+--------------------------+-----------------------------+------------------------+-----------------------------+-----------------------------+-----------------------------+------------------------+
+Total line number = 4
+It costs 0.018s
```
更多语法请参照[SQL REFERENCE](../Operation%20Manual/SQL%20Reference.md)。
@@ -194,10 +291,17 @@ select * from root.sg1 where time > 10 disable align
```
select count(status) from root.ln.wf01.wt01;
```
+结果:
-| count(root.ln.wf01.wt01.status) |
-| -------------- |
-| 4 |
+```
++-------------------------------+
+|count(root.ln.wf01.wt01.status)|
++-------------------------------+
+| 10080|
++-------------------------------+
+Total line number = 1
+It costs 0.016s
+```
#### 分层聚合查询
@@ -212,9 +316,15 @@ select count(status) from root.ln.wf01.* group by level=2
```
运行结果为:
-| count(root.ln.wf01.*.status) |
-| ---------------------------- |
-| 7 |
+```
++----------------------------+
+|COUNT(root.ln.wf01.*.status)|
++----------------------------+
+| 10080|
++----------------------------+
+Total line number = 1
+It costs 0.003s
+```
假设此时在"root.ln"下面加入名为wf02的子序列,如"root.ln.wf02.wt01.status"。
@@ -224,9 +334,15 @@ select count(status) from root.ln.*.* group by level=2
```
运行结果:
-| count(root.ln.wf01.*.status) | count(root.ln.wf02.*.status) |
-| ---------------------------- | ---------------------------- |
-| 7 | 4
+```
++----------------------------+----------------------------+
+|COUNT(root.ln.wf01.*.status)|COUNT(root.ln.wf02.*.status)|
++----------------------------+----------------------------+
+| 10080| 10082|
++----------------------------+----------------------------+
+Total line number = 1
+It costs 0.003s
+```
分层聚合查询也可被用于其他聚合函数,当前所支持的聚合函数为:count, sum, avg, last_value, first_value, min_time, max_time, min_value, max_value
@@ -274,7 +390,21 @@ select count(status), max_value(temperature) from root.ln.wf01.wt01 group by ([2
每个时间间隔窗口内都有数据,SQL执行后的结果集如下所示:
-
+```
++-----------------------------+-------------------------------+----------------------------------------+
+| Time|count(root.ln.wf01.wt01.status)|max_value(root.ln.wf01.wt01.temperature)|
++-----------------------------+-------------------------------+----------------------------------------+
+|2017-11-01T00:00:00.000+08:00| 1440| 26.0|
+|2017-11-02T00:00:00.000+08:00| 1440| 26.0|
+|2017-11-03T00:00:00.000+08:00| 1440| 25.99|
+|2017-11-04T00:00:00.000+08:00| 1440| 26.0|
+|2017-11-05T00:00:00.000+08:00| 1440| 26.0|
+|2017-11-06T00:00:00.000+08:00| 1440| 25.99|
+|2017-11-07T00:00:00.000+08:00| 1380| 26.0|
++-----------------------------+-------------------------------+----------------------------------------+
+Total line number = 7
+It costs 0.024s
+```
#### 指定滑动步长的降频聚合查询
@@ -300,7 +430,21 @@ select count(status), max_value(temperature) from root.ln.wf01.wt01 group by ([2
每个时间间隔窗口内都有数据,SQL执行后的结果集如下所示:
-
+```
++-----------------------------+-------------------------------+----------------------------------------+
+| Time|count(root.ln.wf01.wt01.status)|max_value(root.ln.wf01.wt01.temperature)|
++-----------------------------+-------------------------------+----------------------------------------+
+|2017-11-01T00:00:00.000+08:00| 180| 25.98|
+|2017-11-02T00:00:00.000+08:00| 180| 25.98|
+|2017-11-03T00:00:00.000+08:00| 180| 25.96|
+|2017-11-04T00:00:00.000+08:00| 180| 25.96|
+|2017-11-05T00:00:00.000+08:00| 180| 26.0|
+|2017-11-06T00:00:00.000+08:00| 180| 25.85|
+|2017-11-07T00:00:00.000+08:00| 180| 25.99|
++-----------------------------+-------------------------------+----------------------------------------+
+Total line number = 7
+It costs 0.006s
+```
#### 带值过滤条件的降频聚合查询
@@ -326,33 +470,49 @@ select count(status), max_value(temperature) from root.ln.wf01.wt01 where time >
每个时间间隔窗口内都有数据,SQL执行后的结果集如下所示:
-
-
-GROUP BY的SELECT子句里的查询路径必须是聚合函数,否则系统将会抛出如下对应的错误。
-
-
+```
++-----------------------------+-------------------------------+----------------------------------------+
+| Time|count(root.ln.wf01.wt01.status)|max_value(root.ln.wf01.wt01.temperature)|
++-----------------------------+-------------------------------+----------------------------------------+
+|2017-11-01T00:00:00.000+08:00| 119| 25.98|
+|2017-11-02T00:00:00.000+08:00| 179| 25.98|
+|2017-11-03T00:00:00.000+08:00| 180| 25.96|
+|2017-11-04T00:00:00.000+08:00| 180| 25.96|
+|2017-11-05T00:00:00.000+08:00| 180| 26.0|
+|2017-11-06T00:00:00.000+08:00| 180| 25.85|
+|2017-11-07T00:00:00.000+08:00| 180| 25.99|
++-----------------------------+-------------------------------+----------------------------------------+
+Total line number = 7
+It costs 0.018s
+```
#### 左开右闭区间
每个区间的结果时间戳为区间右端点,对应的SQL语句是:
```
-select count(status) from root.ln.wf01.wt01 group by((5, 40], 5ms);
+select count(status) from root.ln.wf01.wt01 group by ((2017-11-01T00:00:00, 2017-11-07T23:00:00],1d);
```
这条查询语句的时间区间是左开右闭的,结果中不会包含时间点5的数据,但是会包含时间点40的数据。
SQL执行后的结果集如下所示:
-| Time | count(root.ln.wf01.wt01.status) |
-| ------ | ------------------------------- |
-| 10 | 1 |
-| 15 | 2 |
-| 20 | 3 |
-| 25 | 4 |
-| 30 | 4 |
-| 35 | 3 |
-| 40 | 5 |
+```
++-----------------------------+-------------------------------+
+| Time|count(root.ln.wf01.wt01.status)|
++-----------------------------+-------------------------------+
+|2017-11-02T00:00:00.000+08:00| 1440|
+|2017-11-03T00:00:00.000+08:00| 1440|
+|2017-11-04T00:00:00.000+08:00| 1440|
+|2017-11-05T00:00:00.000+08:00| 1440|
+|2017-11-06T00:00:00.000+08:00| 1440|
+|2017-11-07T00:00:00.000+08:00| 1440|
+|2017-11-07T23:00:00.000+08:00| 1380|
++-----------------------------+-------------------------------+
+Total line number = 7
+It costs 0.004s
+```
#### 降采样后按Level聚合查询
@@ -363,19 +523,26 @@ SQL执行后的结果集如下所示:
统计降采样后的数据点个数
```
-select count(status) from root.ln.wf01.wt01 group by ([0,20),3ms), level=1;
+select count(status) from root.ln.wf01.wt01 group by ((2017-11-01T00:00:00, 2017-11-07T23:00:00],1d), level=1;
```
+结果:
-| Time | count(root.ln) |
-| ------ | -------------- |
-| 0 | 1 |
-| 3 | 0 |
-| 6 | 0 |
-| 9 | 1 |
-| 12 | 3 |
-| 15 | 0 |
-| 18 | 0 |
+```
++-----------------------------+-------------------------+
+| Time|COUNT(root.ln.*.*.status)|
++-----------------------------+-------------------------+
+|2017-11-02T00:00:00.000+08:00| 1440|
+|2017-11-03T00:00:00.000+08:00| 1440|
+|2017-11-04T00:00:00.000+08:00| 1440|
+|2017-11-05T00:00:00.000+08:00| 1440|
+|2017-11-06T00:00:00.000+08:00| 1440|
+|2017-11-07T00:00:00.000+08:00| 1440|
+|2017-11-07T23:00:00.000+08:00| 1380|
++-----------------------------+-------------------------+
+Total line number = 7
+It costs 0.006s
+```
加上滑动Step的降采样后的结果也可以汇总
@@ -383,16 +550,21 @@ select count(status) from root.ln.wf01.wt01 group by ([0,20),3ms), level=1;
select count(status) from root.ln.wf01.wt01 group by ([0,20),2ms,3ms), level=1;
```
-
-| Time | count(root.ln) |
-| ------ | -------------- |
-| 0 | 1 |
-| 3 | 0 |
-| 6 | 0 |
-| 9 | 0 |
-| 12 | 2 |
-| 15 | 0 |
-| 18 | 0 |
+```
++-----------------------------+-------------------------+
+| Time|COUNT(root.ln.*.*.status)|
++-----------------------------+-------------------------+
+|2017-11-01T00:00:00.000+08:00| 180|
+|2017-11-02T00:00:00.000+08:00| 180|
+|2017-11-03T00:00:00.000+08:00| 180|
+|2017-11-04T00:00:00.000+08:00| 180|
+|2017-11-05T00:00:00.000+08:00| 180|
+|2017-11-06T00:00:00.000+08:00| 180|
+|2017-11-07T00:00:00.000+08:00| 180|
++-----------------------------+-------------------------+
+Total line number = 7
+It costs 0.004s
+```
#### 降频聚合查询补空值
@@ -409,20 +581,80 @@ select count(status) from root.ln.wf01.wt01 group by ([0,20),2ms,3ms), level=1;
* PREVIOUS:只要空值前边有值,就会用其填充空值。
* PREVIOUSUNTILLAST:不会填充此序列最新点后的空值
-SQL 示例:
+首先我们检查一下root.ln.wf01.wt01.temperature在时间2017-11-07T23:50:00以后的值
```
-SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([8, 39), 5m) FILL (int32[PREVIOUSUNTILLAST])
-SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([8, 39), 5m) FILL (int32[PREVIOUSUNTILLAST, 3m])
+IoTDB> SELECT temperature FROM root.ln.wf01.wt01 where time >= 2017-11-07T23:50:00
++-----------------------------+-----------------------------+
+| Time|root.ln.wf01.wt01.temperature|
++-----------------------------+-----------------------------+
+|2017-11-07T23:50:00.000+08:00| 23.7|
+|2017-11-07T23:51:00.000+08:00| 22.24|
+|2017-11-07T23:52:00.000+08:00| 20.18|
+|2017-11-07T23:53:00.000+08:00| 24.58|
+|2017-11-07T23:54:00.000+08:00| 22.52|
+|2017-11-07T23:55:00.000+08:00| 25.9|
+|2017-11-07T23:56:00.000+08:00| 24.44|
+|2017-11-07T23:57:00.000+08:00| 24.39|
+|2017-11-07T23:58:00.000+08:00| 22.93|
+|2017-11-07T23:59:00.000+08:00| 21.07|
++-----------------------------+-----------------------------+
+Total line number = 10
+It costs 0.002s
```
-解释:
+我们发现root.ln.wf01.wt01.temperature的最后时间和值是2017-11-07T23:59:00和21.07。
-使用 PREVIOUSUNTILLAST 方式填充降频聚合的结果。
+SQL 示例:
-所有路径必须都伴随聚合函数,否则会报以下错误信息:
+```
+SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-08T00:01:00),1m) FILL (float[PREVIOUSUNTILLAST]);
+SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-08T00:01:00),1m) FILL (float[PREVIOUS]);
+```
+
+结果:
+
+```
++-----------------------------+-----------------------------------------+
+| Time|last_value(root.ln.wf01.wt01.temperature)|
++-----------------------------+-----------------------------------------+
+|2017-11-07T23:50:00.000+08:00| 23.7|
+|2017-11-07T23:51:00.000+08:00| 22.24|
+|2017-11-07T23:52:00.000+08:00| 20.18|
+|2017-11-07T23:53:00.000+08:00| 24.58|
+|2017-11-07T23:54:00.000+08:00| 22.52|
+|2017-11-07T23:55:00.000+08:00| 25.9|
+|2017-11-07T23:56:00.000+08:00| 24.44|
+|2017-11-07T23:57:00.000+08:00| 24.39|
+|2017-11-07T23:58:00.000+08:00| 22.93|
+|2017-11-07T23:59:00.000+08:00| 21.07|
+|2017-11-08T00:00:00.000+08:00| null|
++-----------------------------+-----------------------------------------+
+Total line number = 11
+It costs 0.005s
+
++-----------------------------+-----------------------------------------+
+| Time|last_value(root.ln.wf01.wt01.temperature)|
++-----------------------------+-----------------------------------------+
+|2017-11-07T23:50:00.000+08:00| 23.7|
+|2017-11-07T23:51:00.000+08:00| 22.24|
+|2017-11-07T23:52:00.000+08:00| 20.18|
+|2017-11-07T23:53:00.000+08:00| 24.58|
+|2017-11-07T23:54:00.000+08:00| 22.52|
+|2017-11-07T23:55:00.000+08:00| 25.9|
+|2017-11-07T23:56:00.000+08:00| 24.44|
+|2017-11-07T23:57:00.000+08:00| 24.39|
+|2017-11-07T23:58:00.000+08:00| 22.93|
+|2017-11-07T23:59:00.000+08:00| 21.07|
+|2017-11-08T00:00:00.000+08:00| 21.07|
++-----------------------------+-----------------------------------------+
+Total line number = 11
+It costs 0.006s
+```
-
+解释:
+
+使用 PREVIOUSUNTILLAST 将不会填充2017-11-07T23:59:00以后的值。
### 最新数据查询
@@ -442,26 +674,31 @@ select last [COMMA ]* from < PrefixPath > [COMMA < PrefixPath >]* <
| Time | Path | Value |
```
-示例 1:查询 root.ln.wf01.wt01.speed 的最新数据点
+示例 1:查询 root.ln.wf01.wt01.status 的最新数据点
```
-> select last speed from root.ln.wf01.wt01
-
-| Time | Path | Value |
-| --- | ----------------------- | ----- |
-| 5 | root.ln.wf01.wt01.speed | 100 |
+IoTDB> select last status from root.ln.wf01.wt01
++-----------------------------+------------------------+-----+
+| Time| timeseries|value|
++-----------------------------+------------------------+-----+
+|2017-11-07T23:59:00.000+08:00|root.ln.wf01.wt01.status|false|
++-----------------------------+------------------------+-----+
+Total line number = 1
+It costs 0.000s
```
-示例 2:查询 root.ln.wf01.wt01 下 speed,status,temperature 时间戳大于等于5的最新数据点。
+示例 2:查询 root.ln.wf01.wt01 下 status,temperature 时间戳大于等于2017-11-07T23:50:00的最新数据点。
```
-> select last speed, status, temperature from root.ln.wf01 where time >= 5
-
-| Time | Path | Value |
-| --- | ---------------------------- | ----- |
-| 5 | root.ln.wf01.wt01.speed | 100 |
-| 7 | root.ln.wf01.wt01.status | true |
-| 9 | root.ln.wf01.wt01.temperature| 35.7 |
+IoTDB> select last status, temperature from root.ln.wf01.wt01 where time >= 2017-11-07T23:50:00
++-----------------------------+-----------------------------+---------+
+| Time| timeseries| value|
++-----------------------------+-----------------------------+---------+
+|2017-11-07T23:59:00.000+08:00| root.ln.wf01.wt01.status| false|
+|2017-11-07T23:59:00.000+08:00|root.ln.wf01.wt01.temperature|21.067368|
++-----------------------------+-----------------------------+---------+
+Total line number = 2
+It costs 0.002s
```
### 自动填充
@@ -507,11 +744,28 @@ select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000
在[样例数据中](https://github.com/thulab/iotdb/files/4438687/OtherMaterial-Sample.Data.txt), 该语句的执行结果如下所示:
-
+```
++-----------------------------+-------------------------------+
+| Time|root.sgcc.wf03.wt01.temperature|
++-----------------------------+-------------------------------+
+|2017-11-01T16:37:50.000+08:00| 21.93|
++-----------------------------+-------------------------------+
+Total line number = 1
+It costs 0.016s
+```
值得注意的是,如果在指定的有效时间范围内没有值,系统将不会填充空值,如下所示:
-
+```
+IoTDB> select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(float[previous, 1s])
++-----------------------------+-------------------------------+
+| Time|root.sgcc.wf03.wt01.temperature|
++-----------------------------+-------------------------------+
+|2017-11-01T16:37:50.000+08:00| null|
++-----------------------------+-------------------------------+
+Total line number = 1
+It costs 0.004s
+```
- Linear方法
@@ -551,7 +805,15 @@ select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000
在 [样例数据](https://github.com/thulab/iotdb/files/4438687/OtherMaterial-Sample.Data.txt), 该语句的执行结果如下所示:
-
+```
++-----------------------------+-------------------------------+
+| Time|root.sgcc.wf03.wt01.temperature|
++-----------------------------+-------------------------------+
+|2017-11-01T16:37:50.000+08:00| 24.746666|
++-----------------------------+-------------------------------+
+Total line number = 1
+It costs 0.017s
+```
#### 数据类型和填充方法之间的对应关系
@@ -570,10 +832,6 @@ select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000
-值得注意的是,IoTDB将针对数据类型不支持的填充方法给出错误提示,如下所示:
-
-
-
如果未指定fill方法,则每种数据类型均具有其自己的默认fill方法和参数。 对应关系如表3-7所示。
**表3-7各种数据类型的默认填充方法和参数**
@@ -618,7 +876,24 @@ select status, temperature from root.ln.wf01.wt01 limit 10
结果如下所示:
-
+```
++-----------------------------+------------------------+-----------------------------+
+| Time|root.ln.wf01.wt01.status|root.ln.wf01.wt01.temperature|
++-----------------------------+------------------------+-----------------------------+
+|2017-11-01T00:00:00.000+08:00| true| 25.96|
+|2017-11-01T00:01:00.000+08:00| true| 24.36|
+|2017-11-01T00:02:00.000+08:00| false| 20.09|
+|2017-11-01T00:03:00.000+08:00| false| 20.18|
+|2017-11-01T00:04:00.000+08:00| false| 21.13|
+|2017-11-01T00:05:00.000+08:00| false| 22.72|
+|2017-11-01T00:06:00.000+08:00| false| 20.71|
+|2017-11-01T00:07:00.000+08:00| false| 21.45|
+|2017-11-01T00:08:00.000+08:00| false| 22.58|
+|2017-11-01T00:09:00.000+08:00| false| 20.98|
++-----------------------------+------------------------+-----------------------------+
+Total line number = 10
+It costs 0.000s
+```
- 示例2:带OFFSET的LIMIT子句
@@ -634,7 +909,20 @@ select status, temperature from root.ln.wf01.wt01 limit 5 offset 3
结果如下所示:
-
+```
++-----------------------------+------------------------+-----------------------------+
+| Time|root.ln.wf01.wt01.status|root.ln.wf01.wt01.temperature|
++-----------------------------+------------------------+-----------------------------+
+|2017-11-01T00:03:00.000+08:00| false| 20.18|
+|2017-11-01T00:04:00.000+08:00| false| 21.13|
+|2017-11-01T00:05:00.000+08:00| false| 22.72|
+|2017-11-01T00:06:00.000+08:00| false| 20.71|
+|2017-11-01T00:07:00.000+08:00| false| 21.45|
++-----------------------------+------------------------+-----------------------------+
+Total line number = 5
+It costs 0.342s
+```
+
- 示例3:LIMIT子句与WHERE子句结合
@@ -650,7 +938,19 @@ select status,temperature from root.ln.wf01.wt01 where time > 2017-11-01T00:05:0
结果如下所示:
-
+```
++-----------------------------+------------------------+-----------------------------+
+| Time|root.ln.wf01.wt01.status|root.ln.wf01.wt01.temperature|
++-----------------------------+------------------------+-----------------------------+
+|2017-11-01T00:03:00.000+08:00| false| 20.18|
+|2017-11-01T00:04:00.000+08:00| false| 21.13|
+|2017-11-01T00:05:00.000+08:00| false| 22.72|
+|2017-11-01T00:06:00.000+08:00| false| 20.71|
+|2017-11-01T00:07:00.000+08:00| false| 21.45|
++-----------------------------+------------------------+-----------------------------+
+Total line number = 5
+It costs 0.000s
+```
- 示例4:LIMIT子句与GROUP BY子句组合
@@ -666,7 +966,18 @@ SQL语句子句要求返回查询结果的第3至7行(第一行编号为0行
结果如下所示:
-
+```
++-----------------------------+-------------------------------+----------------------------------------+
+| Time|count(root.ln.wf01.wt01.status)|max_value(root.ln.wf01.wt01.temperature)|
++-----------------------------+-------------------------------+----------------------------------------+
+|2017-11-04T00:00:00.000+08:00| 1440| 26.0|
+|2017-11-05T00:00:00.000+08:00| 1440| 26.0|
+|2017-11-06T00:00:00.000+08:00| 1440| 25.99|
+|2017-11-07T00:00:00.000+08:00| 1380| 26.0|
++-----------------------------+-------------------------------+----------------------------------------+
+Total line number = 4
+It costs 0.016s
+```
值得注意的是,由于当前的FILL子句只能在某个时间点填充时间序列的缺失值,也就是说,FILL子句的执行结果恰好是一行,因此LIMIT和OFFSET不会是 与FILL子句结合使用,否则将提示错误。 例如,执行以下SQL语句:
@@ -676,7 +987,9 @@ select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000
SQL语句将不会执行,并且相应的错误提示如下:
-
+```
+Msg: 401: line 1:107 mismatched input 'limit' expecting {, SLIMIT, SOFFSET, GROUP, DISABLE, ALIGN}
+```
#### 查询结果的列控制
@@ -696,7 +1009,20 @@ select * from root.ln.wf01.wt01 where time > 2017-11-01T00:05:00.000 and time <
结果如下所示:
-
+```
++-----------------------------+-----------------------------+
+| Time|root.ln.wf01.wt01.temperature|
++-----------------------------+-----------------------------+
+|2017-11-01T00:06:00.000+08:00| 20.71|
+|2017-11-01T00:07:00.000+08:00| 21.45|
+|2017-11-01T00:08:00.000+08:00| 22.58|
+|2017-11-01T00:09:00.000+08:00| 20.98|
+|2017-11-01T00:10:00.000+08:00| 25.52|
+|2017-11-01T00:11:00.000+08:00| 22.91|
++-----------------------------+-----------------------------+
+Total line number = 6
+It costs 0.000s
+```
- 示例2:带OFFSET的LIMIT子句
@@ -712,7 +1038,20 @@ select * from root.ln.wf01.wt01 where time > 2017-11-01T00:05:00.000 and time <
结果如下所示:
-
+```
++-----------------------------+------------------------+
+| Time|root.ln.wf01.wt01.status|
++-----------------------------+------------------------+
+|2017-11-01T00:06:00.000+08:00| false|
+|2017-11-01T00:07:00.000+08:00| false|
+|2017-11-01T00:08:00.000+08:00| false|
+|2017-11-01T00:09:00.000+08:00| false|
+|2017-11-01T00:10:00.000+08:00| true|
+|2017-11-01T00:11:00.000+08:00| false|
++-----------------------------+------------------------+
+Total line number = 6
+It costs 0.003s
+```
- 示例3:SLIMIT子句与GROUP BY子句结合
@@ -725,7 +1064,21 @@ select max_value(*) from root.ln.wf01.wt01 group by ([2017-11-01T00:00:00, 2017-
结果如下所示:
-
+```
++-----------------------------+-----------------------------------+
+| Time|max_value(root.ln.wf01.wt01.status)|
++-----------------------------+-----------------------------------+
+|2017-11-01T00:00:00.000+08:00| true|
+|2017-11-02T00:00:00.000+08:00| true|
+|2017-11-03T00:00:00.000+08:00| true|
+|2017-11-04T00:00:00.000+08:00| true|
+|2017-11-05T00:00:00.000+08:00| true|
+|2017-11-06T00:00:00.000+08:00| true|
+|2017-11-07T00:00:00.000+08:00| true|
++-----------------------------+-----------------------------------+
+Total line number = 7
+It costs 0.000s
+```
- 示例4:SLIMIT子句与FILL子句结合
@@ -742,19 +1095,16 @@ select * from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(floa
结果如下所示:
-
-
-值得注意的是,预期SLIMIT子句将与星形路径或前缀路径一起使用,并且当SLIMIT子句与完整路径查询一起使用时,系统将提示错误。 例如,执行以下SQL语句:
-
```
-select status,temperature from root.ln.wf01.wt01 where time > 2017-11-01T00:05:00.000 and time < 2017-11-01T00:12:00.000 slimit 1
-
++-----------------------------+--------------------------+
+| Time|root.sgcc.wf03.wt01.status|
++-----------------------------+--------------------------+
+|2017-11-01T16:35:00.000+08:00| true|
++-----------------------------+--------------------------+
+Total line number = 1
+It costs 0.007s
```
-SQL语句将不会执行,并且相应的错误提示如下:
-
-
-
#### 控制查询结果的行和列
除了对查询结果进行行或列控制之外,IoTDB还允许用户控制查询结果的行和列。 这是同时包含LIMIT子句和SLIMIT子句的完整示例。
@@ -772,7 +1122,24 @@ select * from root.ln.wf01.wt01 limit 10 offset 100 slimit 2 soffset 0
结果如下所示:
-
+```
++-----------------------------+-----------------------------+------------------------+
+| Time|root.ln.wf01.wt01.temperature|root.ln.wf01.wt01.status|
++-----------------------------+-----------------------------+------------------------+
+|2017-11-01T01:40:00.000+08:00| 21.19| false|
+|2017-11-01T01:41:00.000+08:00| 22.79| false|
+|2017-11-01T01:42:00.000+08:00| 22.98| false|
+|2017-11-01T01:43:00.000+08:00| 21.52| false|
+|2017-11-01T01:44:00.000+08:00| 23.45| true|
+|2017-11-01T01:45:00.000+08:00| 24.06| true|
+|2017-11-01T01:46:00.000+08:00| 22.6| false|
+|2017-11-01T01:47:00.000+08:00| 23.78| true|
+|2017-11-01T01:48:00.000+08:00| 24.72| true|
+|2017-11-01T01:49:00.000+08:00| 24.68| true|
++-----------------------------+-----------------------------+------------------------+
+Total line number = 10
+It costs 0.009s
+```
### 使用别名
@@ -801,10 +1168,48 @@ SQL语句是:
```
select s1,s2 from root.sg1.* ALIGN BY DEVICE
+```
+结果显示如下:
+
+```
++-----------------------------+-----------------+-----------+------+--------+
+| Time| Device|temperature|status|hardware|
++-----------------------------+-----------------+-----------+------+--------+
+|2017-11-01T00:00:00.000+08:00|root.ln.wf01.wt01| 25.96| true| null|
+|2017-11-01T00:01:00.000+08:00|root.ln.wf01.wt01| 24.36| true| null|
+|1970-01-01T08:00:00.001+08:00|root.ln.wf02.wt02| null| true| v1|
+|1970-01-01T08:00:00.002+08:00|root.ln.wf02.wt02| null| false| v2|
+|2017-11-01T00:00:00.000+08:00|root.ln.wf02.wt02| null| true| v2|
+|2017-11-01T00:01:00.000+08:00|root.ln.wf02.wt02| null| true| v2|
++-----------------------------+-----------------+-----------+------+--------+
+Total line number = 6
+It costs 0.012s
```
+“禁用对齐”指示结果集中每个时间序列都有3列。
+
+SQL语句是:
+
+ ```
+ select * from root.sg1 where time > 10 disable align
+ ```
-“禁用对齐”指示结果集中每个时间序列都有3列。 有关更多语法描述,更多语法请参照 [SQL REFERENCE](../Operation%20Manual/SQL%20Reference.md).
+结果显示如下:
+
+```
++-----------------------------+--------------------------+-----------------------------+------------------------+-----------------------------+-----------------------------+-----------------------------+------------------------+
+| Time|root.ln.wf02.wt02.hardware| Time|root.ln.wf02.wt02.status| Time|root.ln.wf01.wt01.temperature| Time|root.ln.wf01.wt01.status|
++-----------------------------+--------------------------+-----------------------------+------------------------+-----------------------------+-----------------------------+-----------------------------+------------------------+
+|1970-01-01T08:00:00.001+08:00| v1|1970-01-01T08:00:00.001+08:00| true|2017-11-01T00:00:00.000+08:00| 25.96|2017-11-01T00:00:00.000+08:00| true|
+|1970-01-01T08:00:00.002+08:00| v2|1970-01-01T08:00:00.002+08:00| false|2017-11-01T00:01:00.000+08:00| 24.36|2017-11-01T00:01:00.000+08:00| true|
+|2017-11-01T00:00:00.000+08:00| v2|2017-11-01T00:00:00.000+08:00| true| null| null| null| null|
+|2017-11-01T00:01:00.000+08:00| v2|2017-11-01T00:01:00.000+08:00| true| null| null| null| null|
++-----------------------------+--------------------------+-----------------------------+------------------------+-----------------------------+-----------------------------+-----------------------------+------------------------+
+Total line number = 4
+It costs 0.018s
+```
+
+有关更多语法描述,更多语法请参照 [SQL REFERENCE](../Operation%20Manual/SQL%20Reference.md).
#### 错误处理
@@ -817,7 +1222,20 @@ select status,temperature from root.ln.wf01.wt01 where time > 2017-11-01T00:05:0
结果如下所示:
-
+```
++-----------------------------+------------------------+-----------------------------+
+| Time|root.ln.wf01.wt01.status|root.ln.wf01.wt01.temperature|
++-----------------------------+------------------------+-----------------------------+
+|2017-11-01T00:06:00.000+08:00| false| 20.71|
+|2017-11-01T00:07:00.000+08:00| false| 21.45|
+|2017-11-01T00:08:00.000+08:00| false| 22.58|
+|2017-11-01T00:09:00.000+08:00| false| 20.98|
+|2017-11-01T00:10:00.000+08:00| true| 25.52|
+|2017-11-01T00:11:00.000+08:00| false| 22.91|
++-----------------------------+------------------------+-----------------------------+
+Total line number = 6
+It costs 0.005s
+```
当LIMIT / SLIMIT子句的参数N / SN超过允许的最大值(N / SN的类型为int32)时,系统将提示错误。 例如,执行以下SQL语句:
@@ -828,7 +1246,9 @@ select status,temperature from root.ln.wf01.wt01 where time > 2017-11-01T00:05:0
SQL语句将不会执行,并且相应的错误提示如下:
-
+```
+Msg: 303: check metadata error: Out of range. LIMIT : N should be Int32.
+```
当LIMIT / LIMIT子句的参数N / SN不是正整数时,系统将提示错误。 例如,执行以下SQL语句:
@@ -839,7 +1259,9 @@ select status,temperature from root.ln.wf01.wt01 where time > 2017-11-01T00:05:0
SQL语句将不会执行,并且相应的错误提示如下:
-
+```
+Msg: 401: line 1:129 mismatched input '.' expecting {, SLIMIT, OFFSET, SOFFSET, GROUP, DISABLE, ALIGN}
+```
当LIMIT子句的参数OFFSET超过结果集的大小时,IoTDB将返回空结果集。 例如,执行以下SQL语句:
@@ -850,7 +1272,14 @@ select status,temperature from root.ln.wf01.wt01 where time > 2017-11-01T00:05:0
结果如下所示:
-
+```
++----+------------------------+-----------------------------+
+|Time|root.ln.wf01.wt01.status|root.ln.wf01.wt01.temperature|
++----+------------------------+-----------------------------+
++----+------------------------+-----------------------------+
+Empty set.
+It costs 0.005s
+```
当SLIMIT子句的参数SOFFSET不小于可用时间序列数时,系统将提示错误。 例如,执行以下SQL语句:
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/Planner.java b/server/src/main/java/org/apache/iotdb/db/qp/Planner.java
index e6db9c0e5bb4..1f5ae1058388 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/Planner.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/Planner.java
@@ -24,8 +24,6 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import org.apache.iotdb.db.conf.IoTDBConfig;
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.exception.metadata.IllegalPathException;
import org.apache.iotdb.db.exception.query.LogicalOperatorException;
import org.apache.iotdb.db.exception.query.LogicalOptimizeException;
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java b/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
index 2cdd2d272ae1..67a03cfc49fc 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
@@ -1035,7 +1035,7 @@ public Operator visitGroupByFillStatement(GroupByFillStatementContext ctx) {
public Operator visitFillStatement(FillStatementContext ctx) {
parseFillClause(ctx.fillClause(), queryOp);
if (ctx.slimitClause() != null) {
- queryOp = (QueryOperator) visit(ctx.slimitClause());
+ parseSlimitClause(ctx.slimitClause(), queryOp);
}
if (ctx.alignByDeviceClauseOrDisableAlign() != null) {
if (ctx.alignByDeviceClauseOrDisableAlign().alignByDeviceClause() != null) {