You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2022/07/06 12:10:04 UTC

[iotdb] branch ChangeFillDoc created (now 1541bd72c7)

This is an automated email from the ASF dual-hosted git repository.

jackietien pushed a change to branch ChangeFillDoc
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at 1541bd72c7 Add Fill Doc

This branch includes the following new commits:

     new 8eb3515da4 FillDoc
     new 1541bd72c7 Add Fill Doc

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[iotdb] 02/02: Add Fill Doc

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jackietien pushed a commit to branch ChangeFillDoc
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 1541bd72c7a286ec34adf0cffa04063cb28cdf29
Author: JackieTien97 <ja...@gmail.com>
AuthorDate: Wed Jul 6 20:09:25 2022 +0800

    Add Fill Doc
---
 docs/UserGuide/Query-Data/Fill-Null-Value.md       | 360 +++++--------------
 docs/zh/UserGuide/Query-Data/Fill-Null-Value.md    | 399 +++++----------------
 .../db/mpp/plan/statement/literal/LongLiteral.java |   8 +-
 3 files changed, 195 insertions(+), 572 deletions(-)

diff --git a/docs/UserGuide/Query-Data/Fill-Null-Value.md b/docs/UserGuide/Query-Data/Fill-Null-Value.md
index 65d7709290..291f3e5326 100644
--- a/docs/UserGuide/Query-Data/Fill-Null-Value.md
+++ b/docs/UserGuide/Query-Data/Fill-Null-Value.md
@@ -23,9 +23,9 @@
 
 When executing some queries, there may be no data for some columns in some rows, and data in these locations will be null, but this kind of null value is not conducive to data visualization and analysis, and the null value needs to be filled.
 
-Fill null value allows the user to fill the query result with null values according to a specific method, such as taking the previous value that is not null, or linear interpolation. The query result after filling the null value can better reflect the data distribution, which is beneficial for users to perform data analysis.
+Fill null value allows the user to fill any query result with null values according to a specific method, such as taking the previous value that is not null, or linear interpolation. The query result after filling the null value can better reflect the data distribution, which is beneficial for users to perform data analysis.
 
-In IoTDB, users can use the FILL clause to specify the fill mode when data is missing at a point in time or a time window. If the queried point's value is not null, the fill function will not work.
+In IoTDB, users can use the FILL clause to specify the fill mode when data is missing. If the queried point's value is not null, the fill function will not work.
 
 ## Fill Methods
 
@@ -55,325 +55,145 @@ fill(previous)
 Here we give an example of filling null values using the previous method. The SQL statement is as follows:
 
 ```sql
-select temperature from root.sgcc.wf03.wt01 where time => 2017-11-01T16:37:00.000 and time <= 2017-11-01T16:40:00.000
+select temperature, status from root.sgcc.wf03.wt01 where time => 2017-11-01T16:37:00.000 and time <= 2017-11-01T16:40:00.000
 ```
 if we don't use any fill methods, the original result will be like:
 
+```
++-----------------------------+-------------------------------+--------------------------+
+|                         Time|root.sgcc.wf03.wt01.temperature|root.sgcc.wf03.wt01.status|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:37:00.000+08:00|                          21.93|                      true|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:38:00.000+08:00|                           null|                     false|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:39:00.000+08:00|                          22.23|                      null|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:40:00.000+08:00|                          23.43|                      null|
++-----------------------------+-------------------------------+--------------------------+
+Total line number = 4
+```
 
-
+if we use previous fill, sql will be like:
 ```sql
 select temperature from root.sgcc.wf03.wt01 where time => 2017-11-01T16:37:00.000 and time <= 2017-11-01T16:40:00.000 fill(previous)
 ```
 
-```
-+-----------------------------+-------------------------------+
-|                         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:
+previous filled result will be like:
 
 ```
-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
++-----------------------------+-------------------------------+--------------------------+
+|                         Time|root.sgcc.wf03.wt01.temperature|root.sgcc.wf03.wt01.status|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:37:00.000+08:00|                          21.93|                      true|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:38:00.000+08:00|                          21.93|                     false|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:39:00.000+08:00|                          22.23|                     false|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:40:00.000+08:00|                          23.43|                     false|
++-----------------------------+-------------------------------+--------------------------+
+Total line number = 4
 ```
 
+> Note: If the first value of this column is null, we will keep first value as null and won't fill it until we meet first non-null value
+
 ### Linear Fill
 
 When the value in the queried timestamp is null, the value of the previous and the next timestamp is used to fill the blank. The formalized linear method is as follows:
 
 ```sql
-select <path> from <prefixPath> where time = <T> fill(linear(, <before_range>, <after_range>)?)
+fill(linear)
 ```
-Detailed descriptions of all parameters are given in following table:
-
-| Parameter name (case insensitive) | Interpretation                                               |
-| :-------------------------------- | :----------------------------------------------------------- |
-| path, prefixPath                  | query path; mandatory field                                  |
-| T                                 | query timestamp (only one can be specified); mandatory field |
-| before\_range, after\_range       | represents the valid time range of the linear method. The previous method works when there are values in the [T-before\_range, T+after\_range] range. When before\_range and after\_range are not explicitly specified, default\_fill\_interval is used. -1 represents infinity; optional field |
-| </center>                         |                                                              |
-
-**Note** if the timeseries has a valid value at query timestamp T, this value will be used as the linear fill value.
-Otherwise, if there is no valid fill value in either range [T - before_range, T] or [T, T + after_range], linear fill method will return null.
 
 Here we give an example of filling null values using the linear method. The SQL statement is as follows:
 
 ```sql
-select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(linear, 1m, 1m)
+select temperature from root.sgcc.wf03.wt01 where time => 2017-11-01T16:37:00.000 and time <= 2017-11-01T16:40:00.000 fill(linear)
 ```
-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- [...]
 
-On the [sample data](https://github.com/thulab/iotdb/files/4438687/OtherMaterial-Sample.Data.txt), the execution result of this statement is shown below:
+linear filled result will be like:
 
 ```
