This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch ty/TableIT
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/ty/TableIT by this push:
new 6b8fbc0bb52 Add IT for IoTDBDiffFunctionIT
6b8fbc0bb52 is described below
commit 6b8fbc0bb52925c8011408fe69a3ee01f98583fe
Author: JackieTien97 <[email protected]>
AuthorDate: Wed Jul 24 09:03:23 2024 +0800
Add IT for IoTDBDiffFunctionIT
---
.../scalar/IoTDBDiffFunctionIT.java | 366 +++++++--------------
.../scalar/IoTDBDiffFunction2IT.java | 42 +++
.../scalar/IoTDBDiffFunction3IT.java | 42 +++
.../scalar/IoTDBDiffFunctionIT.java | 24 +-
.../relational/metadata/TableMetadataImpl.java | 2 +-
5 files changed, 222 insertions(+), 254 deletions(-)
diff --git
a/integration-test/src/test/java/org/apache/iotdb/db/it/builtinfunction/scalar/IoTDBDiffFunctionIT.java
b/integration-test/src/test/java/org/apache/iotdb/db/it/builtinfunction/scalar/IoTDBDiffFunctionIT.java
index 37887b4d382..77f90aa993a 100644
---
a/integration-test/src/test/java/org/apache/iotdb/db/it/builtinfunction/scalar/IoTDBDiffFunctionIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/db/it/builtinfunction/scalar/IoTDBDiffFunctionIT.java
@@ -23,6 +23,7 @@ import org.apache.iotdb.it.env.EnvFactory;
import org.apache.iotdb.it.framework.IoTDBTestRunner;
import org.apache.iotdb.itbase.category.ClusterIT;
import org.apache.iotdb.itbase.category.LocalStandaloneIT;
+import org.apache.iotdb.itbase.env.BaseEnv;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -30,34 +31,35 @@ import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
-import static org.apache.iotdb.db.it.utils.TestUtils.prepareData;
+import java.sql.Connection;
+import java.sql.Statement;
+
import static org.apache.iotdb.db.it.utils.TestUtils.resultSetEqualTest;
-import static org.apache.iotdb.itbase.constant.TestConstant.DEVICE;
-import static org.apache.iotdb.itbase.constant.TestConstant.TIMESTAMP_STR;
@RunWith(IoTDBTestRunner.class)
@Category({LocalStandaloneIT.class, ClusterIT.class})
public class IoTDBDiffFunctionIT {
+
+ private static final String DATABASE_NAME = "db";
+
// 2 devices 4 regions
protected static final String[] SQLs =
new String[] {
- "CREATE DATABASE root.db",
- "CREATE TIMESERIES root.db.d1.s1 WITH DATATYPE=INT32, ENCODING=PLAIN",
- "CREATE TIMESERIES root.db.d1.s2 WITH DATATYPE=FLOAT, ENCODING=PLAIN",
- "INSERT INTO root.db.d1(timestamp,s1,s2) values(1, 1, 1)",
- "INSERT INTO root.db.d1(timestamp,s1) values(2, 2)",
- "INSERT INTO root.db.d1(timestamp,s2) values(3, 3)",
- "INSERT INTO root.db.d1(timestamp,s1) values(4, 4)",
- "INSERT INTO root.db.d1(timestamp,s1,s2) values(5, 5, 5)",
- "INSERT INTO root.db.d1(timestamp,s2) values(6, 6)",
- "INSERT INTO root.db.d1(timestamp,s1,s2) values(5000000000, null, 7)",
- "INSERT INTO root.db.d1(timestamp,s1,s2) values(5000000001, 8, null)",
- "CREATE TIMESERIES root.db.d2.s1 WITH DATATYPE=INT32, ENCODING=PLAIN",
- "CREATE TIMESERIES root.db.d2.s2 WITH DATATYPE=FLOAT, ENCODING=PLAIN",
- "INSERT INTO root.db.d2(timestamp,s1,s2) values(1, 1, 1)",
- "INSERT INTO root.db.d2(timestamp,s1,s2) values(2, 2, 2)",
- "INSERT INTO root.db.d2(timestamp,s1,s2) values(5000000000, null, 3)",
- "INSERT INTO root.db.d2(timestamp,s1,s2) values(5000000001, 4, null)",
+ "CREATE DATABASE " + DATABASE_NAME,
+ "use " + DATABASE_NAME,
+ "create table table1(device_id STRING ID, s1 INT32 MEASUREMENT, FLOAT
INT32 MEASUREMENT);",
+ "INSERT INTO table1(time,device_id,s1,s2) values(1, 'd1', 1, 1)",
+ "INSERT INTO table1(time,device_id,s1) values(2, 'd1', 2)",
+ "INSERT INTO table1(time,device_id,s2) values(3, 'd1', 3)",
+ "INSERT INTO table1(time,device_id,s1) values(4, 'd1', 4)",
+ "INSERT INTO table1(time,device_id,s1,s2) values(5, 'd1', 5, 5)",
+ "INSERT INTO table1(time,device_id,s2) values(6, 'd1', 6)",
+ "INSERT INTO table1(time,device_id,s1,s2) values(5000000000, 'd1',
null, 7)",
+ "INSERT INTO table1(time,device_id,s1,s2) values(5000000001, 'd1', 8,
null)",
+ "INSERT INTO table1(time,device_id,s1,s2) values(1, 'd2', 1, 1)",
+ "INSERT INTO table1(time,device_id,s1,s2) values(2, 'd2', 2, 2)",
+ "INSERT INTO table1(time,device_id,s1,s2) values(5000000000, 'd2',
null, 3)",
+ "INSERT INTO table1(time,device_id,s1,s2) values(5000000001, 'd2', 4,
null)",
"flush"
};
@@ -65,7 +67,19 @@ public class IoTDBDiffFunctionIT {
public static void setUp() throws Exception {
EnvFactory.getEnv().getConfig().getCommonConfig().setPartitionInterval(1000);
EnvFactory.getEnv().initClusterEnvironment();
- prepareData(SQLs);
+ insertData();
+ }
+
+ protected static void insertData() {
+ try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+ Statement statement = connection.createStatement()) {
+
+ for (String sql : SQLs) {
+ statement.execute(sql);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
@AfterClass
@@ -75,285 +89,141 @@ public class IoTDBDiffFunctionIT {
@Test
public void testNewTransformerIgnoreNull() {
- String[] expectedHeader =
- new String[] {TIMESTAMP_STR, "Diff(root.db.d1.s1)",
"diff(root.db.d1.s2)"};
- String[] retArray =
- new String[] {
- "1,null,null,",
- "2,1.0,null,",
- "3,null,2.0,",
- "4,2.0,null,",
- "5,1.0,2.0,",
- "6,null,1.0,",
- "5000000000,null,1.0,",
- "5000000001,3.0,null,"
- };
- resultSetEqualTest("select Diff(s1), diff(s2) from root.db.d1",
expectedHeader, retArray);
-
- // align by device
- expectedHeader = new String[] {TIMESTAMP_STR, DEVICE, "Diff(s1)",
"diff(s2)"};
- retArray =
- new String[] {
- "1,root.db.d1,null,null,",
- "2,root.db.d1,1.0,null,",
- "3,root.db.d1,null,2.0,",
- "4,root.db.d1,2.0,null,",
- "5,root.db.d1,1.0,2.0,",
- "6,root.db.d1,null,1.0,",
- "5000000000,root.db.d1,null,1.0,",
- "5000000001,root.db.d1,3.0,null,",
- "1,root.db.d2,null,null,",
- "2,root.db.d2,1.0,1.0,",
- "5000000000,root.db.d2,null,1.0,",
- "5000000001,root.db.d2,2.0,null,"
- };
- resultSetEqualTest(
- "select Diff(s1), diff(s2) from root.db.d1, root.db.d2 align by
device",
- expectedHeader,
- retArray);
-
- // align by device + order by time
- retArray =
- new String[] {
- "1,root.db.d1,null,null,",
- "1,root.db.d2,null,null,",
- "2,root.db.d1,1.0,null,",
- "2,root.db.d2,1.0,1.0,",
- "3,root.db.d1,null,2.0,",
- "4,root.db.d1,2.0,null,",
- "5,root.db.d1,1.0,2.0,",
- "6,root.db.d1,null,1.0,",
- "5000000000,root.db.d1,null,1.0,",
- "5000000000,root.db.d2,null,1.0,",
- "5000000001,root.db.d1,3.0,null,",
- "5000000001,root.db.d2,2.0,null,"
- };
- resultSetEqualTest(
- "select Diff(s1), diff(s2) from root.db.d1, root.db.d2 order by time
align by device",
- expectedHeader,
- retArray);
- }
-
- @Test
- public void testNewTransformerRespectNull() {
- String[] expectedHeader =
- new String[] {
- TIMESTAMP_STR,
- "Diff(root.db.d1.s1, \"ignoreNull\"=\"false\")",
- "diff(root.db.d1.s2, \"ignoreNull\"=\"false\")"
- };
+ String[] expectedHeader = new String[] {"time", "_col1", "_col2"};
String[] retArray =
new String[] {
- "1,null,null,",
- "2,1.0,null,",
- "3,null,null,",
- "4,null,null,",
- "5,1.0,null,",
- "6,null,1.0,",
- "5000000000,null,1.0,",
- "5000000001,null,null,"
- };
- resultSetEqualTest(
- "select Diff(s1, 'ignoreNull'='false'), diff(s2, 'ignoreNull'='false')
from root.db.d1",
- expectedHeader,
- retArray);
-
- // align by device
- expectedHeader =
- new String[] {
- TIMESTAMP_STR,
- DEVICE,
- "Diff(s1, \"ignoreNull\"=\"false\")",
- "diff(s2, \"ignoreNull\"=\"false\")"
- };
- retArray =
- new String[] {
- "1,root.db.d1,null,null,",
- "2,root.db.d1,1.0,null,",
- "3,root.db.d1,null,null,",
- "4,root.db.d1,null,null,",
- "5,root.db.d1,1.0,null,",
- "6,root.db.d1,null,1.0,",
- "5000000000,root.db.d1,null,1.0,",
- "5000000001,root.db.d1,null,null,",
- "1,root.db.d2,null,null,",
- "2,root.db.d2,1.0,1.0,",
- "5000000000,root.db.d2,null,1.0,",
- "5000000001,root.db.d2,null,null,",
+ "1997-01-01T08:00:00.001Z,null,null,",
+ "1997-01-01T08:00:00.002Z,1.0,null,",
+ "1997-01-01T08:00:00.003Z,null,2.0,",
+ "1997-01-01T08:00:00.004Z,2.0,null,",
+ "1997-01-01T08:00:00.005Z,1.0,2.0,",
+ "1997-01-01T08:00:00.006Z,null,1.0,",
+ "1970-02-27T20:53:20.000Z,null,1.0,",
+ "1970-02-27T20:53:20.001Z,3.0,null,"
};
resultSetEqualTest(
- "select Diff(s1, 'ignoreNull'='false'), diff(s2, 'ignoreNull'='false')
from root.db.d1, root.db.d2 align by device",
+ "select time,diff(s1), diff(s2) from table1 where device_id='d1'",
expectedHeader,
retArray);
- // align by device + order by time
- retArray =
- new String[] {
- "1,root.db.d1,null,null,",
- "1,root.db.d2,null,null,",
- "2,root.db.d1,1.0,null,",
- "2,root.db.d2,1.0,1.0,",
- "3,root.db.d1,null,null,",
- "4,root.db.d1,null,null,",
- "5,root.db.d1,1.0,null,",
- "6,root.db.d1,null,1.0,",
- "5000000000,root.db.d1,null,1.0,",
- "5000000000,root.db.d2,null,1.0,",
- "5000000001,root.db.d1,null,null,",
- "5000000001,root.db.d2,null,null,",
- };
- resultSetEqualTest(
- "select Diff(s1, 'ignoreNull'='false'), diff(s2, 'ignoreNull'='false')
from root.db.d1, root.db.d2 order by time align by device",
- expectedHeader,
- retArray);
- }
-
- // [change_points] is not mappable function, so this calculation use old
transformer
- @Test
- public void testOldTransformerIgnoreNull() {
- String[] expectedHeader =
- new String[] {TIMESTAMP_STR, "change_points(root.db.d1.s1)",
"diff(root.db.d1.s2)"};
- String[] retArray =
- new String[] {
- "1,1,null,",
- "2,2,null,",
- "3,null,2.0,",
- "4,4,null,",
- "5,5,2.0,",
- "6,null,1.0,",
- "5000000000,null,1.0,",
- "5000000001,8,null,"
- };
- resultSetEqualTest(
- "select change_points(s1), diff(s2) from root.db.d1", expectedHeader,
retArray);
-
// align by device
- expectedHeader = new String[] {TIMESTAMP_STR, DEVICE, "change_points(s1)",
"diff(s2)"};
+ expectedHeader = new String[] {"time", "device_id", "_col1", "_col2"};
retArray =
new String[] {
- "1,root.db.d1,1,null,",
- "2,root.db.d1,2,null,",
- "3,root.db.d1,null,2.0,",
- "4,root.db.d1,4,null,",
- "5,root.db.d1,5,2.0,",
- "6,root.db.d1,null,1.0,",
- "5000000000,root.db.d1,null,1.0,",
- "5000000001,root.db.d1,8,null,",
- "1,root.db.d2,1,null,",
- "2,root.db.d2,2,1.0,",
- "5000000000,root.db.d2,null,1.0,",
- "5000000001,root.db.d2,4,null,",
+ "1997-01-01T08:00:00.001Z,d1,null,null,",
+ "1997-01-01T08:00:00.002Z,d1,1.0,null,",
+ "1997-01-01T08:00:00.003Z,d1,null,2.0,",
+ "1997-01-01T08:00:00.004Z,d1,2.0,null,",
+ "1997-01-01T08:00:00.005Z,d1,1.0,2.0,",
+ "1997-01-01T08:00:00.006Z,d1,null,1.0,",
+ "1970-02-27T20:53:20.000Z,d1,null,1.0,",
+ "1970-02-27T20:53:20.001Z,d1,3.0,null,",
+ "1997-01-01T08:00:00.001Z,d2,null,null",
+ "1997-01-01T08:00:00.002Z,d2,1.0,1.0,",
+ "1970-02-27T20:53:20.000Z,d2,null,1.0,",
+ "1970-02-27T20:53:20.001Z,d2,2.0,null,",
};
resultSetEqualTest(
- "select change_points(s1), diff(s2) from root.db.d1, root.db.d2 align
by device",
+ "select time, device_id, Diff(s1), diff(s2) from table1 where
device_id='d1' or device_id='d2' order by device_id",
expectedHeader,
retArray);
// align by device + order by time
- expectedHeader = new String[] {TIMESTAMP_STR, DEVICE, "change_points(s1)",
"diff(s2)"};
retArray =
new String[] {
- "1,root.db.d1,1,null,",
- "1,root.db.d2,1,null,",
- "2,root.db.d1,2,null,",
- "2,root.db.d2,2,1.0,",
- "3,root.db.d1,null,2.0,",
- "4,root.db.d1,4,null,",
- "5,root.db.d1,5,2.0,",
- "6,root.db.d1,null,1.0,",
- "5000000000,root.db.d1,null,1.0,",
- "5000000000,root.db.d2,null,1.0,",
- "5000000001,root.db.d1,8,null,",
- "5000000001,root.db.d2,4,null,",
+ "1997-01-01T08:00:00.001Z,d1,null,null,",
+ "1997-01-01T08:00:00.001Z,d2,null,null",
+ "1997-01-01T08:00:00.002Z,d1,1.0,null,",
+ "1997-01-01T08:00:00.002Z,d2,1.0,1.0,",
+ "1997-01-01T08:00:00.003Z,d1,null,2.0,",
+ "1997-01-01T08:00:00.004Z,d1,2.0,null,",
+ "1997-01-01T08:00:00.005Z,d1,1.0,2.0,",
+ "1997-01-01T08:00:00.006Z,d1,null,1.0,",
+ "1970-02-27T20:53:20.000Z,d1,null,1.0,",
+ "1970-02-27T20:53:20.000Z,d2,null,1.0,",
+ "1970-02-27T20:53:20.001Z,d1,3.0,null,",
+ "1970-02-27T20:53:20.001Z,d2,2.0,null,",
};
resultSetEqualTest(
- "select change_points(s1), diff(s2) from root.db.d1, root.db.d2 order
by time align by device",
+ "select time, device_id, Diff(s1), diff(s2) from table1 where
device_id='d1' or device_id='d2' order by time,device_id",
expectedHeader,
retArray);
}
@Test
- public void testOldTransformerRespectNull() {
- String[] expectedHeader =
- new String[] {
- TIMESTAMP_STR,
- "change_points(root.db.d1.s1)",
- "diff(root.db.d1.s2, \"ignoreNull\"=\"false\")"
- };
+ public void testNewTransformerRespectNull() {
+ String[] expectedHeader = new String[] {"time", "_col1", "_col2"};
String[] retArray =
new String[] {
- "1,1,null,",
- "2,2,null,",
- "4,4,null,",
- "5,5,null,",
- "6,null,1.0,",
- "5000000000,null,1.0,",
- "5000000001,8,null,"
+ "1997-01-01T08:00:00.001Z,null,null,",
+ "1997-01-01T08:00:00.002Z,1.0,null,",
+ "1997-01-01T08:00:00.003Z,null,null,",
+ "1997-01-01T08:00:00.004Z,null,null,",
+ "1997-01-01T08:00:00.005Z,1.0,null,",
+ "1997-01-01T08:00:00.006Z,null,1.0,",
+ "1970-02-27T20:53:20.000Z,null,1.0,",
+ "1970-02-27T20:53:20.001Z,null,null,"
};
resultSetEqualTest(
- "select change_points(s1), diff(s2, 'ignoreNull'='false') from
root.db.d1",
+ "select time, Diff(s1, false), diff(s2, false) from table1 where
device_id='d1'",
expectedHeader,
retArray);
// align by device
- expectedHeader =
- new String[] {
- TIMESTAMP_STR, DEVICE, "change_points(s1)", "diff(s2,
\"ignoreNull\"=\"false\")"
- };
+ expectedHeader = new String[] {"time", "device_id", "_col1", "_col2"};
retArray =
new String[] {
- "1,root.db.d1,1,null,",
- "2,root.db.d1,2,null,",
- "4,root.db.d1,4,null,",
- "5,root.db.d1,5,null,",
- "6,root.db.d1,null,1.0,",
- "5000000000,root.db.d1,null,1.0,",
- "5000000001,root.db.d1,8,null,",
- "1,root.db.d2,1,null,",
- "2,root.db.d2,2,1.0,",
- "5000000000,root.db.d2,null,1.0,",
- "5000000001,root.db.d2,4,null,",
+ "1997-01-01T08:00:00.001Z,d1,null,null,",
+ "1997-01-01T08:00:00.002Z,d1,1.0,null,",
+ "1997-01-01T08:00:00.003Z,d1,null,null,",
+ "1997-01-01T08:00:00.004Z,d1,null,null,",
+ "1997-01-01T08:00:00.005Z,d1,1.0,null,",
+ "1997-01-01T08:00:00.006Z,d1,null,1.0,",
+ "1970-02-27T20:53:20.000Z,d1,null,1.0,",
+ "1970-02-27T20:53:20.001Z,d1,null,null,",
+ "1997-01-01T08:00:00.001Z,d2,null,null",
+ "1997-01-01T08:00:00.002Z,d2,1.0,1.0,",
+ "1970-02-27T20:53:20.000Z,d2,null,1.0,",
+ "1970-02-27T20:53:20.001Z,d2,null,null,",
};
resultSetEqualTest(
- "select change_points(s1), diff(s2, 'ignoreNull'='false') from
root.db.d1, root.db.d2 align by device",
+ "select time, device_id, Diff(s1, false), diff(s2, false) from table1
where device_id='d1' or device_id='d2' order by device_id",
expectedHeader,
retArray);
// align by device + order by time
- expectedHeader =
- new String[] {
- TIMESTAMP_STR, DEVICE, "change_points(s1)", "diff(s2,
\"ignoreNull\"=\"false\")"
- };
retArray =
new String[] {
- "1,root.db.d1,1,null,",
- "1,root.db.d2,1,null,",
- "2,root.db.d1,2,null,",
- "2,root.db.d2,2,1.0,",
- "4,root.db.d1,4,null,",
- "5,root.db.d1,5,null,",
- "6,root.db.d1,null,1.0,",
- "5000000000,root.db.d1,null,1.0,",
- "5000000000,root.db.d2,null,1.0,",
- "5000000001,root.db.d1,8,null,",
- "5000000001,root.db.d2,4,null,",
+ "1997-01-01T08:00:00.001Z,d1,null,null,",
+ "1997-01-01T08:00:00.001Z,d2,null,null",
+ "1997-01-01T08:00:00.002Z,d1,1.0,null,",
+ "1997-01-01T08:00:00.002Z,d2,1.0,1.0,",
+ "1997-01-01T08:00:00.003Z,d1,null,null,",
+ "1997-01-01T08:00:00.004Z,d1,null,null,",
+ "1997-01-01T08:00:00.005Z,d1,1.0,null,",
+ "1997-01-01T08:00:00.006Z,d1,null,1.0,",
+ "1970-02-27T20:53:20.000Z,d1,null,1.0,",
+ "1970-02-27T20:53:20.000Z,d2,null,1.0,",
+ "1970-02-27T20:53:20.001Z,d1,null,null,",
+ "1970-02-27T20:53:20.001Z,d2,null,null,",
};
resultSetEqualTest(
- "select change_points(s1), diff(s2, 'ignoreNull'='false') from
root.db.d1, root.db.d2 order by time align by device",
+ "select time, device_id, Diff(s1, false), diff(s2, false) where
device_id='d1' or device_id='d2' order by time,device_id",
expectedHeader,
retArray);
}
@Test
public void testCaseInSensitive() {
- String[] expectedHeader = new String[] {TIMESTAMP_STR, "root.db.d1.s1",
"root.db.d1.s2"};
- String[] retArray = new String[] {"2,2,null,", "4,4,null,", "5,5,5.0,"};
- resultSetEqualTest(
- "select s1, s2 from root.db.d1 where Diff(s1) between 1 and 2",
expectedHeader, retArray);
-
- retArray = new String[] {};
+ String[] expectedHeader = new String[] {"time", "s1", "s2"};
+ String[] retArray =
+ new String[] {
+ "1997-01-01T08:00:00.002Z,2,null,",
+ "1997-01-01T08:00:00.004Z,4,null,",
+ "1997-01-01T08:00:00.005Z,5,5.0,"
+ };
resultSetEqualTest(
- "select s1, s2 from root.db.d1 where Diff(notExist) between 1 and 2",
+ "select time, s1, s2 from table1 where device_id='d1' and diff(s1)
between 1 and 2",
expectedHeader,
retArray);
}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBDiffFunction2IT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBDiffFunction2IT.java
new file mode 100644
index 00000000000..a6fefaf68a1
--- /dev/null
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBDiffFunction2IT.java
@@ -0,0 +1,42 @@
+/*
+ * 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.relational.it.query.old.builtinfunction.scalar;
+
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.ClusterIT;
+import org.apache.iotdb.itbase.category.LocalStandaloneIT;
+
+import org.junit.BeforeClass;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({LocalStandaloneIT.class, ClusterIT.class})
+public class IoTDBDiffFunction2IT extends IoTDBDiffFunctionIT {
+ @BeforeClass
+ public static void setUp() throws Exception {
+
EnvFactory.getEnv().getConfig().getCommonConfig().setDataRegionGroupExtensionPolicy("CUSTOM");
+
EnvFactory.getEnv().getConfig().getCommonConfig().setDefaultDataRegionGroupNumPerDatabase(2);
+
EnvFactory.getEnv().getConfig().getCommonConfig().setPartitionInterval(1000);
+ EnvFactory.getEnv().initClusterEnvironment();
+ insertData();
+ }
+}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBDiffFunction3IT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBDiffFunction3IT.java
new file mode 100644
index 00000000000..82a298331dc
--- /dev/null
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBDiffFunction3IT.java
@@ -0,0 +1,42 @@
+/*
+ * 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.relational.it.query.old.builtinfunction.scalar;
+
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.ClusterIT;
+import org.apache.iotdb.itbase.category.LocalStandaloneIT;
+
+import org.junit.BeforeClass;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({LocalStandaloneIT.class, ClusterIT.class})
+public class IoTDBDiffFunction3IT extends IoTDBDiffFunctionIT {
+ @BeforeClass
+ public static void setUp() throws Exception {
+
EnvFactory.getEnv().getConfig().getCommonConfig().setDataRegionGroupExtensionPolicy("CUSTOM");
+
EnvFactory.getEnv().getConfig().getCommonConfig().setDefaultDataRegionGroupNumPerDatabase(3);
+
EnvFactory.getEnv().getConfig().getCommonConfig().setPartitionInterval(1000);
+ EnvFactory.getEnv().initClusterEnvironment();
+ insertData();
+ }
+}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/db/it/builtinfunction/scalar/IoTDBDiffFunctionIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBDiffFunctionIT.java
similarity index 95%
copy from
integration-test/src/test/java/org/apache/iotdb/db/it/builtinfunction/scalar/IoTDBDiffFunctionIT.java
copy to
integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBDiffFunctionIT.java
index 37887b4d382..9da3963c5da 100644
---
a/integration-test/src/test/java/org/apache/iotdb/db/it/builtinfunction/scalar/IoTDBDiffFunctionIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBDiffFunctionIT.java
@@ -7,7 +7,7 @@
* "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
+ * 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
@@ -17,12 +17,13 @@
* under the License.
*/
-package org.apache.iotdb.db.it.builtinfunction.scalar;
+package org.apache.iotdb.relational.it.query.old.builtinfunction.scalar;
import org.apache.iotdb.it.env.EnvFactory;
import org.apache.iotdb.it.framework.IoTDBTestRunner;
import org.apache.iotdb.itbase.category.ClusterIT;
import org.apache.iotdb.itbase.category.LocalStandaloneIT;
+import org.apache.iotdb.itbase.env.BaseEnv;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -30,7 +31,9 @@ import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
-import static org.apache.iotdb.db.it.utils.TestUtils.prepareData;
+import java.sql.Connection;
+import java.sql.Statement;
+
import static org.apache.iotdb.db.it.utils.TestUtils.resultSetEqualTest;
import static org.apache.iotdb.itbase.constant.TestConstant.DEVICE;
import static org.apache.iotdb.itbase.constant.TestConstant.TIMESTAMP_STR;
@@ -38,7 +41,6 @@ import static
org.apache.iotdb.itbase.constant.TestConstant.TIMESTAMP_STR;
@RunWith(IoTDBTestRunner.class)
@Category({LocalStandaloneIT.class, ClusterIT.class})
public class IoTDBDiffFunctionIT {
- // 2 devices 4 regions
protected static final String[] SQLs =
new String[] {
"CREATE DATABASE root.db",
@@ -65,7 +67,19 @@ public class IoTDBDiffFunctionIT {
public static void setUp() throws Exception {
EnvFactory.getEnv().getConfig().getCommonConfig().setPartitionInterval(1000);
EnvFactory.getEnv().initClusterEnvironment();
- prepareData(SQLs);
+ insertData();
+ }
+
+ protected static void insertData() {
+ try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+ Statement statement = connection.createStatement()) {
+
+ for (String sql : SQLs) {
+ statement.execute(sql);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
@AfterClass
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/TableMetadataImpl.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/TableMetadataImpl.java
index 5409feacf42..aa18bf262fa 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/TableMetadataImpl.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/TableMetadataImpl.java
@@ -149,7 +149,7 @@ public class TableMetadataImpl implements Metadata {
if (!isOneNumericType(argumentTypes)
&& !(argumentTypes.size() == 2
&& isNumericType(argumentTypes.get(0))
- && BOOLEAN.equals(argumentTypes.get(0)))) {
+ && BOOLEAN.equals(argumentTypes.get(1)))) {
throw new SemanticException(
"Scalar function "
+ functionName.toLowerCase(Locale.ENGLISH)