You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ro...@apache.org on 2021/09/26 03:30:50 UTC
[iotdb] branch const created (now ec97045)
This is an automated email from the ASF dual-hosted git repository.
rong pushed a change to branch const
in repository https://gitbox.apache.org/repos/asf/iotdb.git.
at ec97045 nested queries -> nested expressions
This branch includes the following new commits:
new 736dc83 add 3 functions: const, e and pi
new d46ca7b zh docs
new 0efae60 en docs
new 0ca09d3 add tests
new ec97045 nested queries -> nested expressions
The 5 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] 03/05: en docs
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rong pushed a commit to branch const
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 0efae60379eece459a1c4268a9aa7a2d59604d0d
Author: Steve Yurong Su <ro...@apache.org>
AuthorDate: Sun Sep 26 11:05:19 2021 +0800
en docs
---
.../DML-Data-Manipulation-Language.md | 37 ++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/docs/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md b/docs/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
index 76e1bc9..236f4a2 100644
--- a/docs/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
+++ b/docs/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
@@ -423,6 +423,43 @@ Total line number = 5
It costs 0.014s
```
+#### Constant Timeseries Generation Functions
+
+The constant timeseries generating function is used to generate a timeseries in which the values of all data points are the same.
+
+The constant timeseries generation function accepts one or more timeseries inputs, and the timestamp set of the output data points is the union of the timestamp sets of the input timeseries.
+
+Currently, IoTDB supports the following constant timeseries generating functions:
+
+| Function Name | Allowed Input Series Data Types | Required Attributes | Output Series Data Type | Description |
+| ------------- | ----------------------------------------------- | ------------------------------------------------------------ | -------------------------------------------- | ------------------------------------------------------------ |
+| CONST | INT32 / INT64 / FLOAT / DOUBLE / BOOLEAN / TEXT | `value`: the value of the output data point <br />`type`: the type of the output data point, it can only be INT32 / INT64 / FLOAT / DOUBLE / BOOLEAN / TEXT | Determined by the required attribute `type` | Output the user-specified constant timeseries according to the attributes `value` and `type`. |
+| PI | INT32 / INT64 / FLOAT / DOUBLE / BOOLEAN / TEXT | None | DOUBLE | Data point value: a double value that is closer than any other to `pi`, the ratio of the circumference of a circle to its diameter. |
+| E | INT32 / INT64 / FLOAT / DOUBLE / BOOLEAN / TEXT | None | DOUBLE | Data point value: a double value that is closer than any other to `e`, the base of the natural logarithms. |
+
+Example:
+
+``` sql
+select s1, s2, const(s1, 'value'='1024', 'type'='INT64'), pi(s2), e(s1, s2) from root.sg1.d1;
+```
+
+Result:
+
+```
+select s1, s2, const(s1, 'value'='1024', 'type'='INT64'), pi(s2), e(s1, s2) from root.sg1.d1;
++-----------------------------+--------------+--------------+-----------------------------------------------------+------------------+---------------------------------+
+| Time|root.sg1.d1.s1|root.sg1.d1.s2|const(root.sg1.d1.s1, "value"="1024", "type"="INT64")|pi(root.sg1.d1.s2)|e(root.sg1.d1.s1, root.sg1.d1.s2)|
++-----------------------------+--------------+--------------+-----------------------------------------------------+------------------+---------------------------------+
+|1970-01-01T08:00:00.000+08:00| 0.0| 0.0| 1024| 3.141592653589793| 2.718281828459045|
+|1970-01-01T08:00:00.001+08:00| 1.0| null| 1024| null| 2.718281828459045|
+|1970-01-01T08:00:00.002+08:00| 2.0| null| 1024| null| 2.718281828459045|
+|1970-01-01T08:00:00.003+08:00| null| 3.0| null| 3.141592653589793| 2.718281828459045|
+|1970-01-01T08:00:00.004+08:00| null| 4.0| null| 3.141592653589793| 2.718281828459045|
++-----------------------------+--------------+--------------+-----------------------------------------------------+------------------+---------------------------------+
+Total line number = 5
+It costs 0.005s
+```
+
#### User Defined Timeseries Generating Functions
Please refer to [UDF (User Defined Function)](../Advanced-Features/UDF-User-Defined-Function.md).
[iotdb] 02/05: zh docs
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rong pushed a commit to branch const
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit d46ca7bbf518c41cd2265601b9998cc267a4c6fc
Author: Steve Yurong Su <ro...@apache.org>
AuthorDate: Sun Sep 26 10:47:57 2021 +0800
zh docs
---
.../DML-Data-Manipulation-Language.md | 39 +++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
diff --git a/docs/zh/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md b/docs/zh/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
index 4795de2..e77fd83 100644
--- a/docs/zh/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
+++ b/docs/zh/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
@@ -432,6 +432,43 @@ Total line number = 5
It costs 0.014s
```
+#### 常序列生成函数
+
+常序列生成函数用于生成所有数据点的值都相同的时间序列。
+
+常序列生成函数接受一个或者多个时间序列输入,其输出的数据点的时间戳集合是这些输入序列时间戳集合的并集。
+
+目前 IoTDB 支持如下常序列生成函数:
+
+| 函数名 | 输入序列类型 | 必要的属性参数 | 输出序列类型 | 功能描述 |
+| ------ | ----------------------------------------------- | ------------------------------------------------------------ | -------------------------- | ------------------------------------------------------------ |
+| CONST | INT32 / INT64 / FLOAT / DOUBLE / BOOLEAN / TEXT | `value`: 输出的数据点的值 <br />`type`: 输出的数据点的类型,只能是 INT32 / INT64 / FLOAT / DOUBLE / BOOLEAN / TEXT | 由输入属性参数 `type` 决定 | 根据输入属性 `value` 和 `type` 输出用户指定的常序列 |
+| PI | INT32 / INT64 / FLOAT / DOUBLE / BOOLEAN / TEXT | 无 | DOUBLE | 常序列的值是比任何其他值都更接近圆周率的双精度值,圆周长与其直径的比率。 |
+| E | INT32 / INT64 / FLOAT / DOUBLE / BOOLEAN / TEXT | 无 | DOUBLE | 常序列的值是比任何其他值都更接近 e(自然对数的底)的双精度值。 |
+
+例如:
+
+``` sql
+select s1, s2, const(s1, 'value'='1024', 'type'='INT64'), pi(s2), e(s1, s2) from root.sg1.d1;
+```
+
+结果:
+
+```
+select s1, s2, const(s1, 'value'='1024', 'type'='INT64'), pi(s2), e(s1, s2) from root.sg1.d1;
++-----------------------------+--------------+--------------+-----------------------------------------------------+------------------+---------------------------------+
+| Time|root.sg1.d1.s1|root.sg1.d1.s2|const(root.sg1.d1.s1, "value"="1024", "type"="INT64")|pi(root.sg1.d1.s2)|e(root.sg1.d1.s1, root.sg1.d1.s2)|
++-----------------------------+--------------+--------------+-----------------------------------------------------+------------------+---------------------------------+
+|1970-01-01T08:00:00.000+08:00| 0.0| 0.0| 1024| 3.141592653589793| 2.718281828459045|
+|1970-01-01T08:00:00.001+08:00| 1.0| null| 1024| null| 2.718281828459045|
+|1970-01-01T08:00:00.002+08:00| 2.0| null| 1024| null| 2.718281828459045|
+|1970-01-01T08:00:00.003+08:00| null| 3.0| null| 3.141592653589793| 2.718281828459045|
+|1970-01-01T08:00:00.004+08:00| null| 4.0| null| 3.141592653589793| 2.718281828459045|
++-----------------------------+--------------+--------------+-----------------------------------------------------+------------------+---------------------------------+
+Total line number = 5
+It costs 0.005s
+```
+
#### 自定义时间序列生成函数
请参考 [UDF (用户定义函数)](../Advanced-Features/UDF-User-Defined-Function.md)。
@@ -442,7 +479,7 @@ It costs 0.014s
### 嵌套查询(子查询)
-“嵌套查询”又称为“子查询,即在一条 SQL 语句中,“内层查询”的计算结果可以作为“外层查询”的计算对象来使用。
+“嵌套查询”又称为“子查询”,即在一条 SQL 语句中,“内层查询”的计算结果可以作为“外层查询”的计算对象来使用。
IoTDB 支持在 `select` 字句中执行由**时间序列、算数运算表达式和时间序列生成函数(包括用户自定义函数)**组成的任意嵌套表达式。
[iotdb] 04/05: add tests
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rong pushed a commit to branch const
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 0ca09d3380b9d61e2c75db92d9b1bbf936f36e2d
Author: Steve Yurong Su <ro...@apache.org>
AuthorDate: Sun Sep 26 11:25:24 2021 +0800
add tests
---
.../db/integration/IoTDBUDTFBuiltinFunctionIT.java | 45 +++++++++++++++++++---
1 file changed, 40 insertions(+), 5 deletions(-)
diff --git a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBUDTFBuiltinFunctionIT.java b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBUDTFBuiltinFunctionIT.java
index 07f6491..49059c5 100644
--- a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBUDTFBuiltinFunctionIT.java
+++ b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBUDTFBuiltinFunctionIT.java
@@ -48,11 +48,11 @@ public class IoTDBUDTFBuiltinFunctionIT {
private static final double E = 0.0001;
private static final String[] INSERTION_SQLS = {
- "insert into root.sg.d1(time, s1, s2, s3, s4, s5, s6) values (0, 0, 0, 0, 0, true, '0')",
- "insert into root.sg.d1(time, s1, s2, s3, s4, s5, s6) values (2, 1, 1, 1, 1, false, '1')",
- "insert into root.sg.d1(time, s1, s2, s3, s4, s5, s6) values (4, 2, 2, 2, 2, false, '2')",
- "insert into root.sg.d1(time, s1, s2, s3, s4, s5, s6) values (6, 3, 3, 3, 3, true, '3')",
- "insert into root.sg.d1(time, s1, s2, s3, s4, s5, s6) values (8, 4, 4, 4, 4, true, '4')",
+ "insert into root.sg.d1(time, s1, s2, s3, s4, s5, s6, s7, s8) values (0, 0, 0, 0, 0, true, '0', 0, 0)",
+ "insert into root.sg.d1(time, s1, s2, s3, s4, s5, s6, s7) values (2, 1, 1, 1, 1, false, '1', 1)",
+ "insert into root.sg.d1(time, s1, s2, s3, s4, s5, s6, s7) values (4, 2, 2, 2, 2, false, '2', 2)",
+ "insert into root.sg.d1(time, s1, s2, s3, s4, s5, s6, s8) values (6, 3, 3, 3, 3, true, '3', 3)",
+ "insert into root.sg.d1(time, s1, s2, s3, s4, s5, s6, s8) values (8, 4, 4, 4, 4, true, '4', 4)",
};
@BeforeClass
@@ -295,4 +295,39 @@ public class IoTDBUDTFBuiltinFunctionIT {
fail(throwable.getMessage());
}
}
+
+ @Test
+ public void testConstantTimeSeriesGeneratingFunctions() {
+ String[] expected = {
+ "0, 0.0, 0.0, 1024, 3.141592653589793, 2.718281828459045, ",
+ "2, 1.0, null, 1024, 3.141592653589793, 2.718281828459045, ",
+ "4, 2.0, null, 1024, 3.141592653589793, 2.718281828459045, ",
+ "6, null, 3.0, null, null, 2.718281828459045, ",
+ "8, null, 4.0, null, null, 2.718281828459045, ",
+ };
+
+ try (Connection connection =
+ DriverManager.getConnection(
+ Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+ Statement statement = connection.createStatement();
+ ResultSet resultSet =
+ statement.executeQuery(
+ "select s7, s8, const(s7, 'value'='1024', 'type'='INT64'), pi(s7, s7), e(s7, s8, s7, s8) from root.sg.d1")) {
+
+ assertEquals(1 + 5, resultSet.getMetaData().getColumnCount());
+
+ for (int i = 0; i < INSERTION_SQLS.length; ++i) {
+ resultSet.next();
+ StringBuilder actual = new StringBuilder();
+ for (int j = 0; j < 1 + 5; ++j) {
+ actual.append(resultSet.getString(1 + j)).append(", ");
+ }
+ assertEquals(expected[i], actual.toString());
+ }
+
+ assertFalse(resultSet.next());
+ } catch (SQLException throwable) {
+ fail(throwable.getMessage());
+ }
+ }
}
[iotdb] 05/05: nested queries -> nested expressions
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rong pushed a commit to branch const
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit ec9704540e63d0fc0af0fe483188fc2660952841
Author: Steve Yurong Su <ro...@apache.org>
AuthorDate: Sun Sep 26 11:30:00 2021 +0800
nested queries -> nested expressions
---
docs/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md | 4 +---
.../zh/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md | 4 +---
2 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/docs/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md b/docs/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
index 236f4a2..4b04ef9 100644
--- a/docs/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
+++ b/docs/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
@@ -468,9 +468,7 @@ Known Implementation UDF Libraries:
+ [IoTDB-Quality](https://thulab.github.io/iotdb-quality), a UDF library about data quality, including data profiling, data quality evalution and data repairing, etc.
-### Nested Query (Subquery)
-
-"Nested query" is also called "subquery", that is, in a SQL statement, the result of the "inner query" can be used as the input of the "outer query".
+### Nested Expressions
IoTDB supports the execution of arbitrary nested expressions consisting of **time series, arithmetic expressions, and time series generation functions (including user-defined functions)** in the `select` clause.
diff --git a/docs/zh/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md b/docs/zh/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
index e77fd83..ea5cd13 100644
--- a/docs/zh/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
+++ b/docs/zh/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
@@ -477,9 +477,7 @@ It costs 0.005s
+ [IoTDB-Quality](https://thulab.github.io/iotdb-quality),一个关于数据质量的 UDF 库实现,包括数据画像、数据质量评估与修复等一系列函数。
-### 嵌套查询(子查询)
-
-“嵌套查询”又称为“子查询”,即在一条 SQL 语句中,“内层查询”的计算结果可以作为“外层查询”的计算对象来使用。
+### 嵌套表达式
IoTDB 支持在 `select` 字句中执行由**时间序列、算数运算表达式和时间序列生成函数(包括用户自定义函数)**组成的任意嵌套表达式。
[iotdb] 01/05: add 3 functions: const, e and pi
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rong pushed a commit to branch const
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 736dc83204de38c2df712be77f179f8d7c2bdede
Author: Steve Yurong Su <ro...@apache.org>
AuthorDate: Fri Sep 24 16:38:26 2021 +0800
add 3 functions: const, e and pi
---
.../db/query/udf/builtin/BuiltinFunction.java | 3 +
.../iotdb/db/query/udf/builtin/UDTFConst.java | 123 +++++++++++++++++++++
.../iotdb/db/query/udf/builtin/UDTFConstE.java | 43 +++++++
.../iotdb/db/query/udf/builtin/UDTFConstPi.java | 43 +++++++
4 files changed, 212 insertions(+)
diff --git a/server/src/main/java/org/apache/iotdb/db/query/udf/builtin/BuiltinFunction.java b/server/src/main/java/org/apache/iotdb/db/query/udf/builtin/BuiltinFunction.java
index ead7350..c8fff1f 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/udf/builtin/BuiltinFunction.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/udf/builtin/BuiltinFunction.java
@@ -21,6 +21,9 @@ package org.apache.iotdb.db.query.udf.builtin;
/** All built-in UDFs need to register their function names and classes here. */
public enum BuiltinFunction {
+ CONST("CONST", UDTFConst.class),
+ E("E", UDTFConstE.class),
+ PI("PI", UDTFConstPi.class),
SIN("SIN", UDTFSin.class),
COS("COS", UDTFCos.class),
TAN("TAN", UDTFTan.class),
diff --git a/server/src/main/java/org/apache/iotdb/db/query/udf/builtin/UDTFConst.java b/server/src/main/java/org/apache/iotdb/db/query/udf/builtin/UDTFConst.java
new file mode 100644
index 0000000..a09e8be
--- /dev/null
+++ b/server/src/main/java/org/apache/iotdb/db/query/udf/builtin/UDTFConst.java
@@ -0,0 +1,123 @@
+/*
+ * 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.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.UDFParameterNotValidException;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.tsfile.utils.Binary;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class UDTFConst implements UDTF {
+
+ private static final Set<String> VALID_TYPES = new HashSet<>();
+
+ static {
+ VALID_TYPES.add(TSDataType.INT32.name());
+ VALID_TYPES.add(TSDataType.INT64.name());
+ VALID_TYPES.add(TSDataType.FLOAT.name());
+ VALID_TYPES.add(TSDataType.DOUBLE.name());
+ VALID_TYPES.add(TSDataType.BOOLEAN.name());
+ VALID_TYPES.add(TSDataType.TEXT.name());
+ }
+
+ private TSDataType dataType;
+
+ private int intValue;
+ private long longValue;
+ private float floatValue;
+ private double doubleValue;
+ private boolean booleanValue;
+ private Binary binaryValue;
+
+ @Override
+ public void validate(UDFParameterValidator validator) throws UDFParameterNotValidException {
+ validator
+ .validateRequiredAttribute("value")
+ .validateRequiredAttribute("type")
+ .validate(
+ type -> VALID_TYPES.contains((String) type),
+ "The given value type is not supported.",
+ validator.getParameters().getString("type"));
+ }
+
+ @Override
+ public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations) {
+ dataType = TSDataType.valueOf(parameters.getString("type"));
+ switch (dataType) {
+ case INT32:
+ intValue = Integer.parseInt(parameters.getString("value"));
+ break;
+ case INT64:
+ longValue = Long.parseLong(parameters.getString("value"));
+ break;
+ case FLOAT:
+ floatValue = Float.parseFloat(parameters.getString("value"));
+ break;
+ case DOUBLE:
+ doubleValue = Double.parseDouble(parameters.getString("value"));
+ break;
+ case BOOLEAN:
+ booleanValue = Boolean.parseBoolean(parameters.getString("value"));
+ break;
+ case TEXT:
+ binaryValue = Binary.valueOf(parameters.getString("value"));
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+
+ configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(dataType);
+ }
+
+ @Override
+ public void transform(Row row, PointCollector collector) throws Exception {
+ switch (dataType) {
+ case INT32:
+ collector.putInt(row.getTime(), intValue);
+ break;
+ case INT64:
+ collector.putLong(row.getTime(), longValue);
+ break;
+ case FLOAT:
+ collector.putFloat(row.getTime(), floatValue);
+ break;
+ case DOUBLE:
+ collector.putDouble(row.getTime(), doubleValue);
+ break;
+ case BOOLEAN:
+ collector.putBoolean(row.getTime(), booleanValue);
+ break;
+ case TEXT:
+ collector.putBinary(row.getTime(), binaryValue);
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ }
+}
diff --git a/server/src/main/java/org/apache/iotdb/db/query/udf/builtin/UDTFConstE.java b/server/src/main/java/org/apache/iotdb/db/query/udf/builtin/UDTFConstE.java
new file mode 100644
index 0000000..0e6ee37
--- /dev/null
+++ b/server/src/main/java/org/apache/iotdb/db/query/udf/builtin/UDTFConstE.java
@@ -0,0 +1,43 @@
+/*
+ * 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.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.UDFParameters;
+import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+
+public class UDTFConstE implements UDTF {
+
+ @Override
+ public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations) {
+ configurations
+ .setAccessStrategy(new RowByRowAccessStrategy())
+ .setOutputDataType(TSDataType.DOUBLE);
+ }
+
+ @Override
+ public void transform(Row row, PointCollector collector) throws Exception {
+ collector.putDouble(row.getTime(), Math.E);
+ }
+}
diff --git a/server/src/main/java/org/apache/iotdb/db/query/udf/builtin/UDTFConstPi.java b/server/src/main/java/org/apache/iotdb/db/query/udf/builtin/UDTFConstPi.java
new file mode 100644
index 0000000..c2724c7
--- /dev/null
+++ b/server/src/main/java/org/apache/iotdb/db/query/udf/builtin/UDTFConstPi.java
@@ -0,0 +1,43 @@
+/*
+ * 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.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.UDFParameters;
+import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+
+public class UDTFConstPi implements UDTF {
+
+ @Override
+ public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations) {
+ configurations
+ .setAccessStrategy(new RowByRowAccessStrategy())
+ .setOutputDataType(TSDataType.DOUBLE);
+ }
+
+ @Override
+ public void transform(Row row, PointCollector collector) throws Exception {
+ collector.putDouble(row.getTime(), Math.PI);
+ }
+}