-+-----------------------------+-------------------------------+
-|                         Time|root.sgcc.wf03.wt01.temperature|
-+-----------------------------+-------------------------------+
-|2017-11-01T16:37:50.000+08:00|                      24.746666|
-+-----------------------------+-------------------------------+
-Total line number = 1
-It costs 0.017s
++-----------------------------+-------------------------------+--------------------------+
+|                         Time|root.sgcc.wf03.wt01.temperature|root.sgcc.wf03.wt01.status|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:37:00.000+08:00|                          21.93|                      true|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:38:00.000+08:00|                          22.08|                     false|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:39:00.000+08:00|                          22.23|                      null|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:40:00.000+08:00|                          23.43|                      null|
++-----------------------------+-------------------------------+--------------------------+
+Total line number = 4
 ```
 
+
+> Note: If all the values before current value are null or all the values after current value are null, we will keep current value as null and won't fill it.
+> Note: If the column's data type is boolean/text, we neither fill it nor throw exception, just keep it as it is.
+
 ### Value Fill
 
 When the value in the queried timestamp is null, given fill value is used to fill the blank. The formalized value method is as follows:
 
 ```sql
-select <path> from <prefixPath> where time = <T> fill(constant)
+fill(constant)
 ```
-Detailed descriptions of all parameters are given in following table:
-
-| Parameter name (case insensitive) | Interpretation                                               |
-| :-------------------------------- | :----------------------------------------------------------- |
-| path, prefixPath                  | query path; mandatory field                                  |
-| T                                 | query timestamp (only one can be specified); mandatory field |
-| constant                          | represents given fill value                                  |
-| </center>                         |                                                              |
-
-**Note** if the timeseries has a valid value at query timestamp T, this value will be used as the specific fill value.
 
 Here we give an example of filling null values using the value method. The SQL statement is as follows:
 
 ```sql
 select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(2.0)
 ```
-which means:
 
-Because the timeseries root.sgcc.wf03.wt01.temperature is null at 2017-11-01T16:37:50.000, the system uses given specific value 2.0 to fill
-
-On the [sample data](https://github.com/thulab/iotdb/files/4438687/OtherMaterial-Sample.Data.txt), the execution result of this statement is shown below:
+float constant filled result will be like:
 
 ```
-+-----------------------------+-------------------------------+
-|                         Time|root.sgcc.wf03.wt01.temperature|
-+-----------------------------+-------------------------------+
-|2017-11-01T16:37:50.000+08:00|                            2.0|
-+-----------------------------+-------------------------------+
-Total line number = 1
-It costs 0.007s
++-----------------------------+-------------------------------+--------------------------+
+|                         Time|root.sgcc.wf03.wt01.temperature|root.sgcc.wf03.wt01.status|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:37:00.000+08:00|                          21.93|                      true|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:38:00.000+08:00|                            2.0|                     false|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:39:00.000+08:00|                          22.23|                      null|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:40:00.000+08:00|                          23.43|                      null|
++-----------------------------+-------------------------------+--------------------------+
+Total line number = 4
 ```
 
-When using the ValueFill, note that IoTDB will not fill the query result if the data type is different from the input constant
-
-example:
-
 ```sql
-select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill('test')
+select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(true)
 ```
 
-result:
+boolean constant filled result will be like:
 
 ```
