This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch ty/TableModelGrammar
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/ty/TableModelGrammar by this
push:
new 8f984a4f3fe Report INTERNAL_SERVER_ERROR in executeBatch
8f984a4f3fe is described below
commit 8f984a4f3feb2221427da9df0e946f40dd1fd5d5
Author: Jiang Tian <[email protected]>
AuthorDate: Thu Aug 8 14:24:55 2024 +0800
Report INTERNAL_SERVER_ERROR in executeBatch
---
.../iotdb/it/env/remote/env/RemoteServerEnv.java | 2 +-
.../it/db/it/IOTDBInsertWithTimeAtAnyIndexIT.java | 134 -----
...eBatchIT.java => IoTDBExecuteBatchTableIT.java} | 2 +-
...ushQueryIT.java => IoTDBFlushQueryTableIT.java} | 2 +-
...T.java => IoTDBInsertAlignedValuesTableIT.java} | 368 +++++++++----
.../it/db/it/IoTDBInsertMultiPartitionIT.java | 75 ---
.../relational/it/db/it/IoTDBInsertMultiRowIT.java | 196 -------
.../relational/it/db/it/IoTDBInsertNaNIT.java | 199 -------
.../relational/it/db/it/IoTDBInsertNullIT.java | 166 ------
.../relational/it/db/it/IoTDBInsertTableIT.java | 589 +++++++++++++++++++++
.../it/db/it/IoTDBInsertWithoutTimeIT.java | 135 -----
...iDeviceIT.java => IoTDBMultiDeviceTableIT.java} | 35 +-
.../it/db/it/IoTDBPartialInsertionIT.java | 221 --------
...oTDBRecoverIT.java => IoTDBRecoverTableIT.java} | 4 +-
...sedIT.java => IoTDBRecoverUnclosedTableIT.java} | 4 +-
...oTDBRestartIT.java => IoTDBRestartTableIT.java} | 4 +-
...onIT.java => IoTDBSetConfigurationTableIT.java} | 2 +-
.../db/it/aligned/IoTDBInsertAlignedValues2IT.java | 188 -------
.../db/it/aligned/IoTDBInsertAlignedValues3IT.java | 124 -----
.../db/it/aligned/IoTDBInsertAlignedValues4IT.java | 79 ---
.../it/query/old/query/IoTDBQueryDemoTableIT.java | 13 +-
.../protocol/thrift/impl/ClientRPCServiceImpl.java | 4 +-
.../plan/relational/sql/util/AstUtil.java | 5 +
.../plan/statement/crud/InsertRowStatement.java | 3 +-
24 files changed, 882 insertions(+), 1672 deletions(-)
diff --git
a/integration-test/src/main/java/org/apache/iotdb/it/env/remote/env/RemoteServerEnv.java
b/integration-test/src/main/java/org/apache/iotdb/it/env/remote/env/RemoteServerEnv.java
index fa5540e31a5..04e3399ad32 100644
---
a/integration-test/src/main/java/org/apache/iotdb/it/env/remote/env/RemoteServerEnv.java
+++
b/integration-test/src/main/java/org/apache/iotdb/it/env/remote/env/RemoteServerEnv.java
@@ -72,7 +72,7 @@ public class RemoteServerEnv implements BaseEnv {
try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
statement.execute("CREATE DATABASE root.init;");
- statement.execute("DELETE DATABASE root;");
+ statement.execute("DELETE DATABASE root.init;");
} catch (Exception e) {
e.printStackTrace();
throw new AssertionError(e.getMessage());
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IOTDBInsertWithTimeAtAnyIndexIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IOTDBInsertWithTimeAtAnyIndexIT.java
deleted file mode 100644
index e1cfb8ae007..00000000000
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IOTDBInsertWithTimeAtAnyIndexIT.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * 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.db.it;
-
-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;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-@RunWith(IoTDBTestRunner.class)
-@Category({LocalStandaloneIT.class, ClusterIT.class})
-public class IOTDBInsertWithTimeAtAnyIndexIT {
-
- @BeforeClass
- public static void setUp() throws Exception {
-
EnvFactory.getEnv().getConfig().getCommonConfig().setAutoCreateSchemaEnabled(true);
- EnvFactory.getEnv().initClusterEnvironment();
- }
-
- @AfterClass
- public static void tearDown() throws Exception {
- EnvFactory.getEnv().cleanClusterEnvironment();
- }
-
- @Test
- public void testInsertTimeAtAnyIndex() throws SQLException {
- try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
- Statement statement = connection.createStatement()) {
- statement.execute("create database IF NOT EXISTS test");
- statement.execute("use \"test\"");
- statement.addBatch(
- "create table IF NOT EXISTS db(id1 string id, s1 int32 measurement,
s2 int32 measurement)");
- statement.addBatch("insert into db(id1, s1, s2, time) values ('d1', 2,
3, 1)");
- statement.addBatch("insert into db(id1, s1, time, s2) values ('d1', 20,
10, 30)");
- statement.addBatch("insert into db(id1, \"time\", s1, s2) values ('d1',
100, 200, 300)");
- statement.executeBatch();
-
- try (ResultSet resultSet = statement.executeQuery("select time, s1 from
db")) {
- assertTrue(resultSet.next());
- assertEquals(1, resultSet.getLong(1));
- assertEquals(2, resultSet.getInt(2));
- assertTrue(resultSet.next());
- assertEquals(10, resultSet.getLong(1));
- assertEquals(20, resultSet.getInt(2));
- assertTrue(resultSet.next());
- assertEquals(100, resultSet.getLong(1));
- assertEquals(200, resultSet.getInt(2));
- assertFalse(resultSet.next());
- }
- }
- }
-
- public static void main(String[] args) throws SQLException {
- try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
- Statement statement = connection.createStatement()) {
- statement.execute("create database IF NOT EXISTS test");
- statement.execute("use \"test\"");
- statement.addBatch(
- "create table IF NOT EXISTS db(id1 string id, s1 int32 measurement,
s2 int32 measurement)");
- statement.addBatch("insert into db(id1, s1, s2, time) values ('d1', 2,
3, 1)");
- statement.addBatch("insert into db(id1, s1, time, s2) values ('d1', 20,
10, 30)");
- statement.addBatch("insert into db(id1, \"time\", s1, s2) values ('d1',
100, 200, 300)");
- statement.executeBatch();
-
- try (ResultSet resultSet = statement.executeQuery("select time, s1 from
db")) {
- assertTrue(resultSet.next());
- assertEquals(1, resultSet.getLong(1));
- assertEquals(2, resultSet.getDouble(2), 0.00001);
- assertTrue(resultSet.next());
- assertEquals(10, resultSet.getLong(1));
- assertEquals(20, resultSet.getDouble(2), 0.00001);
- assertTrue(resultSet.next());
- assertEquals(100, resultSet.getLong(1));
- assertEquals(200, resultSet.getDouble(2), 0.00001);
- assertFalse(resultSet.next());
- }
- }
- }
-
- @Test
- public void testInsertMultiTime() {
- try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
- Statement statement = connection.createStatement()) {
- try {
- statement.addBatch("create database test");
- statement.addBatch("use \"test\"");
- statement.addBatch(
- "create table (id1 string id, s1 int32 measurement, s2 int32
measurement)");
- statement.addBatch("insert into db(id1, s1, s2, time, time) values
('d1', 2, 3, 1, 1)");
- statement.executeBatch();
- fail();
- } catch (SQLException e) {
- // expected
- }
-
- } catch (SQLException e) {
- fail();
- }
- }
-}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBExecuteBatchIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBExecuteBatchTableIT.java
similarity index 99%
rename from
integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBExecuteBatchIT.java
rename to
integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBExecuteBatchTableIT.java
index 2727aa3cf3e..51960ba76b6 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBExecuteBatchIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBExecuteBatchTableIT.java
@@ -43,7 +43,7 @@ import static org.junit.Assert.fail;
@RunWith(IoTDBTestRunner.class)
@Category({LocalStandaloneIT.class, ClusterIT.class, RemoteIT.class})
@Ignore // 'Drop Table' and 'Alter table' is not supported
-public class IoTDBExecuteBatchIT {
+public class IoTDBExecuteBatchTableIT {
@Before
public void setUp() throws Exception {
EnvFactory.getEnv().initClusterEnvironment();
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBFlushQueryIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBFlushQueryTableIT.java
similarity index 99%
rename from
integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBFlushQueryIT.java
rename to
integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBFlushQueryTableIT.java
index 42d1ce43fc4..584fad84965 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBFlushQueryIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBFlushQueryTableIT.java
@@ -44,7 +44,7 @@ import static org.junit.Assert.fail;
@RunWith(IoTDBTestRunner.class)
@Category({LocalStandaloneIT.class, ClusterIT.class})
-public class IoTDBFlushQueryIT {
+public class IoTDBFlushQueryTableIT {
private static String[] sqls =
new String[] {
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/aligned/IoTDBInsertAlignedValuesIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertAlignedValuesTableIT.java
similarity index 57%
rename from
integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/aligned/IoTDBInsertAlignedValuesIT.java
rename to
integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertAlignedValuesTableIT.java
index 6b5082f75c6..6bd12b8eeb5 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/aligned/IoTDBInsertAlignedValuesIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertAlignedValuesTableIT.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.relational.it.db.it.aligned;
+package org.apache.iotdb.relational.it.db.it;
import org.apache.iotdb.it.env.EnvFactory;
import org.apache.iotdb.it.framework.IoTDBTestRunner;
@@ -25,8 +25,8 @@ import org.apache.iotdb.itbase.category.ClusterIT;
import org.apache.iotdb.itbase.category.LocalStandaloneIT;
import org.apache.iotdb.itbase.env.BaseEnv;
-import org.junit.After;
-import org.junit.Before;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -45,16 +45,20 @@ import static org.junit.Assert.fail;
@RunWith(IoTDBTestRunner.class)
@Category({LocalStandaloneIT.class, ClusterIT.class})
-public class IoTDBInsertAlignedValuesIT {
+public class IoTDBInsertAlignedValuesTableIT {
- @Before
- public void setUp() throws Exception {
+ @BeforeClass
+ public static void setUp() throws Exception {
EnvFactory.getEnv().getConfig().getCommonConfig().setAutoCreateSchemaEnabled(true);
EnvFactory.getEnv().initClusterEnvironment();
+ try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+ Statement statement = connection.createStatement()) {
+ statement.execute("create database t1");
+ }
}
- @After
- public void tearDown() throws Exception {
+ @AfterClass
+ public static void tearDown() throws Exception {
EnvFactory.getEnv().cleanClusterEnvironment();
}
@@ -62,7 +66,6 @@ public class IoTDBInsertAlignedValuesIT {
public void testInsertAlignedValues() throws SQLException {
try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
Statement statement = connection.createStatement()) {
- statement.execute("create database t1");
statement.execute("use \"t1\"");
statement.addBatch(
"create table wf01 (id1 string id, status boolean measurement,
temperature float measurement)");
@@ -112,17 +115,16 @@ public class IoTDBInsertAlignedValuesIT {
try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
Statement statement = connection.createStatement()) {
- statement.execute("create database t1");
statement.execute("use \"t1\"");
statement.addBatch(
- "create table wf01 (id1 string id, status boolean measurement,
temperature float measurement)");
+ "create table wf02 (id1 string id, status boolean measurement,
temperature float measurement)");
statement.addBatch(
- "insert into wf01(id1, time, status, temperature) values ('wt01',
4000, true, 17.1)");
- statement.addBatch("insert into wf01(id1, time, status) values ('wt01',
5000, true)");
- statement.addBatch("insert into wf01(id1, time, temperature) values
('wt01', 6000, 22)");
+ "insert into wf02(id1, time, status, temperature) values ('wt01',
4000, true, 17.1)");
+ statement.addBatch("insert into wf02(id1, time, status) values ('wt01',
5000, true)");
+ statement.addBatch("insert into wf02(id1, time, temperature) values
('wt01', 6000, 22)");
statement.executeBatch();
- try (ResultSet resultSet = statement.executeQuery("select status from
wf01")) {
+ try (ResultSet resultSet = statement.executeQuery("select status from
wf02")) {
assertTrue(resultSet.next());
assertTrue(resultSet.getBoolean(1));
assertTrue(resultSet.next());
@@ -131,7 +133,7 @@ public class IoTDBInsertAlignedValuesIT {
}
try (ResultSet resultSet =
- statement.executeQuery("select time, status, temperature from
wf01")) {
+ statement.executeQuery("select time, status, temperature from
wf02")) {
assertTrue(resultSet.next());
assertEquals(4000, resultSet.getLong(1));
@@ -157,18 +159,17 @@ public class IoTDBInsertAlignedValuesIT {
public void testUpdatingAlignedValues() throws SQLException {
try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
Statement statement = connection.createStatement()) {
- statement.execute("create database t1");
statement.execute("use \"t1\"");
statement.addBatch(
- "create table wf01 (id1 string id, status boolean measurement,
temperature float measurement)");
+ "create table wf03 (id1 string id, status boolean measurement,
temperature float measurement)");
statement.addBatch(
- "insert into wf01(id1, time, status, temperature) values ('wt01',
4000, true, 17.1)");
- statement.addBatch("insert into wf01(id1, time, status) values ('wt01',
5000, true)");
- statement.addBatch("insert into wf01(id1, time, temperature)values
('wt01', 5000, 20.1)");
- statement.addBatch("insert into wf01(id1, time, temperature)values
('wt01', 6000, 22)");
+ "insert into wf03(id1, time, status, temperature) values ('wt01',
4000, true, 17.1)");
+ statement.addBatch("insert into wf03(id1, time, status) values ('wt01',
5000, true)");
+ statement.addBatch("insert into wf03(id1, time, temperature)values
('wt01', 5000, 20.1)");
+ statement.addBatch("insert into wf03(id1, time, temperature)values
('wt01', 6000, 22)");
statement.executeBatch();
- try (ResultSet resultSet = statement.executeQuery("select time, status
from wf01")) {
+ try (ResultSet resultSet = statement.executeQuery("select time, status
from wf03")) {
assertTrue(resultSet.next());
assertTrue(resultSet.getBoolean(2));
assertTrue(resultSet.next());
@@ -177,7 +178,7 @@ public class IoTDBInsertAlignedValuesIT {
}
try (ResultSet resultSet =
- statement.executeQuery("select time, status, temperature from
wf01")) {
+ statement.executeQuery("select time, status, temperature from
wf03")) {
assertTrue(resultSet.next());
assertEquals(4000, resultSet.getLong(1));
@@ -198,7 +199,7 @@ public class IoTDBInsertAlignedValuesIT {
}
statement.execute("flush");
- try (ResultSet resultSet = statement.executeQuery("select time, status
from wf01")) {
+ try (ResultSet resultSet = statement.executeQuery("select time, status
from wf03")) {
assertTrue(resultSet.next());
assertTrue(resultSet.getBoolean(2));
assertTrue(resultSet.next());
@@ -207,7 +208,7 @@ public class IoTDBInsertAlignedValuesIT {
}
try (ResultSet resultSet =
- statement.executeQuery("select time, status, temperature from
wf01")) {
+ statement.executeQuery("select time, status, temperature from
wf03")) {
assertTrue(resultSet.next());
assertEquals(4000, resultSet.getLong(1));
@@ -233,15 +234,14 @@ public class IoTDBInsertAlignedValuesIT {
public void testInsertAlignedValuesWithSameTimestamp() throws SQLException {
try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
Statement statement = connection.createStatement()) {
- statement.execute("create database test");
- statement.execute("use \"test\"");
+ statement.execute("use \"t1\"");
statement.addBatch(
- "create table sg (id1 string id, s2 double measurement, s1 double
measurement)");
- statement.addBatch("insert into sg(id1,time,s2) values('d1',1,2)");
- statement.addBatch("insert into sg(id1,time,s1) values('d1',1,2)");
+ "create table sg3 (id1 string id, s2 double measurement, s1 double
measurement)");
+ statement.addBatch("insert into sg3(id1,time,s2) values('d1',1,2)");
+ statement.addBatch("insert into sg3(id1,time,s1) values('d1',1,2)");
statement.executeBatch();
- try (ResultSet resultSet = statement.executeQuery("select time, s1, s2
from sg")) {
+ try (ResultSet resultSet = statement.executeQuery("select time, s1, s2
from sg3")) {
assertTrue(resultSet.next());
assertEquals(1, resultSet.getLong(1));
@@ -252,7 +252,7 @@ public class IoTDBInsertAlignedValuesIT {
}
statement.execute("flush");
- try (ResultSet resultSet = statement.executeQuery("select time, s1, s2
from sg")) {
+ try (ResultSet resultSet = statement.executeQuery("select time, s1, s2
from sg3")) {
assertTrue(resultSet.next());
assertEquals(1, resultSet.getLong(1));
@@ -268,12 +268,11 @@ public class IoTDBInsertAlignedValuesIT {
public void testInsertWithWrongMeasurementNum1() throws SQLException {
try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
Statement statement = connection.createStatement()) {
- statement.execute("create database t1");
statement.execute("use \"t1\"");
statement.execute(
- "create table wf01 (id1 string id, status int32, temperature int32
measurement)");
+ "create table wf04 (id1 string id, status int32, temperature int32
measurement)");
statement.execute(
- "insert into wf01(id1, time, status, temperature) values('wt01',
11000, 100)");
+ "insert into wf04(id1, time, status, temperature) values('wt01',
11000, 100)");
fail();
} catch (SQLException e) {
assertEquals(
@@ -285,12 +284,11 @@ public class IoTDBInsertAlignedValuesIT {
public void testInsertWithWrongMeasurementNum2() {
try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
Statement statement = connection.createStatement()) {
- statement.execute("create database t1");
statement.execute("use \"t1\"");
statement.execute(
- "create table wf01 (id1 string id, status int32, temperature int32
measurement)");
+ "create table wf05 (id1 string id, status int32, temperature int32
measurement)");
statement.execute(
- "insert into wf01(id1, time, status, temperature) values('wt01',
11000, 100, 300, 400)");
+ "insert into wf05(id1, time, status, temperature) values('wt01',
11000, 100, 300, 400)");
fail();
} catch (SQLException e) {
assertEquals(
@@ -302,127 +300,267 @@ public class IoTDBInsertAlignedValuesIT {
public void testInsertWithWrongType() throws SQLException {
try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
Statement statement = connection.createStatement()) {
- statement.execute("create database lz");
- statement.execute("use \"lz\"");
+ statement.execute("use \"t1\"");
statement.execute(
- "create table dev (id1 string id, latitude int32 measurement,
longitude int32 measurement)");
- statement.execute("insert into dev(id1,time,latitude,longitude)
values('GPS', 1,1.3,6.7)");
+ "create table dev6 (id1 string id, latitude int32 measurement,
longitude int32 measurement)");
+ statement.execute("insert into dev6(id1,time,latitude,longitude)
values('GPS', 1,1.3,6.7)");
fail();
}
}
@Test
- public void testInsertTimeseriesWithUnMatchedAlignedType() throws
SQLException {
- try (Connection connection = EnvFactory.getEnv().getConnection();
+ public void testInsertWithDuplicatedMeasurements() {
+ try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
Statement statement = connection.createStatement()) {
- statement.execute("create ALIGNED timeseries root.db.d_aligned(s01 INT64
encoding=RLE)");
- statement.execute("insert into root.db.d_aligned(time, s01) aligned
values (4000, 123)");
- statement.execute("insert into root.db.d_aligned(time, s01) values
(5000, 456)");
- statement.execute("create timeseries root.db.d_not_aligned.s01 INT64
encoding=RLE");
- statement.execute("insert into root.db.d_not_aligned(time, s01) values
(4000, 987)");
- statement.execute("insert into root.db.d_not_aligned(time, s01) aligned
values (5000, 654)");
-
- try (ResultSet resultSet = statement.executeQuery("select s01 from
root.db.d_aligned")) {
- assertTrue(resultSet.next());
- assertEquals(4000, resultSet.getLong(1));
- assertEquals(123, resultSet.getLong(2));
+ statement.execute("use \"t1\"");
+ statement.execute("create table wf07(id1 string id, s3 boolean
measurement, status int32)");
+ statement.execute(
+ "insert into wf07(id1, time, s3, status, status) values('wt01', 100,
true, 20.1, 20.2)");
+ fail();
+ } catch (SQLException e) {
+ assertTrue(
+ e.getMessage(),
+ e.getMessage().contains("Insertion contains duplicated measurement:
status"));
+ }
+ }
- assertTrue(resultSet.next());
- assertEquals(5000, resultSet.getLong(1));
- assertEquals(456, resultSet.getLong(2));
+ @Test
+ public void testInsertMultiRows() {
+ try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+ Statement statement = connection.createStatement()) {
+ statement.execute("use \"t1\"");
+ statement.execute(
+ "create table sg8 (id1 string id, s1 int32 measurement, s2 int32
measurement)");
+ statement.execute(
+ "insert into sg8(id1, time, s1, s2) values('d1', 10, 2, 2), ('d1',
11, 3, '3'), ('d1', 12,12.11,false)");
+ fail();
+ } catch (SQLException e) {
+ assertTrue(e.getMessage(), e.getMessage().contains("data type is not
consistent"));
+ }
+ }
- assertFalse(resultSet.next());
+ @Test
+ public void testInsertLargeNumber() {
+ try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+ Statement statement = connection.createStatement()) {
+ statement.execute("use \"t1\"");
+ statement.execute(
+ "create table sg9 (id1 string id, s98 int64 measurement, s99 int64
measurement)");
+ statement.execute(
+ "insert into sg9(id1, time, s98, s99) values('d1', 10, 2,
271840880000000000000000)");
+ fail("Exception expected");
+ } catch (SQLException e) {
+ assertEquals(
+ "700: line 1:58: Invalid numeric literal: 271840880000000000000000",
e.getMessage());
+ }
+ }
+
+ @Test
+ public void testInsertAlignedWithEmptyPage() throws SQLException {
+ try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+ Statement statement = connection.createStatement()) {
+ statement.execute("use \"t1\"");
+ statement.execute(
+ "create table dev10 (id1 string id, s1 int32 measurement, s2 int32
measurement, s3 int32 measurement)");
+ for (int i = 0; i < 100; i++) {
+ if (i == 99) {
+ statement.addBatch(
+ "insert into dev10(id1,time,s1,s3) values("
+ + "'GPS'"
+ + ","
+ + i
+ + ","
+ + i
+ + ","
+ + i
+ + ")");
+ } else {
+ statement.addBatch(
+ "insert into dev10(id1, time,s1,s2) values("
+ + "'GPS'"
+ + ","
+ + i
+ + ","
+ + i
+ + ","
+ + i
+ + ")");
+ }
}
+ statement.executeBatch();
- try (ResultSet resultSet = statement.executeQuery("select s01 from
root.db.d_not_aligned")) {
- assertTrue(resultSet.next());
- assertEquals(4000, resultSet.getLong(1));
- assertEquals(987, resultSet.getLong(2));
+ statement.execute("flush");
+ int rowCount = 0;
+ try (ResultSet resultSet = statement.executeQuery("select time, s3 from
dev10")) {
+ while (resultSet.next()) {
+ assertEquals(99, resultSet.getInt(2));
+ rowCount++;
+ }
+ assertEquals(1, rowCount);
+ }
- assertTrue(resultSet.next());
- assertEquals(5000, resultSet.getLong(1));
- assertEquals(654, resultSet.getLong(2));
+ try (ResultSet resultSet = statement.executeQuery("select time, s2 from
dev10")) {
+ rowCount = 0;
+ while (resultSet.next()) {
+ assertEquals(rowCount, resultSet.getInt(2));
+ rowCount++;
+ }
+ assertEquals(99, rowCount);
+ }
- assertFalse(resultSet.next());
+ try (ResultSet resultSet = statement.executeQuery("select time, s1 from
dev10")) {
+ rowCount = 0;
+ while (resultSet.next()) {
+ assertEquals(rowCount, resultSet.getInt(2));
+ rowCount++;
+ }
+ assertEquals(100, rowCount);
}
}
}
@Test
- @Ignore // TODO: delete
- public void testInsertNonAlignedTimeseriesWithAligned() throws SQLException {
- try (Connection connection = EnvFactory.getEnv().getConnection();
+ public void testInsertAlignedWithEmptyPage2() throws SQLException {
+ try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
Statement statement = connection.createStatement()) {
- statement.execute("CREATE TIMESERIES root.lz.dev.GPS3.latitude with
datatype=INT32");
- statement.execute("CREATE TIMESERIES root.lz.dev.GPS3.longitude with
datatype=INT32");
+ statement.execute("use \"t1\"");
statement.execute(
- "insert into root.lz.dev.GPS3(time,latitude,longitude) aligned
values(1,123,456)");
- // it's supported.
+ "create table sg11 (id1 string id, s1 string measurement, s2 string
measurement)");
+
+ statement.execute("insert into sg11(id1, time, s1, s2) values('d1',
1,'aa','bb')");
+ statement.execute("insert into sg11(id1, time, s1, s2) values('d1',
1,'aa','bb')");
+ statement.execute("insert into sg11(id1, time, s1, s2) values('d2',
1,'aa','bb')");
+ statement.execute("flush");
+ statement.execute("insert into sg11(id1, time, s1, s2) values('d1',
1,'aa','bb')");
}
}
+ @Ignore // aggregation
@Test
- @Ignore // TODO: delete
- public void testInsertAlignedValuesWithThreeLevelPath() throws SQLException {
- try (Connection connection = EnvFactory.getEnv().getConnection();
+ public void testInsertComplexAlignedValues() throws SQLException {
+ try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
Statement statement = connection.createStatement()) {
- statement.execute("insert into root.sg_device(time, status) aligned
values (4000, true)");
+ statement.execute("use \"t1\"");
+ statement.addBatch(
+ "create table sg12 (id1 string id, s1 int32 measurement, s2 int32
measurement)");
+ statement.addBatch("insert into sg12(id1, time, s1) values('id1', 3,1)");
+ statement.addBatch("insert into sg12(id1, time, s1) values('id1', 3,1)");
+ statement.addBatch("insert into sg12(id1, time, s1) values('id1', 1,1)");
+ statement.addBatch("insert into sg12(id1, time, s1) values('id1', 2,1)");
+ statement.addBatch("insert into sg12(id1, time, s2) values('id1', 2,2)");
+ statement.addBatch("insert into sg12(id1, time, s2) values('id1', 1,2)");
+ statement.addBatch("insert into sg12(id1, time, s2) values('id1', 3,2)");
+ statement.addBatch("insert into sg12(id1, time, s3) values('id1', 1,3)");
+ statement.addBatch("insert into sg12(id1, time, s3) values('id1', 3,3)");
+ statement.executeBatch();
+
+ try (ResultSet resultSet =
+ statement.executeQuery("select count(s1), count(s2), count(s3) from
sg12")) {
- try (ResultSet resultSet = statement.executeQuery("select ** from
root")) {
assertTrue(resultSet.next());
- assertTrue(resultSet.getBoolean(2));
+ assertEquals(3, resultSet.getInt(1));
+ assertEquals(3, resultSet.getInt(2));
+ assertEquals(2, resultSet.getInt(3));
+
+ assertFalse(resultSet.next());
+ }
+
+ statement.execute("flush");
+ try (ResultSet resultSet =
+ statement.executeQuery("select count(s1), count(s2), count(s3) from
sg12")) {
+
+ assertTrue(resultSet.next());
+ assertEquals(3, resultSet.getInt(1));
+ assertEquals(3, resultSet.getInt(2));
+ assertEquals(2, resultSet.getInt(3));
+
assertFalse(resultSet.next());
}
}
}
@Test
- public void testInsertWithDuplicatedMeasurements() {
+ public void testInsertAlignedWithEmptyPage3() throws SQLException {
try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
Statement statement = connection.createStatement()) {
- statement.execute("create database t1");
statement.execute("use \"t1\"");
- statement.execute("create table wf01(id1 string id, s3 boolean
measurement, status int32)");
statement.execute(
- "insert into wf01(id1, time, s3, status, status) values('wt01', 100,
true, 20.1, 20.2)");
- fail();
- } catch (SQLException e) {
- assertTrue(
- e.getMessage(),
- e.getMessage().contains("Insertion contains duplicated measurement:
status"));
- }
- }
+ "create table dev13 (id1 string id, s1 int32 measurement, s2 int32
measurement, s3 int32 measurement)");
+ for (int i = 0; i < 100; i++) {
+ if (i >= 49) {
+ statement.addBatch(
+ "insert into dev13(id1,time,s1,s2,s3) values("
+ + "\'GPS\'"
+ + ","
+ + i
+ + ","
+ + i
+ + ","
+ + i
+ + ","
+ + i
+ + ")");
+ } else {
+ statement.addBatch(
+ "insert into dev13(id1,time,s1,s2) values("
+ + "\'GPS\'"
+ + ","
+ + i
+ + ","
+ + i
+ + ","
+ + i
+ + ")");
+ }
+ }
+ statement.executeBatch();
+ statement.execute("flush");
+ int rowCount = 0;
+ try (ResultSet resultSet = statement.executeQuery("select s3 from
dev13")) {
+ while (resultSet.next()) {
+ assertEquals(rowCount + 49, resultSet.getInt(1));
+ rowCount++;
+ }
+ assertEquals(51, rowCount);
+ }
- @Test
- public void testInsertMultiRows() {
- try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
- Statement statement = connection.createStatement()) {
- statement.execute("create database test");
- statement.execute("use \"test\"");
- statement.execute(
- "create table sg1 (id1 string id, s1 int32 measurement, s2 int32
measurement)");
- statement.execute(
- "insert into sg1(id1, time, s1, s2) values('d1', 10, 2, 2), ('d1',
11, 3, '3'), ('d1', 12,12.11,false)");
- fail();
- } catch (SQLException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("data type is not
consistent"));
+ try (ResultSet resultSet = statement.executeQuery("select s2 from
dev13")) {
+ rowCount = 0;
+ while (resultSet.next()) {
+ assertEquals(rowCount, resultSet.getInt(1));
+ rowCount++;
+ }
+ assertEquals(100, rowCount);
+ }
+
+ try (ResultSet resultSet = statement.executeQuery("select s1 from
dev13")) {
+ rowCount = 0;
+ while (resultSet.next()) {
+ assertEquals(rowCount, resultSet.getInt(1));
+ rowCount++;
+ }
+ assertEquals(100, rowCount);
+ }
}
}
@Test
- public void testInsertLargeNumber() {
+ public void testExtendTextColumn() {
try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
Statement statement = connection.createStatement()) {
- statement.execute("create database test");
- statement.execute("use \"test\"");
- statement.execute(
- "create table sg1 (id1 string id, s98 int64 measurement, s99 int64
measurement)");
+ statement.execute("use \"t1\"");
statement.execute(
- "insert into sg1(id1, time, s98, s99) values('d1', 10, 2,
271840880000000000000000)");
- fail("Exception expected");
- } catch (SQLException e) {
- assertEquals(
- "700: line 1:58: Invalid numeric literal: 271840880000000000000000",
e.getMessage());
+ "create table sg14 (id1 string id, s1 string measurement, s2 string
measurement)");
+ statement.execute("insert into sg14(id1,time,s1,s2)
values('d1',1,'test','test')");
+ statement.execute("insert into sg14(id1,time,s1,s2)
values('d1',2,'test','test')");
+ statement.execute("insert into sg14(id1,time,s1,s2)
values('d1',3,'test','test')");
+ statement.execute("insert into sg14(id1,time,s1,s2)
values('d1',4,'test','test')");
+ statement.execute("insert into sg14(id1,time,s1,s3)
values('d1',5,'test','test')");
+ statement.execute("insert into sg14(id1,time,s1,s2)
values('d1',6,'test','test')");
+ statement.execute("flush");
+ statement.execute("insert into sg14(id1,time,s1,s3)
values('d1',7,'test','test')");
+ fail();
+ } catch (SQLException ignored) {
}
}
}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertMultiPartitionIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertMultiPartitionIT.java
deleted file mode 100644
index 3d3654de265..00000000000
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertMultiPartitionIT.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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.db.it;
-
-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.category.RemoteIT;
-import org.apache.iotdb.itbase.env.BaseEnv;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-
-import java.sql.Connection;
-import java.sql.Statement;
-
-import static org.junit.Assert.fail;
-
-@RunWith(IoTDBTestRunner.class)
-@Category({LocalStandaloneIT.class, ClusterIT.class, RemoteIT.class})
-public class IoTDBInsertMultiPartitionIT {
-
- @BeforeClass
- public static void setUp() throws Exception {
- EnvFactory.getEnv()
- .getConfig()
- .getDataNodeCommonConfig()
- .setWriteMemoryProportion("10000000:1");
- EnvFactory.getEnv().initClusterEnvironment();
- }
-
- @AfterClass
- public static void tearDown() throws Exception {
- EnvFactory.getEnv().cleanClusterEnvironment();
- }
-
- @Test
- public void testInsertMultiPartition() {
-
- try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
- Statement statement = connection.createStatement()) {
- statement.execute("create database test");
- statement.execute("use \"test\"");
- statement.execute("create table sg (id1 string id, s1 int32
measurement)");
- statement.execute("insert into sg(id1,time,s1) values('d1',1,2)");
- statement.execute("flush");
- statement.execute("insert into sg(id1,time,s1) values('d1',2,2)");
- statement.execute("insert into sg(id1,time,s1)
values('d1',604800001,2)");
- statement.execute("flush");
- } catch (Exception e) {
- fail(e.getMessage());
- }
- }
-}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertMultiRowIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertMultiRowIT.java
deleted file mode 100644
index 8322f2a2b6a..00000000000
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertMultiRowIT.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * 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.db.it;
-
-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.apache.iotdb.rpc.TSStatusCode;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-@RunWith(IoTDBTestRunner.class)
-@Category({LocalStandaloneIT.class, ClusterIT.class})
-public class IoTDBInsertMultiRowIT {
- private static List<String> sqls = new ArrayList<>();
- private static Connection connection;
-
- @BeforeClass
- public static void setUp() throws Exception {
-
EnvFactory.getEnv().getConfig().getCommonConfig().setMaxInnerCompactionCandidateFileNum(2);
- EnvFactory.getEnv().initClusterEnvironment();
- initCreateSQLStatement();
- insertData();
- }
-
- @AfterClass
- public static void tearDown() throws Exception {
- close();
- EnvFactory.getEnv().cleanClusterEnvironment();
- }
-
- private static void close() {
- if (Objects.nonNull(connection)) {
- try {
- connection.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
-
- private static void initCreateSQLStatement() {
- sqls.add("CREATE DATABASE t1");
- sqls.add("USE \"t1\"");
- sqls.add(
- "create table wf01 (id1 string id, status boolean measurement,
temperature float measurement)");
- }
-
- private static void insertData() throws ClassNotFoundException, SQLException
{
- connection = EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
- Statement statement = connection.createStatement();
-
- for (String sql : sqls) {
- statement.execute(sql);
- }
-
- statement.close();
- }
-
- @Ignore // aggregation
- @Test
- public void testInsertMultiRow() throws SQLException {
- Statement st0 = connection.createStatement();
- st0.execute("insert into wf01(id1, time, status) values ('wt01', 1,
true)");
- st0.execute("insert into wf01(id1, time, status) values ('wt01', 2, true),
('wt01', 3, false)");
- st0.execute(
- "insert into wf01(id1, time, status) values ('wt01', 4, true),
('wt01', 5, true), ('wt01', 6, false)");
-
- st0.execute("insert into wf01(id1, time, temperature, status) values
('wt01', 7, 15.3, true)");
- st0.execute(
- "insert into wf01(id1, time, temperature, status) values ('wt01', 8,
18.3, false), ('wt01', 9, 23.1, false)");
- st0.execute(
- "insert into wf01(id1, time, temperature, status) values ('wt01', 10,
22.3, true), ('wt01', 11, 18.8, false), ('wt01', 12, 24.4, true)");
- st0.close();
-
- Statement st1 = connection.createStatement();
- ResultSet rs1 = st1.executeQuery("select count(status) from wf01");
- rs1.next();
- long countStatus = rs1.getLong(1);
- assertEquals(countStatus, 12L);
-
- ResultSet rs2 = st1.executeQuery("select count(temperature) from wf01");
- rs2.next();
- long countTemperature = rs2.getLong(1);
- assertEquals(countTemperature, 6L);
-
- st1.close();
- }
-
- @Test(expected = Exception.class)
- @Ignore
- public void testInsertWithTimesColumns() throws SQLException {
- Statement st1 = connection.createStatement();
- st1.execute("insert into wf01(id1,time) values('wt01', 1)");
- }
-
- @Test
- public void testInsertMultiRowWithMisMatchDataType() {
- try {
- Statement st1 = connection.createStatement();
- st1.execute(
- "insert into wf01(id1, time, status) values('wt01', 1, 1.0),
('wt01', 2, 'hello')");
- fail();
- } catch (SQLException e) {
- assertTrue(
-
e.getMessage().contains(Integer.toString(TSStatusCode.METADATA_ERROR.getStatusCode())));
- }
- }
-
- @Test
- @Ignore // TODO: delete
- public void testInsertMultiRowWithNull() {
- try (Statement st1 = connection.createStatement()) {
- st1.execute(
- "insert into root.t1.d99.wt01(time, s1, s2) values(100, null, 1),
(101, null, 2)");
- fail();
- } catch (SQLException e) {
- assertTrue(
-
e.getMessage().contains(Integer.toString(TSStatusCode.METADATA_ERROR.getStatusCode())));
- }
- try (Statement st2 = connection.createStatement()) {
- st2.execute("CREATE TIMESERIES root.t1.d1.s1 WITH DATATYPE=double,
ENCODING=PLAIN;");
- st2.execute(
- "INSERT INTO root.t1.d1(time, s1) VALUES (6,
10),(7,12),(8,14),(9,160),(10,null),(11,58)");
- } catch (SQLException e) {
- fail();
- }
- }
-
- @Test
- public void testInsertMultiRowWithWrongTimestampPrecision() {
- try (Statement st1 = connection.createStatement()) {
- st1.execute(
- "insert into wf01(id1, time, status) values('wt01',
1618283005586000, true), ('wt01', 1618283005586001, false)");
- fail();
- } catch (SQLException e) {
- assertTrue(e.getMessage().contains("Current system timestamp precision
is ms"));
- }
- }
-
- @Test
- public void testInsertMultiRowWithMultiTimePartition() throws Exception {
- try (Statement st1 = connection.createStatement()) {
- st1.execute("create table sg1 (id1 string id, s1 int32 measurement)");
- st1.execute("insert into sg1(id1, time, s1) values('d1', 604800010,1)");
- st1.execute("flush");
- st1.execute("insert into sg1(id1, time, s1) values('d1', 604799990,1),
('d1', 604800001,1)");
- st1.execute("flush");
- ResultSet rs1 = st1.executeQuery("select time, s1 from sg1");
- assertTrue(rs1.next());
- assertEquals(604799990, rs1.getLong("time"));
- assertTrue(rs1.next());
- assertEquals(604800001, rs1.getLong("time"));
- assertTrue(rs1.next());
- assertEquals(604800010, rs1.getLong("time"));
- assertFalse(rs1.next());
- }
- }
-}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertNaNIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertNaNIT.java
deleted file mode 100644
index bb597bfc3d2..00000000000
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertNaNIT.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * 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.db.it;
-
-import org.apache.iotdb.db.queryengine.common.header.ColumnHeaderConstant;
-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.category.RemoteIT;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.apache.iotdb.db.utils.constant.TestConstant.TIMESTAMP_STR;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-/**
- * Notice that, all test begins with "IoTDB" is integration test. All test
which will start the
- * IoTDB server should be defined as integration test.
- *
- * <p>This test stores NaN Values and retrieves them via SQL Interface.
- */
-@RunWith(IoTDBTestRunner.class)
-@Category({LocalStandaloneIT.class, ClusterIT.class, RemoteIT.class})
-public class IoTDBInsertNaNIT {
-
- private static final String CREATE_TEMPLATE_SQL =
- "CREATE TIMESERIES root.vehicle.%s.%s WITH DATATYPE=%s, ENCODING=%s,
'MAX_POINT_NUMBER'='%d'";
- private static final String INSERT_TEMPLATE_SQL =
- "insert into root.vehicle.%s(timestamp,%s) values(%d,%s)";
- private static final String INSERT_BRAND_NEW_TEMPLATE_SQL =
- "insert into root.cycle.%s(timestamp,%s) values(%d,%s)";
- private static List<String> sqls = new ArrayList<>();
- private static final int TIMESTAMP = 10;
- private static final String VALUE = "NaN";
- private static final float DELTA_FLOAT = 0.0000001f;
- private static final double DELTA_DOUBLE = 0.0000001d;
-
- @BeforeClass
- public static void setUp() throws Exception {
- EnvFactory.getEnv().initClusterEnvironment();
- initCreateSQLStatement();
- insertData();
- }
-
- @AfterClass
- public static void tearDown() throws Exception {
- EnvFactory.getEnv().cleanClusterEnvironment();
- }
-
- private static void initCreateSQLStatement() {
- sqls.add("CREATE DATABASE root.happy");
- sqls.add("CREATE DATABASE root.cycle");
- sqls.add("CREATE DATABASE root.vehicle.f0");
- sqls.add("CREATE DATABASE root.vehicle.d0");
- for (int i = 0; i < 10; i++) {
- sqls.add(String.format(CREATE_TEMPLATE_SQL, "f0", "s" + i + "rle",
"FLOAT", "RLE", i));
- sqls.add(String.format(CREATE_TEMPLATE_SQL, "f0", "s" + i + "2f",
"FLOAT", "TS_2DIFF", i));
- sqls.add(String.format(CREATE_TEMPLATE_SQL, "d0", "s" + i + "rle",
"DOUBLE", "RLE", i));
- sqls.add(String.format(CREATE_TEMPLATE_SQL, "d0", "s" + i + "2f",
"DOUBLE", "TS_2DIFF", i));
- }
- for (int i = 0; i < 10; i++) {
- sqls.add(String.format(INSERT_TEMPLATE_SQL, "f0", "s" + i + "rle",
TIMESTAMP, VALUE));
- sqls.add(String.format(INSERT_TEMPLATE_SQL, "f0", "s" + i + "2f",
TIMESTAMP, VALUE));
- sqls.add(String.format(INSERT_TEMPLATE_SQL, "d0", "s" + i + "rle",
TIMESTAMP, VALUE));
- sqls.add(String.format(INSERT_TEMPLATE_SQL, "d0", "s" + i + "2f",
TIMESTAMP, VALUE));
- }
- }
-
- private static void insertData() {
- try (Connection connection = EnvFactory.getEnv().getConnection();
- Statement statement = connection.createStatement()) {
-
- for (String sql : sqls) {
- statement.execute(sql);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void selectAllSQLTest() {
- try (Connection connection = EnvFactory.getEnv().getConnection();
- Statement statement = connection.createStatement()) {
- int cnt;
- try (ResultSet resultSet = statement.executeQuery("select * from
root.vehicle.*")) {
- assertNotNull(resultSet);
- cnt = 0;
- while (resultSet.next()) {
- assertEquals(TIMESTAMP + "", resultSet.getString(TIMESTAMP_STR));
- for (int i = 0; i < 10; i++) {
- assertEquals(
- Float.parseFloat(VALUE),
- resultSet.getFloat(String.format("root.vehicle.%s.%s", "f0",
"s" + i + "rle")),
- DELTA_FLOAT);
- assertEquals(
- Float.parseFloat(VALUE),
- resultSet.getFloat(String.format("root.vehicle.%s.%s", "f0",
"s" + i + "2f")),
- DELTA_FLOAT);
- assertEquals(
- Double.parseDouble(VALUE),
- resultSet.getDouble(String.format("root.vehicle.%s.%s", "d0",
"s" + i + "rle")),
- DELTA_DOUBLE);
- assertEquals(
- Double.parseDouble(VALUE),
- resultSet.getDouble(String.format("root.vehicle.%s.%s", "d0",
"s" + i + "2f")),
- DELTA_DOUBLE);
- }
- cnt++;
- }
- assertEquals(1, cnt);
- }
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void selectTest() {
- try (Connection connection = EnvFactory.getEnv().getConnection();
- Statement statement = connection.createStatement()) {
- statement.execute(
- "CREATE TIMESERIES root.happy.device1.sensor1.temperature WITH
DATATYPE=DOUBLE, ENCODING=RLE");
- statement.execute(
- "INSERT INTO root.happy.device1.sensor1(timestamp,temperature)
values(7925, NaN)");
- int cnt;
- try (ResultSet resultSet =
- statement.executeQuery("select * from root.happy.device1.sensor1")) {
- assertNotNull(resultSet);
- cnt = 0;
- while (resultSet.next()) {
- assertEquals(7925 + "", resultSet.getString(TIMESTAMP_STR));
- assertEquals(
- Double.parseDouble(VALUE),
- resultSet.getDouble("root.happy.device1.sensor1.temperature"),
- DELTA_DOUBLE);
- cnt++;
- }
- assertEquals(1, cnt);
- }
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void testNaNValue() {
- try (Connection connection = EnvFactory.getEnv().getConnection();
- Statement statement = connection.createStatement()) {
- statement.execute(
- String.format(INSERT_BRAND_NEW_TEMPLATE_SQL, "d0", "s0" + "2f",
TIMESTAMP, VALUE));
- boolean exist = false;
- try (ResultSet resultSet = statement.executeQuery("show timeseries")) {
- assertNotNull(resultSet);
- while (resultSet.next()) {
- if
((resultSet.getString(ColumnHeaderConstant.TIMESERIES)).contains("root.cycle.d0.s0"))
{
- exist = true;
- }
- }
- }
- assertTrue(exist);
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertNullIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertNullIT.java
deleted file mode 100644
index 75c2a7093d6..00000000000
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertNullIT.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * 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.db.it;
-
-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.category.RemoteIT;
-import org.apache.iotdb.itbase.env.BaseEnv;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-@RunWith(IoTDBTestRunner.class)
-@Category({LocalStandaloneIT.class, ClusterIT.class, RemoteIT.class})
-public class IoTDBInsertNullIT {
- private static final List<String> sqls = new ArrayList<>();
- private static Connection connection;
-
- @BeforeClass
- public static void setUp() throws Exception {
- EnvFactory.getEnv().initClusterEnvironment();
- initCreateSQLStatement();
- insertData();
- }
-
- @AfterClass
- public static void tearDown() throws Exception {
- close();
- EnvFactory.getEnv().cleanClusterEnvironment();
- }
-
- private static void close() {
- if (Objects.nonNull(connection)) {
- try {
- connection.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
-
- private static void initCreateSQLStatement() {
- sqls.add("CREATE DATABASE test");
- sqls.add("USE \"test\"");
- sqls.add(
- "CREATE TABLE sg (id1 string id, s1 boolean measurement, s2 float
measurement, s3 int32 measurement)");
- }
-
- private static void insertData() throws SQLException {
- connection = EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
- Statement statement = connection.createStatement();
-
- for (String sql : sqls) {
- statement.execute(sql);
- }
-
- statement.close();
- }
-
- @Test
- public void testInsertNull() {
- String[] retArray =
- new String[] {
- "1,d2,null,1.0,1,", "2,d2,true,null,2,", "3,d2,true,3.0,null,",
- };
-
- try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
- Statement statement = connection.createStatement()) {
- statement.execute("use \"test\"");
- statement.execute("insert into sg(id1,time,s1,s2,s3)
values('d2',1,null,1.0,1)");
- statement.execute("insert into sg(id1,time,s1,s2,s3)
values('d2',2,true,null,2)");
- statement.execute("insert into sg(id1,time,s1,s2,s3)
values('d2',3,true,3.0,null)");
-
- try (ResultSet resultSet = statement.executeQuery("select * from sg")) {
- assertNotNull(resultSet);
- ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
- List<Integer> actualIndexToExpectedIndexList =
- checkHeader(
- resultSetMetaData,
- "time,id1,s1,s2,s3",
- new int[] {
- Types.TIMESTAMP, Types.VARCHAR, Types.BOOLEAN, Types.FLOAT,
Types.INTEGER,
- });
-
- int cnt = 0;
- while (resultSet.next()) {
- String[] expectedStrings = retArray[cnt].split(",");
- StringBuilder expectedBuilder = new StringBuilder();
- StringBuilder actualBuilder = new StringBuilder();
- for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++) {
- if (i == 1) {
-
actualBuilder.append(resultSet.getTimestamp(i).getTime()).append(",");
- } else {
- actualBuilder.append(resultSet.getString(i)).append(",");
- }
- expectedBuilder
- .append(expectedStrings[actualIndexToExpectedIndexList.get(i -
1)])
- .append(",");
- }
- assertEquals(expectedBuilder.toString(), actualBuilder.toString());
- cnt++;
- }
- assertEquals(3, cnt);
- }
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- private List<Integer> checkHeader(
- ResultSetMetaData resultSetMetaData, String expectedHeaderStrings, int[]
expectedTypes)
- throws SQLException {
- String[] expectedHeaders = expectedHeaderStrings.split(",");
- Map<String, Integer> expectedHeaderToTypeIndexMap = new HashMap<>();
- for (int i = 0; i < expectedHeaders.length; ++i) {
- expectedHeaderToTypeIndexMap.put(expectedHeaders[i], i);
- }
-
- List<Integer> actualIndexToExpectedIndexList = new ArrayList<>();
- for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++) {
- Integer typeIndex =
expectedHeaderToTypeIndexMap.get(resultSetMetaData.getColumnName(i));
- assertNotNull(typeIndex);
- assertEquals(expectedTypes[typeIndex],
resultSetMetaData.getColumnType(i));
- actualIndexToExpectedIndexList.add(typeIndex);
- }
- return actualIndexToExpectedIndexList;
- }
-}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertTableIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertTableIT.java
new file mode 100644
index 00000000000..16397c5254e
--- /dev/null
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertTableIT.java
@@ -0,0 +1,589 @@
+/*
+ * 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.db.it;
+
+import org.apache.iotdb.isession.ISession;
+import org.apache.iotdb.isession.SessionDataSet;
+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.category.RemoteIT;
+import org.apache.iotdb.itbase.env.BaseEnv;
+import org.apache.iotdb.rpc.TSStatusCode;
+
+import org.apache.tsfile.enums.TSDataType;
+import org.apache.tsfile.read.common.RowRecord;
+import org.apache.tsfile.write.record.Tablet;
+import org.apache.tsfile.write.schema.IMeasurementSchema;
+import org.apache.tsfile.write.schema.MeasurementSchema;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static
org.apache.iotdb.db.it.utils.TestUtils.assertTableNonQueryTestFail;
+import static org.apache.iotdb.db.it.utils.TestUtils.resultSetEqualTest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({LocalStandaloneIT.class, ClusterIT.class, RemoteIT.class})
+public class IoTDBInsertTableIT {
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ EnvFactory.getEnv()
+ .getConfig()
+ .getDataNodeCommonConfig()
+ .setWriteMemoryProportion("10000000:1");
+ EnvFactory.getEnv().initClusterEnvironment();
+ try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+ Statement statement = connection.createStatement()) {
+ statement.execute("create database if not exists test");
+ statement.execute("use test");
+ statement.execute(
+ "CREATE TABLE sg10(id1 string id, s1 int64 measurement, s2 float
measurement, s3 string measurement)");
+ statement.execute(
+ "CREATE TABLE sg11(id1 string id, s1 int64 measurement, s2 float
measurement, s3 string measurement)");
+ }
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ EnvFactory.getEnv().cleanClusterEnvironment();
+ }
+
+ @Test
+ public void testInsertMultiPartition() {
+ try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+ Statement statement = connection.createStatement()) {
+ statement.execute("use \"test\"");
+ statement.execute("create table sg1 (id1 string id, s1 int32
measurement)");
+ statement.execute("insert into sg1(id1,time,s1) values('d1',1,2)");
+ statement.execute("flush");
+ statement.execute("insert into sg1(id1,time,s1) values('d1',2,2)");
+ statement.execute("insert into sg1(id1,time,s1)
values('d1',604800001,2)");
+ statement.execute("flush");
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testInsertTimeAtAnyIndex() throws SQLException {
+ try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+ Statement statement = connection.createStatement()) {
+ statement.execute("use \"test\"");
+ statement.addBatch(
+ "create table IF NOT EXISTS db2(id1 string id, s1 int32 measurement,
s2 int32 measurement)");
+ statement.addBatch("insert into db2(id1, s1, s2, time) values ('d1', 2,
3, 1)");
+ statement.addBatch("insert into db2(id1, s1, time, s2) values ('d1', 20,
10, 30)");
+ statement.addBatch("insert into db2(id1, \"time\", s1, s2) values ('d1',
100, 200, 300)");
+ statement.executeBatch();
+
+ try (ResultSet resultSet = statement.executeQuery("select time, s1 from
db2")) {
+ assertTrue(resultSet.next());
+ assertEquals(1, resultSet.getLong(1));
+ assertEquals(2, resultSet.getInt(2));
+ assertTrue(resultSet.next());
+ assertEquals(10, resultSet.getLong(1));
+ assertEquals(20, resultSet.getInt(2));
+ assertTrue(resultSet.next());
+ assertEquals(100, resultSet.getLong(1));
+ assertEquals(200, resultSet.getInt(2));
+ assertFalse(resultSet.next());
+ }
+ }
+ }
+
+ @Test
+ public void testInsertMultiTime() {
+ try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+ Statement statement = connection.createStatement()) {
+ try {
+ statement.addBatch("use \"test\"");
+ statement.addBatch(
+ "create table t3(id1 string id, s1 int32 measurement, s2 int32
measurement)");
+ statement.addBatch("insert into t3(id1, s1, s2, time, time) values
('d1', 2, 3, 1, 1)");
+ statement.executeBatch();
+ fail();
+ } catch (SQLException e) {
+ // expected
+ }
+
+ } catch (SQLException e) {
+ fail();
+ }
+ }
+
+ @Test
+ public void testPartialInsertionAllFailed() throws SQLException {
+ try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+ Statement statement = connection.createStatement()) {
+ try {
+ statement.execute("USE \"test\"");
+ statement.execute("create table sg4 (id1 string id, s0 int32
measurement)");
+ statement.execute("INSERT INTO sg4(id1, timestamp, s0) VALUES ('id',
1, 1)");
+ fail();
+ } catch (SQLException e) {
+ assertTrue(e.getMessage().contains("Unknown column category"));
+ }
+ }
+ }
+
+ @Test
+ public void testPartialInsertionRestart() throws SQLException {
+ try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+ Statement statement = connection.createStatement()) {
+ statement.execute("USE \"test\"");
+ statement.execute("SET CONFIGURATION enable_auto_create_schema=false");
+ statement.execute(
+ "create table sg5 (id1 string id, s1 text measurement, s2 double
measurement)");
+
+ try {
+ statement.execute("INSERT INTO sg5(id1,time,s1,s2) VALUES('d1',
100,'test','test')");
+ } catch (SQLException e) {
+ // ignore
+ }
+ } finally {
+ try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+ Statement statement = connection.createStatement()) {
+ statement.execute("SET CONFIGURATION enable_auto_create_schema=true");
+ }
+ }
+
+ // TODO: replace restartDaemon() with new methods in Env.
+ /*
+ long time = 0;
+ try {
+ EnvironmentUtils.restartDaemon();
+ StorageEngine.getInstance().recover();
+ // wait for recover
+ while (!StorageEngine.getInstance().isAllSgReady()) {
+ Thread.sleep(500);
+ time += 500;
+ if (time > 10000) {
+ logger.warn("wait too long in restart, wait for: " + time / 1000 +
"s");
+ }
+ }
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ */
+
+ try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+ Statement statement = connection.createStatement()) {
+ statement.execute("use \"test\"");
+
+ try (ResultSet resultSet = statement.executeQuery("SELECT s1 FROM sg5"))
{
+ assertNotNull(resultSet);
+ int cnt = 0;
+ while (resultSet.next()) {
+ cnt++;
+ assertEquals("test", resultSet.getString("s1"));
+ }
+ assertEquals(1, cnt);
+ }
+ try (ResultSet resultSet = statement.executeQuery("SELECT s2 FROM sg5"))
{
+ assertNotNull(resultSet);
+ assertFalse(resultSet.next());
+ }
+ }
+ }
+
+ @Test
+ public void testPartialInsertTablet() {
+ try (ISession session =
EnvFactory.getEnv().getSessionConnection(BaseEnv.TABLE_SQL_DIALECT)) {
+ session.executeNonQueryStatement("use \"test\"");
+ session.executeNonQueryStatement("SET CONFIGURATION
enable_auto_create_schema=false");
+ session.executeNonQueryStatement(
+ "create table sg6 (id1 string id, s1 int64 measurement, s2 int64
measurement)");
+ List<IMeasurementSchema> schemaList = new ArrayList<>();
+ schemaList.add(new MeasurementSchema("id1", TSDataType.STRING));
+ schemaList.add(new MeasurementSchema("s1", TSDataType.INT64));
+ schemaList.add(new MeasurementSchema("s2", TSDataType.INT64));
+ schemaList.add(new MeasurementSchema("s3", TSDataType.INT64));
+ final List<Tablet.ColumnType> columnTypes =
+ Arrays.asList(
+ Tablet.ColumnType.ID,
+ Tablet.ColumnType.MEASUREMENT,
+ Tablet.ColumnType.MEASUREMENT,
+ Tablet.ColumnType.MEASUREMENT);
+ Tablet tablet = new Tablet("sg6", schemaList, columnTypes, 300);
+ long timestamp = 0;
+ for (long row = 0; row < 100; row++) {
+ int rowIndex = tablet.rowSize++;
+ tablet.addTimestamp(rowIndex, timestamp);
+ for (int s = 0; s < 4; s++) {
+ long value = timestamp;
+ if (s == 0) {
+ tablet.addValue(schemaList.get(s).getMeasurementId(), rowIndex,
"d1");
+ } else {
+ tablet.addValue(schemaList.get(s).getMeasurementId(), rowIndex,
value);
+ }
+ }
+ timestamp++;
+ }
+ timestamp = System.currentTimeMillis();
+ for (long row = 0; row < 100; row++) {
+ int rowIndex = tablet.rowSize++;
+ tablet.addTimestamp(rowIndex, timestamp);
+ for (int s = 0; s < 4; s++) {
+ long value = timestamp;
+ if (s == 0) {
+ tablet.addValue(schemaList.get(s).getMeasurementId(), rowIndex,
"d1");
+ } else {
+ tablet.addValue(schemaList.get(s).getMeasurementId(), rowIndex,
value);
+ }
+ }
+ timestamp++;
+ }
+ try {
+ session.insertRelationalTablet(tablet);
+ } catch (Exception e) {
+ if (!e.getMessage().contains("507")) {
+ fail(e.getMessage());
+ }
+ } finally {
+ session.executeNonQueryStatement("SET CONFIGURATION
enable_auto_create_schema=false");
+ }
+ try (SessionDataSet dataSet = session.executeQueryStatement("SELECT *
FROM sg6")) {
+ assertEquals(dataSet.getColumnNames().size(), 4);
+ assertEquals(dataSet.getColumnNames().get(0), "time");
+ assertEquals(dataSet.getColumnNames().get(1), "id1");
+ assertEquals(dataSet.getColumnNames().get(2), "s1");
+ assertEquals(dataSet.getColumnNames().get(3), "s2");
+ int cnt = 0;
+ while (dataSet.hasNext()) {
+ RowRecord rowRecord = dataSet.next();
+ long time = rowRecord.getFields().get(0).getLongV();
+ assertEquals(time, rowRecord.getFields().get(2).getLongV());
+ assertEquals(time, rowRecord.getFields().get(3).getLongV());
+ cnt++;
+ }
+ Assert.assertEquals(200, cnt);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testInsertNull() {
+ String[] retArray =
+ new String[] {
+ "1,d2,null,1.0,1,", "2,d2,true,null,2,", "3,d2,true,3.0,null,",
+ };
+
+ try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+ Statement statement = connection.createStatement()) {
+ statement.execute("use \"test\"");
+ statement.execute(
+ "CREATE TABLE sg7 (id1 string id, s1 boolean measurement, s2 float
measurement, s3 int32 measurement)");
+ statement.execute("insert into sg7(id1,time,s1,s2,s3)
values('d2',1,null,1.0,1)");
+ statement.execute("insert into sg7(id1,time,s1,s2,s3)
values('d2',2,true,null,2)");
+ statement.execute("insert into sg7(id1,time,s1,s2,s3)
values('d2',3,true,3.0,null)");
+
+ try (ResultSet resultSet = statement.executeQuery("select * from sg7")) {
+ assertNotNull(resultSet);
+ ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
+ List<Integer> actualIndexToExpectedIndexList =
+ checkHeader(
+ resultSetMetaData,
+ "time,id1,s1,s2,s3",
+ new int[] {
+ Types.TIMESTAMP, Types.VARCHAR, Types.BOOLEAN, Types.FLOAT,
Types.INTEGER,
+ });
+
+ int cnt = 0;
+ while (resultSet.next()) {
+ String[] expectedStrings = retArray[cnt].split(",");
+ StringBuilder expectedBuilder = new StringBuilder();
+ StringBuilder actualBuilder = new StringBuilder();
+ for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++) {
+ if (i == 1) {
+
actualBuilder.append(resultSet.getTimestamp(i).getTime()).append(",");
+ } else {
+ actualBuilder.append(resultSet.getString(i)).append(",");
+ }
+ expectedBuilder
+ .append(expectedStrings[actualIndexToExpectedIndexList.get(i -
1)])
+ .append(",");
+ }
+ assertEquals(expectedBuilder.toString(), actualBuilder.toString());
+ cnt++;
+ }
+ assertEquals(3, cnt);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testInsertNaN() throws SQLException {
+ try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+ Statement statement = connection.createStatement()) {
+ statement.execute("use \"test\"");
+ statement.execute(
+ "CREATE TABLE sg8 (id1 string id, s1 float measurement, s2 double
measurement)");
+ // NaN should be a string literal, i.e., 'NaN', not NaN or "NaN"
+ try {
+ statement.execute("insert into sg8(id1,time,s1,s2)
values('d2',1,NaN,NaN)");
+ fail("expected exception");
+ } catch (SQLException e) {
+ assertEquals(
+ "701: Cannot insert identifier NaN, please use string literal",
e.getMessage());
+ }
+ try {
+ statement.execute("insert into sg8(id1,time,s1,s2)
values('d2',1,\"NaN\",\"NaN\")");
+ fail("expected exception");
+ } catch (SQLException e) {
+ assertEquals(
+ "701: Cannot insert identifier \"NaN\", please use string
literal", e.getMessage());
+ }
+
+ statement.execute("insert into sg8(id1,time,s1,s2)
values('d2',1,'NaN','NaN')");
+
+ try (ResultSet resultSet = statement.executeQuery("select * from sg8")) {
+ assertNotNull(resultSet);
+ int cnt = 0;
+ while (resultSet.next()) {
+ assertEquals(1, resultSet.getLong("time"));
+ assertTrue(Float.isNaN(resultSet.getFloat("s1")));
+ assertTrue(Double.isNaN(resultSet.getDouble("s2")));
+ cnt++;
+ }
+ assertEquals(1, cnt);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ @Ignore // aggregation
+ @Test
+ public void testInsertWithoutTime() {
+ try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+ Statement statement = connection.createStatement()) {
+ statement.execute("USE \"test\"");
+ statement.execute(
+ "CREATE TABLE sg9(id1 string id, s1 int64 measurement, s2 float
measurement, s3 string measurement)");
+ statement.execute("insert into sg9(id1, s1, s2, s3) values ('d1',1, 1,
'1')");
+ Thread.sleep(1);
+ statement.execute("insert into sg9(id1, s2, s1, s3) values ('d1',2, 2,
'2')");
+ Thread.sleep(1);
+ statement.execute("insert into sg9(id1, s3, s2, s1) values ('d1','3', 3,
3)");
+ Thread.sleep(1);
+ statement.execute("insert into sg9(id1, s1) values ('d1',1)");
+ statement.execute("insert into sg9(id1, s2) values ('d1',2)");
+ statement.execute("insert into sg9(id1, s3) values ('d1','3')");
+ } catch (SQLException | InterruptedException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+
+ String expectedHeader = "count(s1),count(s2),count(s3),";
+ String[] retArray = new String[] {"4,4,4,"};
+ resultSetEqualTest("select count(s1), count(s2), count(s3) from sg9",
expectedHeader, retArray);
+ }
+
+ @Test
+ public void testInsertMultiRow() {
+ assertTableNonQueryTestFail(
+ "insert into sg10(s3) values ('d1', '1'), ('d1', '2')",
+ "need timestamps when insert multi rows",
+ "test");
+ assertTableNonQueryTestFail(
+ "insert into sg10(id1, s1, s2) values ('d1', 1, 1), ('d1', 2, 2)",
+ "need timestamps when insert multi rows",
+ "test");
+ }
+
+ @Test
+ public void testInsertWithMultiTimesColumns() {
+ assertTableNonQueryTestFail(
+ "insert into sg11(id1, time, time) values ('d1', 1, 1)",
+ "One row should only have one time value",
+ "test");
+ assertTableNonQueryTestFail(
+ "insert into sg11(id1, time, s1, time) values ('d1', 1, 1, 1)",
+ "One row should only have one time value",
+ "test");
+ }
+
+ @Ignore // aggregation
+ @Test
+ public void testInsertMultiRow2() throws SQLException {
+ try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT)) {
+ Statement st0 = connection.createStatement();
+ st0.execute("use \"test\"");
+ st0.execute(
+ "create table wf12 (id1 string id, status boolean measurement,
temperature float measurement)");
+ st0.execute("insert into wf12(id1, time, status) values ('wt01', 1,
true)");
+ st0.execute(
+ "insert into wf12(id1, time, status) values ('wt01', 2, true),
('wt01', 3, false)");
+ st0.execute(
+ "insert into wf12(id1, time, status) values ('wt01', 4, true),
('wt01', 5, true), ('wt01', 6, false)");
+
+ st0.execute(
+ "insert into wf12(id1, time, temperature, status) values ('wt01', 7,
15.3, true)");
+ st0.execute(
+ "insert into wf12(id1, time, temperature, status) values ('wt01', 8,
18.3, false), ('wt01', 9, 23.1, false)");
+ st0.execute(
+ "insert into wf12(id1, time, temperature, status) values ('wt01',
10, 22.3, true), ('wt01', 11, 18.8, false), ('wt01', 12, 24.4, true)");
+ st0.close();
+
+ Statement st1 = connection.createStatement();
+ ResultSet rs1 = st1.executeQuery("select count(status) from wf12");
+ rs1.next();
+ long countStatus = rs1.getLong(1);
+ assertEquals(countStatus, 12L);
+
+ ResultSet rs2 = st1.executeQuery("select count(temperature) from wf12");
+ rs2.next();
+ long countTemperature = rs2.getLong(1);
+ assertEquals(countTemperature, 6L);
+
+ st1.close();
+ }
+ }
+
+ @Test
+ public void testInsertMultiRowWithMisMatchDataType() throws SQLException {
+ try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT)) {
+ try {
+ Statement st1 = connection.createStatement();
+ st1.execute("use \"test\"");
+ st1.execute(
+ "create table wf13 (id1 string id, status boolean measurement,
temperature float measurement)");
+ st1.execute(
+ "insert into wf13(id1, time, status) values('wt01', 1, 1.0),
('wt01', 2, 'hello')");
+ fail();
+ } catch (SQLException e) {
+ assertTrue(
+
e.getMessage().contains(Integer.toString(TSStatusCode.METADATA_ERROR.getStatusCode())));
+ }
+ }
+ }
+
+ @Test
+ public void testInsertMultiRowWithNull() throws SQLException {
+ try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+ Statement st1 = connection.createStatement()) {
+ st1.execute("use \"test\"");
+ st1.execute(
+ "create table wf14 (id1 string id, status boolean measurement,
temperature float measurement)");
+ st1.execute("insert into wt14(time, s1, s2) values(100, null, 1), (101,
null, 2)");
+ fail();
+ } catch (SQLException e) {
+ assertTrue(
+
e.getMessage().contains(Integer.toString(TSStatusCode.METADATA_ERROR.getStatusCode())));
+ }
+ try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT)) {
+ try (Statement st2 = connection.createStatement()) {
+ st2.execute("use \"test\"");
+ st2.execute(
+ "CREATE TABLE wf15 (wt string id, s1 double measurement, s2 double
measurement)");
+ st2.execute(
+ "INSERT INTO wf15(wt, time, s1) VALUES ('1', 6, 10),('1',
7,12),('1', 8,14),('1', 9,160),('1', 10,null),('1', 11,58)");
+ } catch (SQLException e) {
+ fail(e.getMessage());
+ }
+ }
+ }
+
+ @Test
+ public void testInsertMultiRowWithWrongTimestampPrecision() throws
SQLException {
+ try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+ Statement st1 = connection.createStatement()) {
+ try {
+ st1.execute("use \"test\"");
+ st1.execute(
+ "insert into wf16(id1, time, status) values('wt01',
1618283005586000, true), ('wt01', 1618283005586001, false)");
+ fail();
+ } catch (SQLException e) {
+ assertTrue(e.getMessage().contains("Current system timestamp precision
is ms"));
+ }
+ }
+ }
+
+ @Test
+ public void testInsertMultiRowWithMultiTimePartition() throws Exception {
+ try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+ Statement st1 = connection.createStatement()) {
+ st1.execute("use \"test\"");
+ st1.execute("create table sg17 (id1 string id, s1 int32 measurement)");
+ st1.execute("insert into sg17(id1, time, s1) values('d1', 604800010,1)");
+ st1.execute("flush");
+ st1.execute("insert into sg17(id1, time, s1) values('d1', 604799990,1),
('d1', 604800001,1)");
+ st1.execute("flush");
+ ResultSet rs1 = st1.executeQuery("select time, s1 from sg17");
+ assertTrue(rs1.next());
+ assertEquals(604799990, rs1.getLong("time"));
+ assertTrue(rs1.next());
+ assertEquals(604800001, rs1.getLong("time"));
+ assertTrue(rs1.next());
+ assertEquals(604800010, rs1.getLong("time"));
+ assertFalse(rs1.next());
+ }
+ }
+
+ private List<Integer> checkHeader(
+ ResultSetMetaData resultSetMetaData, String expectedHeaderStrings, int[]
expectedTypes)
+ throws SQLException {
+ String[] expectedHeaders = expectedHeaderStrings.split(",");
+ Map<String, Integer> expectedHeaderToTypeIndexMap = new HashMap<>();
+ for (int i = 0; i < expectedHeaders.length; ++i) {
+ expectedHeaderToTypeIndexMap.put(expectedHeaders[i], i);
+ }
+
+ List<Integer> actualIndexToExpectedIndexList = new ArrayList<>();
+ for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++) {
+ Integer typeIndex =
expectedHeaderToTypeIndexMap.get(resultSetMetaData.getColumnName(i));
+ assertNotNull(typeIndex);
+ assertEquals(expectedTypes[typeIndex],
resultSetMetaData.getColumnType(i));
+ actualIndexToExpectedIndexList.add(typeIndex);
+ }
+ return actualIndexToExpectedIndexList;
+ }
+}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertWithoutTimeIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertWithoutTimeIT.java
deleted file mode 100644
index 32d5a312a30..00000000000
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertWithoutTimeIT.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * 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.db.it;
-
-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.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Arrays;
-import java.util.List;
-
-import static
org.apache.iotdb.db.it.utils.TestUtils.assertTableNonQueryTestFail;
-import static org.apache.iotdb.db.it.utils.TestUtils.resultSetEqualTest;
-import static org.junit.Assert.fail;
-
-@RunWith(IoTDBTestRunner.class)
-@Category({LocalStandaloneIT.class, ClusterIT.class})
-public class IoTDBInsertWithoutTimeIT {
-
- private static final List<String> sqls =
- Arrays.asList(
- "CREATE DATABASE test",
- "USE \"test\"",
- "CREATE TABLE sg1(id1 string id, s1 int64 measurement, s2 float
measurement, s3 string measurement)");
-
- @Before
- public void setUp() throws Exception {
- EnvFactory.getEnv().initClusterEnvironment();
- createTable();
- }
-
- @After
- public void tearDown() throws Exception {
- EnvFactory.getEnv().cleanClusterEnvironment();
- }
-
- private static void createTable() {
- try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
- Statement statement = connection.createStatement()) {
- for (String sql : sqls) {
- statement.execute(sql);
- }
- } catch (SQLException e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Ignore // aggregation
- @Test
- public void testInsertWithoutTime() {
- try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
- Statement statement = connection.createStatement()) {
- statement.execute("use \"test\"");
- statement.execute("insert into sg1(id1, s1, s2, s3) values ('d1',1, 1,
'1')");
- Thread.sleep(1);
- statement.execute("insert into sg1(id1, s2, s1, s3) values ('d1',2, 2,
'2')");
- Thread.sleep(1);
- statement.execute("insert into sg1(id1, s3, s2, s1) values ('d1','3', 3,
3)");
- Thread.sleep(1);
- statement.execute("insert into sg1(id1, s1) values ('d1',1)");
- statement.execute("insert into sg1(id1, s2) values ('d1',2)");
- statement.execute("insert into sg1(id1, s3) values ('d1','3')");
- } catch (SQLException | InterruptedException e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
-
- String expectedHeader = "count(s1),count(s2),count(s3),";
- String[] retArray = new String[] {"4,4,4,"};
- resultSetEqualTest("select count(s1), count(s2), count(s3) from sg1",
expectedHeader, retArray);
- }
-
- @Test
- @Ignore // TODO: delete
- public void testInsertWithoutValueColumns() {
- assertTableNonQueryTestFail(
- "insert into sg1(id1, time) values ('d1', 1)",
- "InsertStatement should contain at least one measurement",
- "test");
- }
-
- @Test
- public void testInsertMultiRow() {
- assertTableNonQueryTestFail(
- "insert into sg1(s3) values ('d1', '1'), ('d1', '2')",
- "need timestamps when insert multi rows",
- "test");
- assertTableNonQueryTestFail(
- "insert into sg1(id1, s1, s2) values ('d1', 1, 1), ('d1', 2, 2)",
- "need timestamps when insert multi rows",
- "test");
- }
-
- @Test
- public void testInsertWithMultiTimesColumns() {
- assertTableNonQueryTestFail(
- "insert into sg1(id1, time, time) values ('d1', 1, 1)",
- "One row should only have one time value",
- "test");
- assertTableNonQueryTestFail(
- "insert into sg1(id1, time, s1, time) values ('d1', 1, 1, 1)",
- "One row should only have one time value",
- "test");
- }
-}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBMultiDeviceIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBMultiDeviceTableIT.java
similarity index 95%
rename from
integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBMultiDeviceIT.java
rename to
integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBMultiDeviceTableIT.java
index 85b3feead33..b034a2de087 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBMultiDeviceIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBMultiDeviceTableIT.java
@@ -22,11 +22,10 @@ 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.constant.TestConstant;
import org.apache.iotdb.itbase.env.BaseEnv;
-import org.junit.After;
-import org.junit.Before;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
@@ -34,10 +33,12 @@ import org.junit.runner.RunWith;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
@@ -46,10 +47,10 @@ import static org.junit.Assert.fail;
*/
@RunWith(IoTDBTestRunner.class)
@Category({LocalStandaloneIT.class, ClusterIT.class})
-public class IoTDBMultiDeviceIT {
+public class IoTDBMultiDeviceTableIT {
- @Before
- public void setUp() throws Exception {
+ @BeforeClass
+ public static void setUp() throws Exception {
// use small page
EnvFactory.getEnv()
.getConfig()
@@ -67,8 +68,8 @@ public class IoTDBMultiDeviceIT {
insertData();
}
- @After
- public void tearDown() throws Exception {
+ @AfterClass
+ public static void tearDown() throws Exception {
EnvFactory.getEnv().cleanClusterEnvironment();
}
@@ -76,10 +77,6 @@ public class IoTDBMultiDeviceIT {
try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
Statement statement = connection.createStatement()) {
- for (String sql : TestConstant.createSql) {
- statement.addBatch(sql);
- }
-
statement.addBatch("CREATE DATABASE test");
statement.addBatch("USE \"test\"");
statement.addBatch(
@@ -102,7 +99,7 @@ public class IoTDBMultiDeviceIT {
statement.addBatch(sql);
sql =
String.format(
- "insert into t(id1,id2,time,s0) values('fans','d3','%s,%s)",
time, time % 4);
+ "insert into t(id1,id2,time,s0) values('fans','d3',%s,%s)",
time, time % 4);
statement.addBatch(sql);
sql =
String.format(
@@ -135,7 +132,7 @@ public class IoTDBMultiDeviceIT {
statement.addBatch(sql);
sql =
String.format(
- "insert into t(id1,id2,time,s0) values('fans','d3','%s,%s)",
time, time % 4);
+ "insert into t(id1,id2,time,s0) values('fans','d3',%s,%s)",
time, time % 4);
statement.addBatch(sql);
sql =
String.format(
@@ -168,7 +165,7 @@ public class IoTDBMultiDeviceIT {
statement.addBatch(sql);
sql =
String.format(
- "insert into t(id1,id2,time,s0) values('fans','d3','%s,%s)",
time, time % 4);
+ "insert into t(id1,id2,time,s0) values('fans','d3',%s,%s)",
time, time % 4);
statement.addBatch(sql);
sql =
String.format(
@@ -203,7 +200,7 @@ public class IoTDBMultiDeviceIT {
statement.addBatch(sql);
sql =
String.format(
- "insert into t(id1,id2,time,s0) values('fans','d3','%s,%s)",
time, time % 4);
+ "insert into t(id1,id2,time,s0) values('fans','d3',%s,%s)",
time, time % 4);
statement.addBatch(sql);
sql =
String.format(
@@ -236,7 +233,7 @@ public class IoTDBMultiDeviceIT {
statement.addBatch(sql);
sql =
String.format(
- "insert into t(id1,id2,time,s0) values('fans','d3','%s,%s)",
time, time % 4);
+ "insert into t(id1,id2,time,s0) values('fans','d3',%s,%s)",
time, time % 4);
statement.addBatch(sql);
sql =
String.format(
@@ -251,7 +248,7 @@ public class IoTDBMultiDeviceIT {
"insert into t(id1, id2,time,s0) values('car','d2',%s,%s)",
time, time % 4);
statement.addBatch(sql);
}
- statement.executeBatch();
+ assertTrue(Arrays.stream(statement.executeBatch()).allMatch(i -> i ==
200));
} catch (Exception e) {
e.printStackTrace();
@@ -285,7 +282,7 @@ public class IoTDBMultiDeviceIT {
lastTimeMap.put(id, cur);
cnt++;
}
- assertEquals(13740, cnt);
+ assertEquals(16030, cnt);
}
} catch (Exception e) {
e.printStackTrace();
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBPartialInsertionIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBPartialInsertionIT.java
deleted file mode 100644
index 8a02a2bf558..00000000000
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBPartialInsertionIT.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * 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.db.it;
-
-import org.apache.iotdb.isession.ISession;
-import org.apache.iotdb.isession.SessionDataSet;
-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.apache.tsfile.enums.TSDataType;
-import org.apache.tsfile.read.common.RowRecord;
-import org.apache.tsfile.write.record.Tablet;
-import org.apache.tsfile.write.schema.IMeasurementSchema;
-import org.apache.tsfile.write.schema.MeasurementSchema;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-@RunWith(IoTDBTestRunner.class)
-@Category({LocalStandaloneIT.class, ClusterIT.class})
-public class IoTDBPartialInsertionIT {
- private final Logger logger =
LoggerFactory.getLogger(IoTDBPartialInsertionIT.class);
-
- @Before
- public void setUp() throws Exception {
-
EnvFactory.getEnv().getConfig().getCommonConfig().setAutoCreateSchemaEnabled(false);
- EnvFactory.getEnv().initClusterEnvironment();
- }
-
- @After
- public void tearDown() throws Exception {
- EnvFactory.getEnv().cleanClusterEnvironment();
- }
-
- @Test
- public void testPartialInsertionAllFailed() throws SQLException {
- try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
- Statement statement = connection.createStatement()) {
-
- try {
- statement.execute("CREATE DATABASE test");
- statement.execute("USE \"test\"");
- statement.execute("create table sg1 (id1 string id, s0 int32
measurement)");
- statement.execute("INSERT INTO sg1(id1, timestamp, s0) VALUES ('id',
1, 1)");
- fail();
- } catch (SQLException e) {
- assertTrue(e.getMessage().contains("Unknown column category"));
- }
- }
- }
-
- @Test
- public void testPartialInsertionRestart() throws SQLException {
- try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
- Statement statement = connection.createStatement()) {
-
- statement.execute("CREATE DATABASE test");
- statement.execute("USE \"test\"");
- statement.execute(
- "create table sg (id1 string id, s1 text measurement, s2 double
measurement)");
-
- try {
- statement.execute("INSERT INTO sg(id1,time,s1,s2) VALUES('d1',
100,'test','test')");
- } catch (SQLException e) {
- // ignore
- }
- }
-
- // TODO: replace restartDaemon() with new methods in Env.
- /*
- long time = 0;
- try {
- EnvironmentUtils.restartDaemon();
- StorageEngine.getInstance().recover();
- // wait for recover
- while (!StorageEngine.getInstance().isAllSgReady()) {
- Thread.sleep(500);
- time += 500;
- if (time > 10000) {
- logger.warn("wait too long in restart, wait for: " + time / 1000 +
"s");
- }
- }
- } catch (Exception e) {
- fail(e.getMessage());
- }
- */
-
- try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
- Statement statement = connection.createStatement()) {
- statement.execute("use \"test\"");
-
- try (ResultSet resultSet = statement.executeQuery("SELECT s1 FROM sg")) {
- assertNotNull(resultSet);
- int cnt = 0;
- while (resultSet.next()) {
- cnt++;
- assertEquals("test", resultSet.getString("s1"));
- }
- assertEquals(1, cnt);
- }
- try (ResultSet resultSet = statement.executeQuery("SELECT s2 FROM sg")) {
- assertNotNull(resultSet);
- assertFalse(resultSet.next());
- }
- }
- }
-
- @Test
- public void testPartialInsertTablet() {
- try (ISession session =
EnvFactory.getEnv().getSessionConnection(BaseEnv.TABLE_SQL_DIALECT)) {
- session.executeNonQueryStatement("create database test");
- session.executeNonQueryStatement("use \"test\"");
- session.executeNonQueryStatement(
- "create table sg1 (id1 string id, s1 int64 measurement, s2 int64
measurement)");
- List<IMeasurementSchema> schemaList = new ArrayList<>();
- schemaList.add(new MeasurementSchema("id1", TSDataType.STRING));
- schemaList.add(new MeasurementSchema("s1", TSDataType.INT64));
- schemaList.add(new MeasurementSchema("s2", TSDataType.INT64));
- schemaList.add(new MeasurementSchema("s3", TSDataType.INT64));
- final List<Tablet.ColumnType> columnTypes =
- Arrays.asList(
- Tablet.ColumnType.ID,
- Tablet.ColumnType.MEASUREMENT,
- Tablet.ColumnType.MEASUREMENT,
- Tablet.ColumnType.MEASUREMENT);
- Tablet tablet = new Tablet("sg1", schemaList, columnTypes, 300);
- long timestamp = 0;
- for (long row = 0; row < 100; row++) {
- int rowIndex = tablet.rowSize++;
- tablet.addTimestamp(rowIndex, timestamp);
- for (int s = 0; s < 4; s++) {
- long value = timestamp;
- if (s == 0) {
- tablet.addValue(schemaList.get(s).getMeasurementId(), rowIndex,
"d1");
- } else {
- tablet.addValue(schemaList.get(s).getMeasurementId(), rowIndex,
value);
- }
- }
- timestamp++;
- }
- timestamp = System.currentTimeMillis();
- for (long row = 0; row < 100; row++) {
- int rowIndex = tablet.rowSize++;
- tablet.addTimestamp(rowIndex, timestamp);
- for (int s = 0; s < 4; s++) {
- long value = timestamp;
- if (s == 0) {
- tablet.addValue(schemaList.get(s).getMeasurementId(), rowIndex,
"d1");
- } else {
- tablet.addValue(schemaList.get(s).getMeasurementId(), rowIndex,
value);
- }
- }
- timestamp++;
- }
- try {
- session.insertRelationalTablet(tablet);
- } catch (Exception e) {
- if (!e.getMessage().contains("507")) {
- fail(e.getMessage());
- }
- }
- try (SessionDataSet dataSet = session.executeQueryStatement("SELECT *
FROM sg1")) {
- assertEquals(dataSet.getColumnNames().size(), 4);
- assertEquals(dataSet.getColumnNames().get(0), "time");
- assertEquals(dataSet.getColumnNames().get(1), "id1");
- assertEquals(dataSet.getColumnNames().get(2), "s1");
- assertEquals(dataSet.getColumnNames().get(3), "s2");
- int cnt = 0;
- while (dataSet.hasNext()) {
- RowRecord rowRecord = dataSet.next();
- long time = rowRecord.getFields().get(0).getLongV();
- assertEquals(time, rowRecord.getFields().get(2).getLongV());
- assertEquals(time, rowRecord.getFields().get(3).getLongV());
- cnt++;
- }
- Assert.assertEquals(200, cnt);
- }
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBRecoverIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBRecoverTableIT.java
similarity index 99%
rename from
integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBRecoverIT.java
rename to
integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBRecoverTableIT.java
index db7688add90..fc9133ad852 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBRecoverIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBRecoverTableIT.java
@@ -51,9 +51,9 @@ import static org.junit.Assert.fail;
@RunWith(IoTDBTestRunner.class)
@Category({LocalStandaloneIT.class, ClusterIT.class})
@Ignore // aggregation
-public class IoTDBRecoverIT {
+public class IoTDBRecoverTableIT {
- private static final Logger logger =
LoggerFactory.getLogger(IoTDBRecoverIT.class);
+ private static final Logger logger =
LoggerFactory.getLogger(IoTDBRecoverTableIT.class);
private static final String TIMESTAMP_STR = "Time";
private static final String TEMPERATURE_STR = "temperature";
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBRecoverUnclosedIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBRecoverUnclosedTableIT.java
similarity index 99%
rename from
integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBRecoverUnclosedIT.java
rename to
integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBRecoverUnclosedTableIT.java
index 21b643f43d1..aa4acae1ce3 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBRecoverUnclosedIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBRecoverUnclosedTableIT.java
@@ -53,8 +53,8 @@ import static org.junit.Assert.fail;
@RunWith(IoTDBTestRunner.class)
@Category({LocalStandaloneIT.class, ClusterIT.class})
@Ignore // aggregation
-public class IoTDBRecoverUnclosedIT {
- private static final Logger logger =
LoggerFactory.getLogger(IoTDBRecoverUnclosedIT.class);
+public class IoTDBRecoverUnclosedTableIT {
+ private static final Logger logger =
LoggerFactory.getLogger(IoTDBRecoverUnclosedTableIT.class);
private static final String TIMESTAMP_STR = "time";
private static final String TEMPERATURE_STR = "temperature";
private static final String[] creationSqls =
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBRestartIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBRestartTableIT.java
similarity index 99%
rename from
integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBRestartIT.java
rename to
integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBRestartTableIT.java
index 212ae15da68..dc7b6e4608d 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBRestartIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBRestartTableIT.java
@@ -49,9 +49,9 @@ import static org.junit.Assert.fail;
@Ignore
@RunWith(IoTDBTestRunner.class)
@Category({LocalStandaloneIT.class, ClusterIT.class})
-public class IoTDBRestartIT {
+public class IoTDBRestartTableIT {
- private final Logger logger = LoggerFactory.getLogger(IoTDBRestartIT.class);
+ private final Logger logger =
LoggerFactory.getLogger(IoTDBRestartTableIT.class);
@Before
public void setUp() throws Exception {
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBSetConfigurationIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBSetConfigurationTableIT.java
similarity index 98%
rename from
integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBSetConfigurationIT.java
rename to
integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBSetConfigurationTableIT.java
index 9c323c0a5c5..0f5d10c1b88 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBSetConfigurationIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBSetConfigurationTableIT.java
@@ -42,7 +42,7 @@ import java.util.Arrays;
@RunWith(IoTDBTestRunner.class)
@Category({LocalStandaloneIT.class})
-public class IoTDBSetConfigurationIT {
+public class IoTDBSetConfigurationTableIT {
@BeforeClass
public static void setUp() throws Exception {
EnvFactory.getEnv().initClusterEnvironment();
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/aligned/IoTDBInsertAlignedValues2IT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/aligned/IoTDBInsertAlignedValues2IT.java
deleted file mode 100644
index ee9beac44c8..00000000000
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/aligned/IoTDBInsertAlignedValues2IT.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * 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.db.it.aligned;
-
-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.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-@RunWith(IoTDBTestRunner.class)
-@Category({LocalStandaloneIT.class, ClusterIT.class})
-public class IoTDBInsertAlignedValues2IT {
-
- @Before
- public void setUp() throws Exception {
- EnvFactory.getEnv()
- .getConfig()
- .getCommonConfig()
- .setAutoCreateSchemaEnabled(true)
- .setMaxNumberOfPointsInPage(2);
- EnvFactory.getEnv().initClusterEnvironment();
- }
-
- @After
- public void tearDown() throws Exception {
- EnvFactory.getEnv().cleanClusterEnvironment();
- }
-
- @Test
- public void testInsertAlignedWithEmptyPage() throws SQLException {
- try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
- Statement statement = connection.createStatement()) {
- statement.execute("create database lz");
- statement.execute("use \"lz\"");
- statement.execute(
- "create table dev (id1 string id, s1 int32 measurement, s2 int32
measurement, s3 int32 measurement)");
- for (int i = 0; i < 100; i++) {
- if (i == 99) {
- statement.addBatch(
- "insert into dev(id1,time,s1,s3) values("
- + "'GPS'"
- + ","
- + i
- + ","
- + i
- + ","
- + i
- + ")");
- } else {
- statement.addBatch(
- "insert into dev(id1, time,s1,s2) values("
- + "'GPS'"
- + ","
- + i
- + ","
- + i
- + ","
- + i
- + ")");
- }
- }
- statement.executeBatch();
-
- statement.execute("flush");
- int rowCount = 0;
- try (ResultSet resultSet = statement.executeQuery("select time, s3 from
dev")) {
- while (resultSet.next()) {
- assertEquals(99, resultSet.getInt(2));
- rowCount++;
- }
- assertEquals(1, rowCount);
- }
-
- try (ResultSet resultSet = statement.executeQuery("select time, s2 from
dev")) {
- rowCount = 0;
- while (resultSet.next()) {
- assertEquals(rowCount, resultSet.getInt(2));
- rowCount++;
- }
- assertEquals(99, rowCount);
- }
-
- try (ResultSet resultSet = statement.executeQuery("select time, s1 from
dev")) {
- rowCount = 0;
- while (resultSet.next()) {
- assertEquals(rowCount, resultSet.getInt(2));
- rowCount++;
- }
- assertEquals(100, rowCount);
- }
- }
- }
-
- @Test
- public void testInsertAlignedWithEmptyPage2() throws SQLException {
- try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
- Statement statement = connection.createStatement()) {
- statement.execute("create database test");
- statement.execute("use \"test\"");
- statement.execute(
- "create table sg (id1 string id, s1 string measurement, s2 string
measurement)");
-
- statement.execute("insert into sg(id1, time, s1, s2) values('d1',
1,'aa','bb')");
- statement.execute("insert into sg(id1, time, s1, s2) values('d1',
1,'aa','bb')");
- statement.execute("insert into sg(id1, time, s1, s2) values('d2',
1,'aa','bb')");
- statement.execute("flush");
- statement.execute("insert into sg(id1, time, s1, s2) values('d1',
1,'aa','bb')");
- }
- }
-
- @Ignore // aggregation
- @Test
- public void testInsertComplexAlignedValues() throws SQLException {
- try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
- Statement statement = connection.createStatement()) {
- statement.execute("create database test");
- statement.execute("use \"test\"");
- statement.addBatch(
- "create table sg (id1 string id, s1 int32 measurement, s2 int32
measurement)");
- statement.addBatch("insert into sg(id1, time, s1) values('id1', 3,1)");
- statement.addBatch("insert into sg(id1, time, s1) values('id1', 3,1)");
- statement.addBatch("insert into sg(id1, time, s1) values('id1', 1,1)");
- statement.addBatch("insert into sg(id1, time, s1) values('id1', 2,1)");
- statement.addBatch("insert into sg(id1, time, s2) values('id1', 2,2)");
- statement.addBatch("insert into sg(id1, time, s2) values('id1', 1,2)");
- statement.addBatch("insert into sg(id1, time, s2) values('id1', 3,2)");
- statement.addBatch("insert into sg(id1, time, s3) values('id1', 1,3)");
- statement.addBatch("insert into sg(id1, time, s3) values('id1', 3,3)");
- statement.executeBatch();
-
- try (ResultSet resultSet =
- statement.executeQuery("select count(s1), count(s2), count(s3) from
sg")) {
-
- assertTrue(resultSet.next());
- assertEquals(3, resultSet.getInt(1));
- assertEquals(3, resultSet.getInt(2));
- assertEquals(2, resultSet.getInt(3));
-
- assertFalse(resultSet.next());
- }
-
- statement.execute("flush");
- try (ResultSet resultSet =
- statement.executeQuery("select count(s1), count(s2), count(s3) from
sg")) {
-
- assertTrue(resultSet.next());
- assertEquals(3, resultSet.getInt(1));
- assertEquals(3, resultSet.getInt(2));
- assertEquals(2, resultSet.getInt(3));
-
- assertFalse(resultSet.next());
- }
- }
- }
-}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/aligned/IoTDBInsertAlignedValues3IT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/aligned/IoTDBInsertAlignedValues3IT.java
deleted file mode 100644
index e92bd6f22c8..00000000000
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/aligned/IoTDBInsertAlignedValues3IT.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * 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.db.it.aligned;
-
-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.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import static org.junit.Assert.assertEquals;
-
-@RunWith(IoTDBTestRunner.class)
-@Category({LocalStandaloneIT.class, ClusterIT.class})
-public class IoTDBInsertAlignedValues3IT {
-
- @Before
- public void setUp() throws Exception {
- EnvFactory.getEnv()
- .getConfig()
- .getCommonConfig()
- .setAutoCreateSchemaEnabled(true)
- .setMaxNumberOfPointsInPage(4);
- EnvFactory.getEnv().initClusterEnvironment();
- }
-
- @After
- public void tearDown() throws Exception {
- EnvFactory.getEnv().cleanClusterEnvironment();
- }
-
- @Test
- public void testInsertAlignedWithEmptyPage2() throws SQLException {
- try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
- Statement statement = connection.createStatement()) {
- statement.execute("create database lz");
- statement.execute("use \"lz\"");
- statement.execute(
- "create table dev (id1 string id, s1 int32 measurement, s2 int32
measurement, s3 int32 measurement)");
- for (int i = 0; i < 100; i++) {
- if (i >= 49) {
- statement.addBatch(
- "insert into dev(id1,time,s1,s2,s3) values("
- + "\'GPS\'"
- + ","
- + i
- + ","
- + i
- + ","
- + i
- + ","
- + i
- + ")");
- } else {
- statement.addBatch(
- "insert into dev(id1,time,s1,s2) values("
- + "\'GPS\'"
- + ","
- + i
- + ","
- + i
- + ","
- + i
- + ")");
- }
- }
- statement.executeBatch();
- statement.execute("flush");
- int rowCount = 0;
- try (ResultSet resultSet = statement.executeQuery("select s3 from dev"))
{
- while (resultSet.next()) {
- assertEquals(rowCount + 49, resultSet.getInt(1));
- rowCount++;
- }
- assertEquals(51, rowCount);
- }
-
- try (ResultSet resultSet = statement.executeQuery("select s2 from dev"))
{
- rowCount = 0;
- while (resultSet.next()) {
- assertEquals(rowCount, resultSet.getInt(1));
- rowCount++;
- }
- assertEquals(100, rowCount);
- }
-
- try (ResultSet resultSet = statement.executeQuery("select s1 from dev"))
{
- rowCount = 0;
- while (resultSet.next()) {
- assertEquals(rowCount, resultSet.getInt(1));
- rowCount++;
- }
- assertEquals(100, rowCount);
- }
- }
- }
-}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/aligned/IoTDBInsertAlignedValues4IT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/aligned/IoTDBInsertAlignedValues4IT.java
deleted file mode 100644
index aa6b4e2c569..00000000000
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/aligned/IoTDBInsertAlignedValues4IT.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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.db.it.aligned;
-
-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.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import static org.junit.Assert.fail;
-
-@RunWith(IoTDBTestRunner.class)
-@Category({LocalStandaloneIT.class, ClusterIT.class})
-public class IoTDBInsertAlignedValues4IT {
-
- @Before
- public void setUp() throws Exception {
- EnvFactory.getEnv()
- .getConfig()
- .getCommonConfig()
- .setAutoCreateSchemaEnabled(true)
- .setPrimitiveArraySize(2);
- EnvFactory.getEnv().initClusterEnvironment();
- }
-
- @After
- public void tearDown() throws Exception {
- EnvFactory.getEnv().cleanClusterEnvironment();
- }
-
- @Test
- public void testExtendTextColumn() {
-
- try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
- Statement statement = connection.createStatement()) {
- statement.execute("create database test");
- statement.execute("use \"test\"");
- statement.execute(
- "create table sg (id1 string id, s1 string measurement, s2 string
measurement)");
- statement.execute("insert into sg(id1,time,s1,s2)
values('d1',1,'test','test')");
- statement.execute("insert into sg(id1,time,s1,s2)
values('d1',2,'test','test')");
- statement.execute("insert into sg(id1,time,s1,s2)
values('d1',3,'test','test')");
- statement.execute("insert into sg(id1,time,s1,s2)
values('d1',4,'test','test')");
- statement.execute("insert into sg(id1,time,s1,s3)
values('d1',5,'test','test')");
- statement.execute("insert into sg(id1,time,s1,s2)
values('d1',6,'test','test')");
- statement.execute("flush");
- statement.execute("insert into sg(id1,time,s1,s3)
values('d1',7,'test','test')");
- fail();
- } catch (SQLException ignored) {
- }
- }
-}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/query/IoTDBQueryDemoTableIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/query/IoTDBQueryDemoTableIT.java
index 14488c140bf..f9269ed24ee 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/query/IoTDBQueryDemoTableIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/query/IoTDBQueryDemoTableIT.java
@@ -56,7 +56,6 @@ public class IoTDBQueryDemoTableIT {
"CREATE DATABASE " + DATABASE_NAME,
"USE " + DATABASE_NAME,
"CREATE TABLE wf(device STRING ID, status BOOLEAN MEASUREMENT,
temperature FLOAT MEASUREMENT, hardware TEXT MEASUREMENT)",
- "create timeseries wf.status with datatype=BOOLEAN,encoding=PLAIN",
"insert into wf(time,device,status) values(1509465600000,'wt01',true)",
"insert into wf(time,device,status) values(1509465660000,'wt01',true)",
"insert into wf(time,device,status)
values(1509465720000,'wt01',false)",
@@ -73,10 +72,10 @@ public class IoTDBQueryDemoTableIT {
"insert into wf(time,device,temperature)
values(1509465780000,'wt01',20.182663)",
"insert into wf(time,device,temperature)
values(1509465840000,'wt01',21.125198)",
"insert into wf(time,device,temperature)
values(1509465900000,'wt01',22.720892)",
- "insert into wf(time,device,temperature)
values(1509465960000,'wt01',20.71);",
- "insert into wf(time,device,temperature)
values(1509466020000,'wt01',21.451046);",
- "insert into wf(time,device,temperature)
values(1509466080000,'wt01',22.57987);",
- "insert into wf(time,device,temperature)
values(1509466140000,'wt01',20.98177);",
+ "insert into wf(time,device,temperature)
values(1509465960000,'wt01',20.71)",
+ "insert into wf(time,device,temperature)
values(1509466020000,'wt01',21.451046)",
+ "insert into wf(time,device,temperature)
values(1509466080000,'wt01',22.57987)",
+ "insert into wf(time,device,temperature)
values(1509466140000,'wt01',20.98177)",
"insert into wf(time,device,hardware)
values(1509465600000,'wt02','v2')",
"insert into wf(time,device,hardware)
values(1509465660000,'wt02','v2')",
"insert into wf(time,device,hardware)
values(1509465720000,'wt02','v1')",
@@ -137,7 +136,7 @@ public class IoTDBQueryDemoTableIT {
new String[] {
defaultFormatDataTime(1509466140000L) + ",wt03,false,20.98177,null,",
defaultFormatDataTime(1509466140000L) + ",wt02,false,null,v1,",
- defaultFormatDataTime(1509466140000L) + ",wt01,false,null,null,"
+ defaultFormatDataTime(1509466140000L) + ",wt01,false,20.98177,null,"
};
try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
@@ -180,7 +179,7 @@ public class IoTDBQueryDemoTableIT {
String[] retArray =
new String[] {
defaultFormatDataTime(1509466140000L) + ",wt02,false,null,v1,",
- defaultFormatDataTime(1509466140000L) + ",wt01,false,null,null,"
+ defaultFormatDataTime(1509466140000L) + ",wt01,false,20.98177,null,"
};
try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java
index fc0706cef62..e4a78f3a8f8 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java
@@ -1706,9 +1706,7 @@ public class ClientRPCServiceImpl implements
IClientRPCServiceWithHandler {
TSStatus status =
onQueryException(
e, "\"" + statement + "\". " +
OperationType.EXECUTE_BATCH_STATEMENT);
- if (status.getCode() !=
TSStatusCode.INTERNAL_SERVER_ERROR.getStatusCode()) {
- isAllSuccessful = false;
- }
+ isAllSuccessful = false;
results.add(status);
} finally {
addStatementExecutionLatency(
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/util/AstUtil.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/util/AstUtil.java
index 666ee1437c1..c9854ea52b6 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/util/AstUtil.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/util/AstUtil.java
@@ -21,6 +21,7 @@ package
org.apache.iotdb.db.queryengine.plan.relational.sql.util;
import org.apache.iotdb.db.exception.sql.SemanticException;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Expression;
+import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Identifier;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Literal;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Node;
@@ -102,6 +103,10 @@ public final class AstUtil {
if (expression instanceof Literal) {
return ((Literal) expression).getTsValue();
}
+ if (expression instanceof Identifier) {
+ throw new SemanticException(
+ String.format("Cannot insert identifier %s, please use string
literal", expression));
+ }
throw new SemanticException("Unsupported expression: " + expression);
}
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/crud/InsertRowStatement.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/crud/InsertRowStatement.java
index 592afa2cbee..bec3192c0a1 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/crud/InsertRowStatement.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/crud/InsertRowStatement.java
@@ -231,7 +231,8 @@ public class InsertRowStatement extends InsertBaseStatement
implements ISchemaVa
dataTypes[i] = measurementSchemas[i].getType();
try {
// if the type is binary and the value is already binary, do not
convert
- if (values[i] != null && !(dataTypes[i].isBinary() && values[i]
instanceof Binary)) {
+ if (values[i] instanceof String
+ || values[i] != null && !(dataTypes[i].isBinary() && values[i]
instanceof Binary)) {
values[i] = CommonUtils.parseValue(dataTypes[i],
values[i].toString(), zoneId);
}
} catch (Exception e) {