You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/03/07 02:04:05 UTC

[GitHub] [iotdb] SteveYurongSu commented on a change in pull request #5146: [IOTDB-2596] Add buildin UDTF in_range

SteveYurongSu commented on a change in pull request #5146:
URL: https://github.com/apache/iotdb/pull/5146#discussion_r819198260



##########
File path: docs/zh/UserGuide/Query-Data/Select-Expression.md
##########
@@ -346,9 +346,10 @@ It costs 0.078s
 
 目前IoTDB支持以下条件函数
 
-| 函数名    | 可接收的输入序列类型   | 必要的属性参数                | 输出序列类型     | 功能类型                                             |
-|--------|-------------------|------------------------|------------|--------------------------------------------------|
-| ON_OFF | INT32 / INT64 / FLOAT / DOUBLE| `threshold`:DOUBLE类型参数 | BOOLEAN 类型 | 大于等于`threshold` 的数据点返回true,小于`threshold`的数据点返回false |
+| 函数名      | 可接收的输入序列类型                     | 必要的属性参数                               | 输出序列类型     | 功能类型                                             |
+|----------|--------------------------------|---------------------------------------|------------|--------------------------------------------------|
+| ON_OFF   | INT32 / INT64 / FLOAT / DOUBLE | `threshold`:DOUBLE类型                  | BOOLEAN 类型 | 返回`ts_value >= threshold`的bool值                  |
+| IN_RANGE | INT32 / INT64 / FLOAT / DOUBLE | `lower`:DOUBLE类型<br/>`upper`:DOUBLE类型 | BOOLEAN类型呢 | 返回`ts_value >= lower && ts_value <= upper`的bool值 |                                                    |

Review comment:
       ```suggestion
   | IN_RANGE | INT32 / INT64 / FLOAT / DOUBLE | `lower`:DOUBLE类型<br/>`upper`:DOUBLE类型 | BOOLEAN类型 | 返回`ts_value >= lower && ts_value <= upper`的bool值 |                                                    |
   ```

##########
File path: docs/zh/UserGuide/Query-Data/Select-Expression.md
##########
@@ -379,7 +382,25 @@ IoTDB> select ts, on_off(ts, 'threshold'='2') from root.test;
 |1970-01-01T08:00:00.003+08:00|           3|                                 true|
 |1970-01-01T08:00:00.004+08:00|           4|                                 true|
 +-----------------------------+------------+-------------------------------------+
+```
 
+##### 测试2
+Sql语句:
+```sql
+select ts, in_range(ts, 'lower'='2', 'upper'='3.1') from root.test;
+```
+
+输出:
+```
+IoTDB> select ts, in_range(ts,'lower'='2', 'upper'='3.1') from root.test;

Review comment:
       ```suggestion
   IoTDB> select ts, in_range(ts, 'lower'='2', 'upper'='3.1') from root.test;
   ```

##########
File path: server/src/main/java/org/apache/iotdb/db/query/udf/builtin/UDTFInRange.java
##########
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.query.udf.builtin;
+
+import org.apache.iotdb.db.exception.metadata.MetadataException;
+import org.apache.iotdb.db.query.udf.api.UDTF;
+import org.apache.iotdb.db.query.udf.api.access.Row;
+import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
+import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.db.query.udf.api.exception.UDFException;
+import org.apache.iotdb.db.query.udf.api.exception.UDFInputSeriesDataTypeNotValidException;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+
+import java.io.IOException;
+
+public class UDTFInRange implements UDTF {
+  TSDataType dataType;

Review comment:
       ```suggestion
     protected TSDataType dataType;
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org