-+-----------------------------+-------------------------------+
-|                         Time|root.sgcc.wf03.wt01.temperature|
-+-----------------------------+-------------------------------+
-|2017-11-01T16:37:50.000+08:00|                          null |
-+-----------------------------+-------------------------------+
-Total line number = 1
-It costs 0.007s
++-----------------------------+-------------------------------+--------------------------+
+|                         Time|root.sgcc.wf03.wt01.temperature|root.sgcc.wf03.wt01.status|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:37:00.000+08:00|                          21.93|                      true|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:38:00.000+08:00|                           null|                     false|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:39:00.000+08:00|                          22.23|                      true|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:40:00.000+08:00|                          23.43|                      true|
++-----------------------------+-------------------------------+--------------------------+
+Total line number = 4
 ```
 
-## Downsampling with Fill
-IoTDB supports null value filling of original down-frequency aggregate results. Previous, Linear, and Value fill methods can be used in any aggregation operator in a query statement, but only one fill method can be used in a query statement. In addition, the following two points should be paid attention to when using:
-- GroupByFill will not fill the aggregate result of count in any case, because in IoTDB, if there is no data in a time range, the aggregate result of count is 0.
-- GroupByFill will classify sum aggregation results. In IoTDB, if a query interval does not contain any data, sum aggregation result is null, and GroupByFill will fill sum. If the sum of a time range happens to be 0, GroupByFill will not fill the value
-
-The syntax of downsampling aggregate query is similar to that of single fill query. Simple examples and usage details are listed below:
-
-### Difference Between PREVIOUSUNTILLAST And PREVIOUS:
-
-* 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.
-
-first, we check value root.ln.wf01.wt01.temperature when time after 2017-11-07T23:49:00.
-
-```
-IoTDB> SELECT temperature FROM root.ln.wf01.wt01 where time >= 2017-11-07T23:49:00
-+-----------------------------+-----------------------------+
-|                         Time|root.ln.wf01.wt01.temperature|
-+-----------------------------+-----------------------------+
-|2017-11-07T23:49:00.000+08:00|                         23.7|
-|2017-11-07T23:51:00.000+08:00|                        22.24|
-|2017-11-07T23:53:00.000+08:00|                        24.58|
-|2017-11-07T23:54:00.000+08:00|                        22.52|
-|2017-11-07T23:57:00.000+08:00|                        24.39|
-|2017-11-08T00:00:00.000+08:00|                        21.07|
-+-----------------------------+-----------------------------+
-Total line number = 6
-It costs 0.010s
-```
+> Note: When using the ValueFill, IoTDB neither fill the query result if the data type is different from the input constant nor throw exception, just keep it as it is.
+> Note: If constant value is larger than Integer.MAX_VALUE, IoTDB neither fill the query result if the data type is int32 nor throw exception, just keep it as it is.
 
-we will find that in root.ln.wf01.wt01.temperature the first time and value are 2017-11-07T23:49:00 and 23.7 and the last time and value are 2017-11-08T00:00:00 and 21.07 respectively.
+#### Constant Fill Type Consistency
 
-Then execute SQL statements:
-
-```sql
-SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-07T23:59:00),1m) FILL (PREVIOUSUNTILLAST);
-SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-07T23:59:00),1m) FILL (PREVIOUS);
-```
-
-result:
-
-```
-IoTDB> SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-07T23:59:00),1m) FILL (PREVIOUSUNTILLAST);
-+-----------------------------+-----------------------------------------+
-|                         Time|last_value(root.ln.wf01.wt01.temperature)|
-+-----------------------------+-----------------------------------------+
-|2017-11-07T23:50:00.000+08:00|                                     null|
-|2017-11-07T23:51:00.000+08:00|                                    22.24|
-|2017-11-07T23:52:00.000+08:00|                                    22.24|
-|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|                                    22.52|
-|2017-11-07T23:56:00.000+08:00|                                    22.52|
-|2017-11-07T23:57:00.000+08:00|                                    24.39|
-|2017-11-07T23:58:00.000+08:00|                                     null|
-+-----------------------------+-----------------------------------------+
-Total line number = 9
-It costs 0.007s
-
-IoTDB> SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-07T23:59:00),1m) FILL (PREVIOUS);
-+-----------------------------+-----------------------------------------+
-|                         Time|last_value(root.ln.wf01.wt01.temperature)|
-+-----------------------------+-----------------------------------------+
-|2017-11-07T23:50:00.000+08:00|                                     null|
-|2017-11-07T23:51:00.000+08:00|                                    22.24|
-|2017-11-07T23:52:00.000+08:00|                                    22.24|
-|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|                                    22.52|
-|2017-11-07T23:56:00.000+08:00|                                    22.52|
-|2017-11-07T23:57:00.000+08:00|                                    24.39|
-|2017-11-07T23:58:00.000+08:00|                                    24.39|
-+-----------------------------+-----------------------------------------+
-Total line number = 9
-It costs 0.006s
-```
-
-which means:
-
-using PREVIOUSUNTILLAST won't fill time after 2017-11-07T23:57.
-
-### Fill The First And Last Null Value
-
-The fill methods of IoTDB can be divided into three categories: PreviousFill, LinearFill and ValueFill. Where PreviousFill needs to know the first not-null value before the null value, LinearFill needs to know the first not-null value before and after the null value to fill. If the first or last value in the result returned by a query statement is null, a sequence of null values may exist at the beginning or the end of the result set, which does not meet GroupByFill's expectations.
-
-In the above example, there is no data in the first time interval [2017-11-07T23:50:00, 2017-11-07T23:51:00). The previous time interval with data is [2017-11-01T23:49:00, 2017-11-07T23:50:00). The first interval can be filled by setting PREVIOUS to fill the forward query parameter before_range as shown in the following example:
-
-```sql
-SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-07T23:59:00),1m) FILL (PREVIOUS, 1m);
-```
-
-result:
-```
-IoTDB> SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-07T23:59:00),1m) FILL (PREVIOUS, 1m);
-+-----------------------------+-----------------------------------------+
-|                         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|                                    22.24|
-|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|                                    22.52|
-|2017-11-07T23:56:00.000+08:00|                                     null|
-|2017-11-07T23:57:00.000+08:00|                                    24.39|
-|2017-11-07T23:58:00.000+08:00|                                    24.39|
-+-----------------------------+-----------------------------------------+
-Total line number = 9
-It costs 0.005s
-```
-
-explain:
-
-In order not to conflict with the original semantics, when before_range and after_range parameters are not set, the null value of GroupByFill is filled with the first/next not-null value of the null value. When setting before_range, after_range parameters, and the timestamp of the null record is set to T. GroupByFill takes the previous/last not-null value in [t-before_range, t+after_range) to complete the fill.
-
-Because there is no data in the time interval [2017-11-07T23:55:00, 2017-11-07T23:57:00), Therefore, although this example fills the data of [2017-11-07T23:50:00, 2017-11-07T23:51:00) by setting before_range, due to the small before_range, [2017-11-07T23:56:00, 2017-11-07T23:57:00) data cannot be filled.
-
-Before_range and after_range parameters can also be filled with LINEAR, as shown in the following example:
-
-```sql
-SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-07T23:59:00),1m) FILL (LINEAR, 5m, 5m);
-```
-
-result:
-
-```
-IoTDB> SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-07T23:59:00),1m) FILL (LINEAR, 5m, 5m);
-+-----------------------------+-----------------------------------------+
-|                         Time|last_value(root.ln.wf01.wt01.temperature)|
-+-----------------------------+-----------------------------------------+
-|2017-11-07T23:50:00.000+08:00|                                22.970001|
-|2017-11-07T23:51:00.000+08:00|                                    22.24|
-|2017-11-07T23:52:00.000+08:00|                                    23.41|
-|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|                                23.143333|
-|2017-11-07T23:56:00.000+08:00|                                23.766666|
-|2017-11-07T23:57:00.000+08:00|                                    24.39|
-|2017-11-07T23:58:00.000+08:00|                                23.283333|
-+-----------------------------+-----------------------------------------+
-Total line number = 9
-It costs 0.008s
-```
-
-> Note: Set the initial down-frequency query interval to [start_time, end_time). The query result will keep the same as not setting before_range and after_range parameters. However, the query interval is changed to [start_time - before_range, end_time + after_range). Therefore, the efficiency will be affected when these two parameters are set too large. Please pay attention to them when using.
-
-### Value Fill
-The ValueFill method parses the input constant value into a string. During fill, the string constant is converted to the corresponding type of data. If the conversion succeeds, the null record will be filled; otherwise, it is not filled. Examples are as follows:
-
-```sql
-SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-07T23:59:00),1m) FILL (20.0)
-SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-07T23:59:00),1m) FILL ('temperature')
-```
-
-result:
-```
-IoTDB> SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-07T23:59:00),1m) FILL (20.0);
-+-----------------------------+-----------------------------------------+
-|                         Time|last_value(root.ln.wf01.wt01.temperature)|
-+-----------------------------+-----------------------------------------+
-|2017-11-07T23:50:00.000+08:00|                                     20.0|
-|2017-11-07T23:51:00.000+08:00|                                    22.24|
-|2017-11-07T23:52:00.000+08:00|                                     20.0|
-|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|                                     20.0|
-|2017-11-07T23:56:00.000+08:00|                                     20.0|
-|2017-11-07T23:57:00.000+08:00|                                    24.39|
-|2017-11-07T23:58:00.000+08:00|                                     20.0|
-+-----------------------------+-----------------------------------------+
-Total line number = 9
-It costs 0.007s
-
-IoTDB> SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-07T23:59:00),1m) FILL ('temperature');
-+-----------------------------+-----------------------------------------+
-|                         Time|last_value(root.ln.wf01.wt01.temperature)|
-+-----------------------------+-----------------------------------------+
-|2017-11-07T23:50:00.000+08:00|                                     null|
-|2017-11-07T23:51:00.000+08:00|                                    22.24|
-|2017-11-07T23:52:00.000+08:00|                                     null|
-|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|                                     null|
-|2017-11-07T23:56:00.000+08:00|                                     null|
-|2017-11-07T23:57:00.000+08:00|                                    24.39|
-|2017-11-07T23:58:00.000+08:00|                                     null|
-+-----------------------------+-----------------------------------------+
-Total line number = 9
-It costs 0.005s
-```
\ No newline at end of file
+| Constant Value Data Type | Support Data Type                 |
+|:-------------------------|:----------------------------------|
+| boolean                  | boolean, text                     |
+| int64                    | int32, int64, float, double, text |
+| double                   | float, double, text               |
+| text                     | text                              |
+| </center>                |                                   |
\ No newline at end of file
diff --git a/docs/zh/UserGuide/Query-Data/Fill-Null-Value.md b/docs/zh/UserGuide/Query-Data/Fill-Null-Value.md
index b51f111db0..e561c4e961 100644
--- a/docs/zh/UserGuide/Query-Data/Fill-Null-Value.md
+++ b/docs/zh/UserGuide/Query-Data/Fill-Null-Value.md
@@ -19,20 +19,21 @@
 
 -->
 
+
 # 查询补空值
 
-当对序列进行分段聚合时,某一段时间可能不存在数据,则此段数据的聚合结果为空,但这种空值不利于进行数据可视化展示和分析,需要对空值进行填补。
+当执行一些查询时,结果集的某行某列可能没有数据,则此位置结果为空,但这种空值不利于进行数据可视化展示和分析,需要对空值进行填补。
 
-查询补空值允许用户按照特定的方法对查询结果填充空值,如取前一个不为空的值,或线性插值。补空值之后的查询结果能更好地反映数据分布,有利于用户进行数据分析。
+查询补空值允许用户按照特定的方法对任何查询的结果填充空值,如取前一个不为空的值,或线性插值。补空值之后的查询结果能更好地反映数据分布,有利于用户进行数据分析。
 
-在 IoTDB 中,用户可以使用 FILL 子句指定某一时间点或一时间窗口数据缺失的情况下的填充模式。如果查询点空,则填充功能将不起作用。
+在 IoTDB 中,用户可以使用 FILL 子句指定数据缺失的情况下的填充模式。如果查询点不为空,则填充功能将不起作用。
 
 ## 填充方法
 
 IoTDB 目前支持  `previous` , `linear`,  `value` 三种空值填充方式,数据类型和支持的填充方法如下表所示:
 
-| 数据类型 | 支持的填充方法          |
-| :------- | :---------------------- |
+| 数据类型 | 支持的填充方法                 |
+| :------- |:------------------------|
 | boolean  | previous, value         |
 | int32    | previous, linear, value |
 | int64    | previous, linear, value |
@@ -40,357 +41,153 @@ IoTDB 目前支持  `previous` , `linear`,  `value` 三种空值填充方式,
 | double   | previous, linear, value |
 | text     | previous, value         |
 
-> 注意:在 Fill 语句中只能指定一种填充方法。空值填充兼容 0.12 版本及以前的语法(即 fill((<data_type>[<fill_method>(, <before_range>, <after_range>)?])+)),但老的语法也不能同时指定多种填充方式。
-
-## 单点补空值
-
-当某一特定时间戳的数据为空时,可以使用单值填充对空值进行填充,详细说明如下:
+> 注意:在 Fill 语句中只能指定一种填充方法。空值填充不兼容 0.13 版本及以前的语法(即 fill((<data_type>[<fill_method>(, <before_range>, <after_range>)?])+))
 
 ### Previous 填充
 
 当查询的时间戳下数据为空时,将使用前一个时间戳的值来填充空白。 语法定义如下:
 
+
 ```sql
