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

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


The following commit(s) were added to refs/heads/master by this push:
     new a10a170  [IOTDB-1739] Constant timeseries generating functions (const, 
pi and e) (#4033)
a10a170 is described below

commit a10a170c99bb92d30e12c3b367030b211ff63548
Author: Steve Yurong Su <[email protected]>
AuthorDate: Mon Sep 27 16:44:45 2021 +0800

    [IOTDB-1739] Constant timeseries generating functions (const, pi and e) 
(#4033)
---
 .../DML-Data-Manipulation-Language.md              |  43 ++++++-
 .../DML-Data-Manipulation-Language.md              |  41 ++++++-
 .../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 +++++++
 .../db/integration/IoTDBUDTFBuiltinFunctionIT.java |  79 ++++++++++++-
 7 files changed, 363 insertions(+), 12 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 14bf1d2..4242785 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 Generating 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 generating 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 | Required Attributes                                          
| Output Series Data Type                      | Description                    
                              |
+| ------------- | ------------------------------------------------------------ 
| -------------------------------------------- | 
------------------------------------------------------------ |
+| CONST         | `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            | None                                                         
| DOUBLE                                       | Data point value: a `double` 
value of  `π`, the ratio of the circumference of a circle to its diameter, 
which is equals to `Math.PI` in the *Java Standard Library*. |
+| E             | None                                                         
| DOUBLE                                       | Data point value: a `double` 
value of  `e`, the base of the natural logarithms, which is equals to `Math.E` 
in the *Java Standard Library*. |
+
+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).
@@ -431,11 +468,9 @@ 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.
+IoTDB supports the execution of arbitrary nested expressions consisting of 
**time series, arithmetic expressions, and time series generating functions 
(including user-defined functions)** in the `select` clause.
 
 #### Syntax
 
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 2c3f21d..275f54c 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  | `value`: 输出的数据点的值 <br />`type`: 输出的数据点的类型,只能是 INT32 / INT64 / FLOAT 
/ DOUBLE / BOOLEAN / TEXT | 由输入属性参数 `type` 决定 | 根据输入属性 `value` 和 `type` 
输出用户指定的常序列。        |
+| PI     | 无                                                           | 
DOUBLE                     | 常序列的值:`π` 的 `double` 值,圆的周长与其直径的比值,即圆周率,等于 
*Java标准库* 中的`Math.PI`。 |
+| E      | 无                                                           | 
DOUBLE                     | 常序列的值:`e` 的 `double` 值,自然对数的底,它等于 *Java 标准库*  中的 
`Math.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)。
@@ -440,9 +477,7 @@ It costs 0.014s
 
 + [IoTDB-Quality](https://thulab.github.io/iotdb-quality),一个关于数据质量的 UDF 
库实现,包括数据画像、数据质量评估与修复等一系列函数。
 
-### 嵌套查询(子查询)
-
-“嵌套查询”又称为“子查询,即在一条 SQL 语句中,“内层查询”的计算结果可以作为“外层查询”的计算对象来使用。
+### 嵌套表达式
 
 IoTDB 支持在 `select` 字句中执行由**时间序列、算数运算表达式和时间序列生成函数(包括用户自定义函数)**组成的任意嵌套表达式。
 
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..8978425
--- /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);
+  }
+}
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..fa0268a 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,73 @@ 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")) {
+
+      try (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());
+      }
+
+      try (Statement statement = connection.createStatement();
+          ResultSet ignored =
+              statement.executeQuery("select const(s7, 'value'='1024') from 
root.sg.d1")) {
+        fail();
+      } catch (SQLException e) {
+        assertTrue(e.getMessage().contains("attribute \"type\" is required but 
was not provided"));
+      }
+
+      try (Statement statement = connection.createStatement();
+          ResultSet ignored =
+              statement.executeQuery("select const(s8, 'type'='INT64') from 
root.sg.d1")) {
+        fail();
+      } catch (SQLException e) {
+        assertTrue(e.getMessage().contains("attribute \"value\" is required 
but was not provided"));
+      }
+
+      try (Statement statement = connection.createStatement();
+          ResultSet ignored =
+              statement.executeQuery(
+                  "select const(s8, 'value'='1024', 'type'='long') from 
root.sg.d1")) {
+        fail();
+      } catch (SQLException e) {
+        assertTrue(e.getMessage().contains("the given value type is not 
supported"));
+      }
+
+      try (Statement statement = connection.createStatement();
+          ResultSet ignored =
+              statement.executeQuery(
+                  "select const(s8, 'value'='1024e', 'type'='INT64') from 
root.sg.d1")) {
+        fail();
+      } catch (SQLException e) {
+        assertTrue(e.getMessage().contains("java.lang.NumberFormatException"));
+      }
+    } catch (SQLException throwable) {
+      fail(throwable.getMessage());
+    }
+  }
 }

Reply via email to