-select <path> from <prefixPath> where time = <T> fill(previous(, <before_range>)?)
+fill(previous)
 ```
 
-下表给出了所有参数的详细说明:
-
-| 参数名称(不区分大小写) | 解释                                                         |
-| :----------------------- | :----------------------------------------------------------- |
-| path, prefixPath         | 查询路径; 必填项                                            |
-| T                        | 查询时间戳(只能指定一个); 必填项                          |
-| before\_range            | 表示前一种方法的有效时间范围。 当 [T-before\_range,T] 范围内的值存在时,前一种方法将起作用。 如果未指定 before_range,则 before_range 会使用默认值 default_fill_interval; -1 表示无穷大; 可选字段 |
-
 在这里,我们举一个使用 Previous 方法填充空值的示例。 SQL 语句如下:
 
 ```sql
-select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(previous, 1m) 
+select temperature, status from root.sgcc.wf03.wt01 where time => 2017-11-01T16:37:00.000 and time <= 2017-11-01T16:40:00.000
 ```
+如果我们不使用任何填充方式,原始的查询结果如下:
 
-含义:
+```
++-----------------------------+-------------------------------+--------------------------+
+|                         Time|root.sgcc.wf03.wt01.temperature|root.sgcc.wf03.wt01.status|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:37:00.000+08:00|                          21.93|                      true|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:38:00.000+08:00|                           null|                     false|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:39:00.000+08:00|                          22.23|                      null|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:40:00.000+08:00|                          23.43|                      null|
++-----------------------------+-------------------------------+--------------------------+
+Total line number = 4
+```
 
-由于时间根目录 root.sgcc.wf03.wt01.temperature 在 2017-11-01T16:37:50.000 为空,因此系统使用以前的时间戳 2017-11-01T16:37:00.000(且时间戳位于 [2017-11-01T16:36:50.000, 2017-11-01T16:37:50.000] 范围)进行填充和显示。
+如果我们使用previous填充, SQL 语句如下:
+```sql
+select temperature from root.sgcc.wf03.wt01 where time => 2017-11-01T16:37:00.000 and time <= 2017-11-01T16:40:00.000 fill(previous)
+```
 
-在 [样例数据](https://github.com/thulab/iotdb/files/4438687/OtherMaterial-Sample.Data.txt) 中, 该语句的执行结果如下所示:
+previous填充后的结果如下:
 
 ```
-+-----------------------------+-------------------------------+
-|                         Time|root.sgcc.wf03.wt01.temperature|
-+-----------------------------+-------------------------------+
-|2017-11-01T16:37:50.000+08:00|                          21.93|
-+-----------------------------+-------------------------------+
-Total line number = 1
-It costs 0.016s
++-----------------------------+-------------------------------+--------------------------+
+|                         Time|root.sgcc.wf03.wt01.temperature|root.sgcc.wf03.wt01.status|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:37:00.000+08:00|                          21.93|                      true|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:38:00.000+08:00|                          21.93|                     false|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:39:00.000+08:00|                          22.23|                     false|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:40:00.000+08:00|                          23.43|                     false|
++-----------------------------+-------------------------------+--------------------------+
+Total line number = 4
 ```
 
-值得注意的是,如果在指定的有效时间范围内没有值,系统将不会填充空值,如下所示:
+> 注意:如果结果集的某一列第一个值就位空,那我们不会填充这一列,直到遇到这一列第一个不为空的值为止。
 
-```
-IoTDB> select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(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 填充
 
 当查询的时间戳下数据为空时,将使用前一个和下一个时间戳的值来填充空白。 语法定义如下:
 
 ```sql
-select <path> from <prefixPath> where time = <T> fill(linear(, <before_range>, <after_range>)?)
+fill(linear)
 ```
 
-下表给出了所有参数的详细说明:
-
-| 参数名称(不区分大小写)    | 解释                                                         |
-| :-------------------------- | :----------------------------------------------------------- |
-| path, prefixPath            | 查询路径; 必填项                                            |
-| T                           | 查询时间戳(只能指定一个); 必填项                          |
-| before\_range, after\_range | 表示线性方法的有效时间范围。 当 [T - before\_range,T + after\_range] 范围内的值存在时,前一种方法将起作用。 如果未明确指定 before\_range 和 after\_range,则使用 default\_fill\_interval。 -1 表示无穷大; 可选字段 |
-
-需要注意的是一旦时间序列在查询时间戳 T 时刻存在有效值,线性填充就会使用这个值作为结果返回。
-除此之外,如果在 [T - before_range, T] 或 [T, T + after_range] 两个范围中任意一个范围内不存在有效填充值,则线性填充返回 null 值。
-
 在这里,我们举一个使用线性方法填充空值的示例。 SQL 语句如下:
 
 ```sql
-select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(linear, 1m, 1m)
+select temperature from root.sgcc.wf03.wt01 where time => 2017-11-01T16:37:00.000 and time <= 2017-11-01T16:40:00.000 fill(linear)
 ```
 
-含义:
-
-由于时间根目录 root.sgcc.wf03.wt01.temperature 在 2017-11-01T16:37:50.000 为空,因此系统使用以前的时间戳 2017-11-01T16:37:00.000(且时间戳位于 [2017-11-01T16:36:50.000,2017-11-01T16:37:50.000) 时间范围)及其值 21.927326,下一个时间戳记 2017-11-01T16:38:00.000(且时间戳记位于 (2017-11-01T16:37:50.000, 2017-11-01T16:38:50.000) 时间范围)及其值 25.311783 以执行线性拟合计算:
-
-21.927326 +(25.311783-21.927326)/ 60s * 50s = 24.747707
-
-在 [样例数据](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.747707|
-+-----------------------------+-------------------------------+
-Total line number = 1
-It costs 0.017s
++-----------------------------+-------------------------------+--------------------------+
+|                         Time|root.sgcc.wf03.wt01.temperature|root.sgcc.wf03.wt01.status|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:37:00.000+08:00|                          21.93|                      true|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:38:00.000+08:00|                          22.08|                     false|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:39:00.000+08:00|                          22.23|                      null|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:40:00.000+08:00|                          23.43|                      null|
++-----------------------------+-------------------------------+--------------------------+
+Total line number = 4
 ```
 
+> 注意:如果某个值之前的所有值都为空,或者某个值之后的所有值都为空,我们不会填充该值。
+> 注意:如果某列的数据类型为boolean/text,我们既不会填充它,也不会报错,只是让那一列保持原样。
+
 ### Value 填充
 
 当查询的时间戳下数据为空时,将使用给定的值来填充空白。语法定义如下:
 
-```sql
-select <path> from <prefixPath> where time = <T> fill(constant)
-```
-
-下表给出了所有参数的详细说明:
-
-| 参数名称(不区分大小写) | 解释                                |
-| :----------------------- | :---------------------------------- |
-| path, prefixPath         | 查询路径; 必填项                   |
-| T                        | 查询时间戳(只能指定一个); 必填项 |
-| constant                 | 给定的填充值;必填项                |
-
-需要注意的是一旦时间序列在查询时间戳T时刻存在有效值,特定值填充就会使用这个值作为结果返回。
-
-
-在这里,我们举一个使用特定值方法填充空值的示例。 SQL语句如下:
-
 ```sql
 select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(2.0)
 ```
 
-含义:
-
-由于时间序列 root.sgcc.wf03.wt01.temperature 在 2017-11-01T16:37:50.000 为空,因此使用给定的值 2.0 进行填充:
-
-在 [样例数据](https://github.com/thulab/iotdb/files/4438687/OtherMaterial-Sample.Data.txt) 中, 该语句的执行结果如下所示:
+使用float类型的常量填充后的结果如下:
 
 ```
-+-----------------------------+-------------------------------+
-|                         Time|root.sgcc.wf03.wt01.temperature|
-+-----------------------------+-------------------------------+
-|2017-11-01T16:37:50.000+08:00|                           2.0 |
-+-----------------------------+-------------------------------+
-Total line number = 1
-It costs 0.007s
++-----------------------------+-------------------------------+--------------------------+
+|                         Time|root.sgcc.wf03.wt01.temperature|root.sgcc.wf03.wt01.status|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:37:00.000+08:00|                          21.93|                      true|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:38:00.000+08:00|                            2.0|                     false|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:39:00.000+08:00|                          22.23|                      null|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:40:00.000+08:00|                          23.43|                      null|
++-----------------------------+-------------------------------+--------------------------+
+Total line number = 4
 ```
 
-在使用 VALUE 方法填充时需要注意,如果查询结果的数据类型与输入常量值不同,IoTDB 将不进行填充
-
-示例:
 ```sql
-select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill('test')
+select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(true)
 ```
 
-结果:
-```
-+-----------------------------+-------------------------------+
-|                         Time|root.sgcc.wf03.wt01.temperature|
-+-----------------------------+-------------------------------+
-|2017-11-01T16:37:50.000+08:00|                          null |
-+-----------------------------+-------------------------------+
-Total line number = 1
-It costs 0.007s
-```
-
-## 降采样补空值
-
-IoTDB 支持对原降采样结果进行空值填充,`previous`、`linear`、`value` 填充方式均可作用于查询语句中的任一聚合算子,但一条查询语句只能使用一种空值填充方式。此外,使用时需要注意以下两点:
-
-- 在任何情形下都不会填充 `count` 的聚合结果,因为对于不存在任数据的查询区间,`count` 的结果为 0。
-- 分类处理 sum 的聚合结果:若某个查询区间不存在任何数据,sum 的聚合结果为 null,将被 GroupByFill 填充;若某个查询区间内 sum 的聚合结果恰好为 0,那么 GroupByFill 不会填充这个值。
-
-降采样补空值查询语法同单点补空值查询语法相似,下面列出简单的示例和使用细节:
-
-### PREVIOUS 和 PREVIOUSUNTILLAST 的区别
-
-* PREVIOUS:只要空值前边有值,就会用其填充空值。
-* PREVIOUSUNTILLAST:不会填充此序列最新点后的空值。
-
-首先检查一下 root.ln.wf01.wt01.temperature 在时间 2017-11-07T23:49:00 以后的值:
+使用boolean类型的常量填充后的结果如下:
 
 ```
-IoTDB> SELECT temperature FROM root.ln.wf01.wt01 where time >= 2017-11-07T23:49:00
-+-----------------------------+-----------------------------+
-|                         Time|root.ln.wf01.wt01.temperature|
-+-----------------------------+-----------------------------+
-|2017-11-07T23:49:00.000+08:00|                         23.7|
-|2017-11-07T23:51:00.000+08:00|                        22.24|
-|2017-11-07T23:53:00.000+08:00|                        24.58|
-|2017-11-07T23:54:00.000+08:00|                        22.52|
-|2017-11-07T23:57:00.000+08:00|                        24.39|
-|2017-11-08T00:00:00.000+08:00|                        21.07|
-+-----------------------------+-----------------------------+
-Total line number = 6
-It costs 0.010s
++-----------------------------+-------------------------------+--------------------------+
+|                         Time|root.sgcc.wf03.wt01.temperature|root.sgcc.wf03.wt01.status|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:37:00.000+08:00|                          21.93|                      true|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:38:00.000+08:00|                           null|                     false|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:39:00.000+08:00|                          22.23|                      true|
++-----------------------------+-------------------------------+--------------------------+
+|2017-11-01T16:40:00.000+08:00|                          23.43|                      true|
++-----------------------------+-------------------------------+--------------------------+
+Total line number = 4
 ```
 
-root.ln.wf01.wt01.temperature 最早时间和值是 2017-11-07T23:49:00 和 23.7;最后时间和值是 2017-11-08T00:00:00 和 21.07
+> 注意:当我们使用常量填充时,如果某列数据类型与常量类型不兼容,我们既不填充该列,也不报错,将该列保持原样。
+> 注意:当常量值大于int32所能表示的最大值时,对于int32类型的列,我们既不填充该列,也不报错,将该列保持原样。
 
-SQL 示例:
+#### 常量类型兼容性
 
-```sql
-SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-07T23:59:00),1m) FILL (PREVIOUSUNTILLAST);
-SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-07T23:59:00),1m) FILL (PREVIOUS);
-```
-
-结果:
-
-```
-IoTDB> SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-07T23:59:00),1m) FILL (PREVIOUSUNTILLAST);
-+-----------------------------+-----------------------------------------+
-|                         Time|last_value(root.ln.wf01.wt01.temperature)|
-+-----------------------------+-----------------------------------------+
-|2017-11-07T23:50:00.000+08:00|                                     null|
-|2017-11-07T23:51:00.000+08:00|                                    22.24|
-|2017-11-07T23:52:00.000+08:00|                                    22.24|
-|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|                                    22.52|
-|2017-11-07T23:56:00.000+08:00|                                    22.52|
-|2017-11-07T23:57:00.000+08:00|                                    24.39|
-|2017-11-07T23:58:00.000+08:00|                                     null|
-+-----------------------------+-----------------------------------------+
-Total line number = 9
-It costs 0.007s
-
-IoTDB> SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-07T23:59:00),1m) FILL (PREVIOUS);
-+-----------------------------+-----------------------------------------+
-|                         Time|last_value(root.ln.wf01.wt01.temperature)|
-+-----------------------------+-----------------------------------------+
-|2017-11-07T23:50:00.000+08:00|                                     null|
-|2017-11-07T23:51:00.000+08:00|                                    22.24|
-|2017-11-07T23:52:00.000+08:00|                                    22.24|
-|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|                                    22.52|
-|2017-11-07T23:56:00.000+08:00|                                    22.52|
-|2017-11-07T23:57:00.000+08:00|                                    24.39|
-|2017-11-07T23:58:00.000+08:00|                                    24.39|
-+-----------------------------+-----------------------------------------+
-Total line number = 9
-It costs 0.006s
-```
-
-解释:
-
-使用 PREVIOUSUNTILLAST 将不会填充 2017-11-07T23:57:00 以后的值。
-
-### 第一个值与最后一个值的填充
-
-IoTDB 的空值填充方式可以分为 PreviousFill, LinearFill, ValueFill 三大类。其中,PreviousFill 需要知道空值前的第一个非空数据,LinearFill 需要知道空值前后的第一个非空数据才能进行填充。假使某条查询语句返回的结果中第一个或最后一个值为空,就可能导致结果集在首尾存在一段连续的空值,不满足 GroupByFill 的业务期望。
-
-在上例中,第一个时间区间 [2017-11-07T23:50:00, 2017-11-07T23:51:00) 内没有任何数据,上一个有数据的时间区间是 [2017-11-01T23:49:00, 2017-11-07T23:50:00),可以通过设置 PREVIOUS 填充向前查询参数 beforeRange 来填充第一个区间的数据,示例如下:
-
-```sql
-SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-07T23:59:00),1m) FILL (PREVIOUS, 1m);
-```
-
-结果:
-
-```
-IoTDB> SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-07T23:59:00),1m) FILL (PREVIOUS, 1m);
-+-----------------------------+-----------------------------------------+
-|                         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|                                    22.24|
-|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|                                    22.52|
-|2017-11-07T23:56:00.000+08:00|                                     null|
-|2017-11-07T23:57:00.000+08:00|                                    24.39|
-|2017-11-07T23:58:00.000+08:00|                                    24.39|
-+-----------------------------+-----------------------------------------+
-Total line number = 9
-It costs 0.005s
-```
-
-解释:
-
-为了不与原有语义冲突,当不设置 before_range, after_range 参数时,GroupByFill 的空值填充取空值的前一个/后一个非空值完成;当设置 before_range, after_range 参数时,设空值所在记录的时间戳为 t,GroupByFill 取 [t-before_range, t+after_range) 内的前一个/后一个非空值完成填充。
-
-因为时间区间 [2017-11-07T23:55:00, 2017-11-07T23:57:00) 内均没有数据,所以本例虽然通过设置 before_range 填充了 [2017-11-07T23:50:00, 2017-11-07T23:51:00) 的数据,但由于 before_range 较小,[2017-11-07T23:56:00, 2017-11-07T23:57:00) 的数据无法填充。
-
-before_range, after_range 参数也可辅助 LINEAR 方式进行填充,示例如下:
-
-```sql
-SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-07T23:59:00),1m) FILL (LINEAR, 5m, 5m);
-```
-
-结果:
-
-```
-IoTDB> SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-07T23:59:00),1m) FILL (LINEAR, 5m, 5m);
-+-----------------------------+-----------------------------------------+
-|                         Time|last_value(root.ln.wf01.wt01.temperature)|
-+-----------------------------+-----------------------------------------+
-|2017-11-07T23:50:00.000+08:00|                                22.970001|
-|2017-11-07T23:51:00.000+08:00|                                    22.24|
-|2017-11-07T23:52:00.000+08:00|                                    23.41|
-|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|                                23.143333|
-|2017-11-07T23:56:00.000+08:00|                                23.766666|
-|2017-11-07T23:57:00.000+08:00|                                    24.39|
-|2017-11-07T23:58:00.000+08:00|                                23.283333|
-+-----------------------------+-----------------------------------------+
-Total line number = 9
-It costs 0.008s
-```
-
-> 注意:设原始降采样查询区间为 [start_time, end_time),在指定 before_range, after_range 参数后,降采样查询结果不变,但查询区间将转变为 [start_time - before_range, end_time + after_range)。因此这两个参数设置较大时会影响效率,使用时需注意。
-
-### Value 填充
-
-值填充方式会将输入的常量值解析为字符串,填充时尝试将字符串常量转换为对应类型的数据,若转换成功则进行填充,否则就不填充。举例如下:
-
-```sql
-SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-07T23:59:00),1m) FILL (20.0)
-SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-07T23:59:00),1m) FILL ('temperature')
-```
-
-结果:
-
-```
-IoTDB> SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-07T23:59:00),1m) FILL (20.0);
-+-----------------------------+-----------------------------------------+
-|                         Time|last_value(root.ln.wf01.wt01.temperature)|
-+-----------------------------+-----------------------------------------+
-|2017-11-07T23:50:00.000+08:00|                                     20.0|
-|2017-11-07T23:51:00.000+08:00|                                    22.24|
-|2017-11-07T23:52:00.000+08:00|                                     20.0|
-|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|                                     20.0|
-|2017-11-07T23:56:00.000+08:00|                                     20.0|
-|2017-11-07T23:57:00.000+08:00|                                    24.39|
-|2017-11-07T23:58:00.000+08:00|                                     20.0|
-+-----------------------------+-----------------------------------------+
-Total line number = 9
-It costs 0.007s
-
-IoTDB> SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-07T23:59:00),1m) FILL ('temperature');
-+-----------------------------+-----------------------------------------+
-|                         Time|last_value(root.ln.wf01.wt01.temperature)|
-+-----------------------------+-----------------------------------------+
-|2017-11-07T23:50:00.000+08:00|                                     null|
-|2017-11-07T23:51:00.000+08:00|                                    22.24|
-|2017-11-07T23:52:00.000+08:00|                                     null|
-|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|                                     null|
-|2017-11-07T23:56:00.000+08:00|                                     null|
-|2017-11-07T23:57:00.000+08:00|                                    24.39|
-|2017-11-07T23:58:00.000+08:00|                                     null|
-+-----------------------------+-----------------------------------------+
-Total line number = 9
-It costs 0.005s
-```
+| 常量类型      | 能够填充的数据类型                |
+|:----------|:----------------------------------|
+| boolean   | boolean, text                     |
+| int64     | int32, int64, float, double, text |
+| double    | float, double, text               |
+| text      | text                              |
+| </center> |                                   |
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/literal/LongLiteral.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/literal/LongLiteral.java
index 6014f1c387..f90cafbd8a 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/literal/LongLiteral.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/literal/LongLiteral.java
@@ -57,8 +57,14 @@ public class LongLiteral extends Literal {
 
   @Override
   public boolean isDataTypeConsistency(TSDataType dataType) {
+    if (dataType == TSDataType.INT32) {
+      try {
+        Math.toIntExact(value);
+      } catch (ArithmeticException e) {
+        return false;
+      }
+    }
     return dataType == TSDataType.INT32
-        || dataType == TSDataType.INT64
         || dataType == TSDataType.FLOAT
         || dataType == TSDataType.DOUBLE
         || dataType == TSDataType.TEXT;


[iotdb] 01/02: FillDoc

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jackietien pushed a commit to branch ChangeFillDoc
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 8eb3515da48cb2b3c5bdf118886cb88b4f33eb09
Author: JackieTien97 <ja...@gmail.com>
AuthorDate: Wed Jul 6 16:47:03 2022 +0800

    FillDoc
---
 docs/UserGuide/Query-Data/Fill-Null-Value.md | 35 ++++++++++------------------
 1 file changed, 12 insertions(+), 23 deletions(-)

diff --git a/docs/UserGuide/Query-Data/Fill-Null-Value.md b/docs/UserGuide/Query-Data/Fill-Null-Value.md
index 8b7be9f676..65d7709290 100644
--- a/docs/UserGuide/Query-Data/Fill-Null-Value.md
+++ b/docs/UserGuide/Query-Data/Fill-Null-Value.md
@@ -21,7 +21,7 @@
 
 # Fill Null Value
 
-When performing segment aggregation on a time series, there may be no data for a certain period of time, and the aggregated result of this segment of data is null, but this kind of null value is not conducive to data visualization and analysis, and the null value needs to be filled.
+When executing some queries, there may be no data for some columns in some rows, and data in these locations will be null, but this kind of null value is not conducive to data visualization and analysis, and the null value needs to be filled.
 
 Fill null value allows the user to fill the query result with null values according to a specific method, such as taking the previous value that is not null, or linear interpolation. The query result after filling the null value can better reflect the data distribution, which is beneficial for users to perform data analysis.
 
@@ -32,49 +32,38 @@ In IoTDB, users can use the FILL clause to specify the fill mode when data is mi
 IoTDB supports previous, linear, and value fill methods. Following table lists the data types and supported fill methods.
 
 | Data Type | Supported Fill Methods  |
-| :-------- | :---------------------- |
+| :-------- |:------------------------|
 | boolean   | previous, value         |
 | int32     | previous, linear, value |
 | int64     | previous, linear, value |
 | float     | previous, linear, value |
 | double    | previous, linear, value |
-| text      | previous                |
+| text      | previous, value         |
 | </center> |                         |
 
-> Note: Only one Fill method can be specified in a Fill statement. Null value fill is compatible with version 0.12 and previous syntax (fill((<data_type>[<fill_method>(, <before_range>, <after_range>)?])+)), but the old syntax could not specify multiple fill methods at the same time
+> Note: Only one Fill method can be specified in a Fill statement. Null value fill is not compatible with version 0.13 and previous syntax (fill((<data_type>[<fill_method>(, <before_range>, <after_range>)?])+)) is not supported anymore.
 
-## Single Point Fill
-
-When data in a particular timestamp is null, the null values can be filled using single fill, as described below:
 
 ### Previous Fill
 
-When the value in the queried timestamp is null, the value of the previous timestamp is used to fill the blank. The formalized previous method is as follows:
+When the value is null, the value of the previous timestamp is used to fill the blank. The formalized previous method is as follows:
 
 ```sql
-select <path> from <prefixPath> where time = <T> fill(previous(, <before_range>)?)
+fill(previous)
 ```
 
-Detailed descriptions of all parameters are given in following table:
-
-
-| Parameter name (case insensitive) | Interpretation                                               |
-| :-------------------------------- | :----------------------------------------------------------- |
-| path, prefixPath                  | query path; mandatory field                                  |
-| T                                 | query timestamp (only one can be specified); mandatory field |
-| before\_range                     | represents the valid time range of the previous method. The previous method works when there are values in the [T-before\_range, T] range. When before\_range is not specified, before\_range takes the default value default\_fill\_interval; -1 represents infinit; optional field |
-| </center>                         |                                                              |
-
 Here we give an example of filling null values using the previous method. The SQL statement is as follows:
 
 ```sql
-select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(previous, 1s) 
+select temperature from root.sgcc.wf03.wt01 where time => 2017-11-01T16:37:00.000 and time <= 2017-11-01T16:40:00.000
 ```
-which means:
+if we don't use any fill methods, the original result will be like:
 
-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:
+
+```sql
+select temperature from root.sgcc.wf03.wt01 where time => 2017-11-01T16:37:00.000 and time <= 2017-11-01T16:40:00.000 fill(previous)
+```
 
 ```
 +-----------------------------+-------------------------------+