This is an automated email from the ASF dual-hosted git repository.
haonan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new c63a940a74c remove connector it (#12471)
c63a940a74c is described below
commit c63a940a74ca338d013d4d1fd027fd794bf47814
Author: CritasWang <[email protected]>
AuthorDate: Mon May 6 17:08:29 2024 +0800
remove connector it (#12471)
---
integration-test/pom.xml | 61 +---
.../org/apache/iotdb/flink/it/AbstractTest.java | 46 ---
.../java/org/apache/iotdb/flink/it/SinkTest.java | 163 ---------
.../java/org/apache/iotdb/flink/it/SourceTest.java | 192 ----------
.../test/java/org/apache/iotdb/flink/it/Utils.java | 94 -----
.../org/apache/iotdb/spark/it/AbstractTest.java | 55 ---
.../java/org/apache/iotdb/spark/it/ReadTest.java | 145 --------
.../test/java/org/apache/iotdb/spark/it/Utils.java | 95 -----
.../java/org/apache/iotdb/spark/it/WriteTest.java | 116 ------
.../iotdb/zeppelin/it/IoTDBInterpreterIT.java | 390 ---------------------
10 files changed, 6 insertions(+), 1351 deletions(-)
diff --git a/integration-test/pom.xml b/integration-test/pom.xml
index 79bd8aeefc4..e2dd5c6425b 100644
--- a/integration-test/pom.xml
+++ b/integration-test/pom.xml
@@ -163,21 +163,11 @@
<artifactId>iotdb-confignode</artifactId>
<version>1.3.2-SNAPSHOT</version>
</dependency>
- <dependency>
- <groupId>org.apache.iotdb</groupId>
- <artifactId>zeppelin-iotdb</artifactId>
- <version>1.3.2-SNAPSHOT</version>
- </dependency>
<dependency>
<groupId>org.apache.iotdb</groupId>
<artifactId>iotdb-thrift</artifactId>
<version>1.3.2-SNAPSHOT</version>
</dependency>
- <dependency>
- <groupId>org.apache.iotdb</groupId>
- <artifactId>spark-iotdb-connector_2.12</artifactId>
- <version>1.3.2-SNAPSHOT</version>
- </dependency>
<dependency>
<groupId>org.apache.iotdb</groupId>
<artifactId>iotdb-cli</artifactId>
@@ -187,16 +177,6 @@
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.iotdb</groupId>
- <artifactId>flink-sql-iotdb-connector</artifactId>
- <version>1.3.2-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.spark</groupId>
- <artifactId>spark-sql-api_2.12</artifactId>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
@@ -207,6 +187,12 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <version>5.10.2</version>
+ <artifactId>junit-jupiter-api</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
@@ -224,41 +210,6 @@
<artifactId>jcip-annotations</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.zeppelin</groupId>
- <artifactId>zeppelin-interpreter</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.spark</groupId>
- <artifactId>spark-core_2.12</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.spark</groupId>
- <artifactId>spark-sql_2.12</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-table-api-java</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-table-common</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-table-test-utils</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
<plugins>
diff --git
a/integration-test/src/test/java/org/apache/iotdb/flink/it/AbstractTest.java
b/integration-test/src/test/java/org/apache/iotdb/flink/it/AbstractTest.java
deleted file mode 100644
index 5b4112c172e..00000000000
--- a/integration-test/src/test/java/org/apache/iotdb/flink/it/AbstractTest.java
+++ /dev/null
@@ -1,46 +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.flink.it;
-
-import org.apache.iotdb.it.env.EnvFactory;
-import org.apache.iotdb.rpc.IoTDBConnectionException;
-import org.apache.iotdb.rpc.StatementExecutionException;
-
-import org.apache.flink.table.api.EnvironmentSettings;
-import org.apache.flink.table.api.TableEnvironment;
-
-public class AbstractTest {
- TableEnvironment tableEnv;
-
- protected String ip;
- protected int port;
-
- public void before() {
- EnvFactory.getEnv().initClusterEnvironment();
- ip = EnvFactory.getEnv().getIP();
- port = Integer.valueOf(EnvFactory.getEnv().getPort());
-
- EnvironmentSettings settings =
EnvironmentSettings.newInstance().inStreamingMode().build();
- tableEnv = TableEnvironment.create(settings);
- }
-
- public void after() throws IoTDBConnectionException,
StatementExecutionException {
- EnvFactory.getEnv().cleanClusterEnvironment();
- }
-}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/flink/it/SinkTest.java
b/integration-test/src/test/java/org/apache/iotdb/flink/it/SinkTest.java
deleted file mode 100644
index a9b16e70f65..00000000000
--- a/integration-test/src/test/java/org/apache/iotdb/flink/it/SinkTest.java
+++ /dev/null
@@ -1,163 +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.flink.it;
-
-import org.apache.iotdb.isession.SessionDataSet;
-import org.apache.iotdb.rpc.IoTDBConnectionException;
-import org.apache.iotdb.rpc.StatementExecutionException;
-import org.apache.iotdb.session.Session;
-
-import org.apache.flink.table.api.DataTypes;
-import org.apache.flink.table.api.Schema;
-import org.apache.flink.table.api.Table;
-import org.apache.flink.table.api.TableDescriptor;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-public class SinkTest extends AbstractTest {
- @Before
- @Override
- public void before() {
- super.before();
- }
-
- @Test
- public void testStreamingSink() {
- Schema dataGenTableSchema =
- Schema.newBuilder()
- .column("Time_", DataTypes.BIGINT())
- .column("root.sg.d0.s0", DataTypes.FLOAT())
- .column("root.sg.d0.s1", DataTypes.FLOAT())
- .column("root.sg.d0.s2", DataTypes.FLOAT())
- .column("root.sg.d0.s3", DataTypes.FLOAT())
- .column("root.sg.d0.s4", DataTypes.FLOAT())
- .column("root.sg.d0.s5", DataTypes.FLOAT())
- .build();
- TableDescriptor descriptor =
- TableDescriptor.forConnector("datagen")
- .schema(dataGenTableSchema)
- .option("rows-per-second", "1")
- .option("fields.Time_.kind", "sequence")
- .option("fields.Time_.start", "1")
- .option("fields.Time_.end", "5")
- .option("fields.root.sg.d0.s0.min", "1")
- .option("fields.root.sg.d0.s0.max", "5")
- .option("fields.root.sg.d0.s1.min", "1")
- .option("fields.root.sg.d0.s1.max", "5")
- .option("fields.root.sg.d0.s2.min", "1")
- .option("fields.root.sg.d0.s2.max", "5")
- .option("fields.root.sg.d0.s3.min", "1")
- .option("fields.root.sg.d0.s3.max", "5")
- .option("fields.root.sg.d0.s4.min", "1")
- .option("fields.root.sg.d0.s4.max", "5")
- .option("fields.root.sg.d0.s5.min", "1")
- .option("fields.root.sg.d0.s5.max", "5")
- .build();
- tableEnv.createTemporaryTable("dataGenTable", descriptor);
- Table dataGenTable = tableEnv.from("dataGenTable");
-
- // create iotdb sink table
- TableDescriptor iotdbDescriptor =
- TableDescriptor.forConnector("IoTDB")
- .schema(dataGenTableSchema)
- .option("nodeUrls", String.format("%s:%d", ip, port))
- .build();
- tableEnv.createTemporaryTable("iotdbSinkTable", iotdbDescriptor);
- // insert data
- dataGenTable.executeInsert("iotdbSinkTable").print();
- }
-
- @Test
- public void testBatchSink() throws IoTDBConnectionException,
StatementExecutionException {
- Utils.prepareData("root.sg.d0", ip, port);
- // schema
- Schema iotdbTableSchema =
- Schema.newBuilder()
- .column("Time_", DataTypes.BIGINT())
- .column("root.sg.d0.s0", DataTypes.INT())
- .column("root.sg.d0.s1", DataTypes.BIGINT())
- .column("root.sg.d0.s2", DataTypes.FLOAT())
- .column("root.sg.d0.s3", DataTypes.DOUBLE())
- .column("root.sg.d0.s4", DataTypes.BOOLEAN())
- .column("root.sg.d0.s5", DataTypes.STRING())
- .build();
-
- // source table
- TableDescriptor sourceDescriptor =
- TableDescriptor.forConnector("IoTDB")
- .schema(iotdbTableSchema)
- .option("nodeUrls", String.format("%s:%d", ip, port))
- .option("sql", "select * from root.sg.d0")
- .build();
- tableEnv.createTemporaryTable("sourceTable", sourceDescriptor);
- Table sourceTable = tableEnv.from("sourceTable");
-
- // sink table
- TableDescriptor sinkDescriptor =
- TableDescriptor.forConnector("IoTDB")
- .schema(iotdbTableSchema)
- .option("nodeUrls", String.format("%s:%d", ip, port))
- .build();
- tableEnv.createTemporaryTable("sinkTable", sinkDescriptor);
-
- // insert data
- sourceTable.executeInsert("sinkTable").print();
-
- // read data from iotdb
- Session session = new Session.Builder().host(ip).port(port).build();
- session.open(false);
-
- SessionDataSet dataSet =
- session.executeQueryStatement("select s0,s1,s2,s3,s4,s5 from
root.sg.d0");
- Object[] columnNames = dataSet.getColumnNames().toArray();
- Object[] columnTypes = dataSet.getColumnTypes().toArray();
- int rowSize = 0;
- while (dataSet.hasNext()) {
- dataSet.next();
- rowSize++;
- }
-
- Object[] exceptedColumnNames = {
- "Time",
- "root.sg.d0.s0",
- "root.sg.d0.s1",
- "root.sg.d0.s2",
- "root.sg.d0.s3",
- "root.sg.d0.s4",
- "root.sg.d0.s5"
- };
- Object[] exceptedColumnTypes = {
- "INT64", "INT32", "INT64", "FLOAT", "DOUBLE", "BOOLEAN", "TEXT"
- };
- int exceptedRowSize = 1000;
-
- Assert.assertEquals(exceptedColumnNames, columnNames);
- Assert.assertEquals(exceptedColumnTypes, columnTypes);
- Assert.assertEquals(exceptedRowSize, rowSize);
- session.close();
- }
-
- @After
- @Override
- public void after() throws IoTDBConnectionException,
StatementExecutionException {
- super.after();
- }
-}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/flink/it/SourceTest.java
b/integration-test/src/test/java/org/apache/iotdb/flink/it/SourceTest.java
deleted file mode 100644
index 79b6b3cf6cc..00000000000
--- a/integration-test/src/test/java/org/apache/iotdb/flink/it/SourceTest.java
+++ /dev/null
@@ -1,192 +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.flink.it;
-
-import org.apache.iotdb.rpc.IoTDBConnectionException;
-import org.apache.iotdb.rpc.StatementExecutionException;
-
-import org.apache.flink.table.api.DataTypes;
-import org.apache.flink.table.api.Schema;
-import org.apache.flink.table.api.Table;
-import org.apache.flink.table.api.TableDescriptor;
-import org.apache.flink.table.api.TableResult;
-import org.apache.flink.table.api.TableSchema;
-import org.apache.flink.table.types.DataType;
-import org.apache.flink.types.Row;
-import org.apache.flink.util.CloseableIterator;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-public class SourceTest extends AbstractTest {
- @Before
- public void before() {
- super.before();
- }
-
- @Test
- public void boundedScanTest() throws IoTDBConnectionException,
StatementExecutionException {
- Utils.prepareData("root.test.flink.scan", ip, port);
-
- Schema iotdbTableSchema =
- Schema.newBuilder()
- .column("Time_", DataTypes.BIGINT())
- .column("root.test.flink.scan.s0", DataTypes.INT())
- .column("root.test.flink.scan.s1", DataTypes.BIGINT())
- .column("root.test.flink.scan.s2", DataTypes.FLOAT())
- .column("root.test.flink.scan.s3", DataTypes.DOUBLE())
- .column("root.test.flink.scan.s4", DataTypes.BOOLEAN())
- .column("root.test.flink.scan.s5", DataTypes.STRING())
- .build();
-
- TableDescriptor iotdbDescriptor =
- TableDescriptor.forConnector("IoTDB")
- .schema(iotdbTableSchema)
- .option("nodeUrls", String.format("%s:%d", ip, port))
- .option("sql", "select * from root.test.flink.scan")
- .build();
- tableEnv.createTemporaryTable("iotdbTable", iotdbDescriptor);
-
- Table iotdbTable = tableEnv.from("iotdbTable");
-
- TableSchema schema = iotdbTable.getSchema();
- String[] fieldNames = schema.getFieldNames();
- DataType[] fieldDataTypes = schema.getFieldDataTypes();
- CloseableIterator<Row> collect = iotdbTable.execute().collect();
- int rowSize = 0;
- while (collect.hasNext()) {
- collect.next();
- rowSize++;
- }
-
- final String[] exceptedFiledNames = {
- "Time_",
- "root.test.flink.scan.s0",
- "root.test.flink.scan.s1",
- "root.test.flink.scan.s2",
- "root.test.flink.scan.s3",
- "root.test.flink.scan.s4",
- "root.test.flink.scan.s5"
- };
- final DataType[] exceptedFieldDataTypes = {
- DataTypes.BIGINT(),
- DataTypes.INT(),
- DataTypes.BIGINT(),
- DataTypes.FLOAT(),
- DataTypes.DOUBLE(),
- DataTypes.BOOLEAN(),
- DataTypes.STRING()
- };
- final int exceptedRowSize = 1000;
-
- Assert.assertEquals(exceptedFiledNames, fieldNames);
- Assert.assertEquals(exceptedFieldDataTypes, fieldDataTypes);
- Assert.assertEquals(exceptedRowSize, rowSize);
- }
-
- @Test
- public void lookupTest() throws IoTDBConnectionException,
StatementExecutionException {
- Utils.prepareData("root.test.flink.lookup", ip, port);
-
- Schema dataGenTableSchema =
- Schema.newBuilder()
- .column("Time_", DataTypes.BIGINT())
- .column("s6", DataTypes.INT())
- .build();
-
- TableDescriptor datagenDescriptor =
- TableDescriptor.forConnector("datagen")
- .schema(dataGenTableSchema)
- .option("fields.Time_.kind", "sequence")
- .option("fields.Time_.start", "1")
- .option("fields.Time_.end", "100")
- .option("fields.s6.min", "1")
- .option("fields.s6.max", "1")
- .build();
- tableEnv.createTemporaryTable("leftTable", datagenDescriptor);
-
- Schema iotdbTableSchema =
- Schema.newBuilder()
- .column("Time_", DataTypes.BIGINT())
- .column("root.test.flink.lookup.s0", DataTypes.INT())
- .column("root.test.flink.lookup.s1", DataTypes.BIGINT())
- .column("root.test.flink.lookup.s2", DataTypes.FLOAT())
- .column("root.test.flink.lookup.s3", DataTypes.DOUBLE())
- .column("root.test.flink.lookup.s4", DataTypes.BOOLEAN())
- .column("root.test.flink.lookup.s5", DataTypes.STRING())
- .build();
-
- TableDescriptor iotdbDescriptor =
- TableDescriptor.forConnector("IoTDB")
- .schema(iotdbTableSchema)
- .option("nodeUrls", String.format("%s:%d", ip, port))
- .option("sql", "select * from root.test.flink.lookup")
- .build();
- tableEnv.createTemporaryTable("rightTable", iotdbDescriptor);
-
- String sql =
- "SELECT l.Time_, r.`root.test.flink.lookup.s0`,
r.`root.test.flink.lookup.s1`, r.`root.test.flink.lookup.s2`,
r.`root.test.flink.lookup.s3`, r.`root.test.flink.lookup.s4`,
r.`root.test.flink.lookup.s5`, l.s6 "
- + "FROM (select *,PROCTIME() as proc_time from leftTable) AS l "
- + "JOIN rightTable FOR SYSTEM_TIME AS OF l.proc_time AS r "
- + "ON l.Time_ = r.Time_";
-
- TableResult result = tableEnv.sqlQuery(sql).execute();
- TableSchema schema = result.getTableSchema();
- String[] fieldNames = schema.getFieldNames();
- DataType[] fieldDataTypes = schema.getFieldDataTypes();
- CloseableIterator<Row> collect = result.collect();
- int rowSize = 0;
- while (collect.hasNext()) {
- collect.next();
- rowSize++;
- }
-
- final String[] exceptedFiledNames = {
- "Time_",
- "root.test.flink.lookup.s0",
- "root.test.flink.lookup.s1",
- "root.test.flink.lookup.s2",
- "root.test.flink.lookup.s3",
- "root.test.flink.lookup.s4",
- "root.test.flink.lookup.s5",
- "s6"
- };
- final DataType[] exceptedFieldDataTypes = {
- DataTypes.BIGINT(),
- DataTypes.INT(),
- DataTypes.BIGINT(),
- DataTypes.FLOAT(),
- DataTypes.DOUBLE(),
- DataTypes.BOOLEAN(),
- DataTypes.STRING(),
- DataTypes.INT()
- };
- final int exceptedRowSize = 100;
-
- Assert.assertEquals(exceptedFiledNames, fieldNames);
- Assert.assertEquals(exceptedFieldDataTypes, fieldDataTypes);
- Assert.assertEquals(exceptedRowSize, rowSize);
- }
-
- @After
- public void after() throws IoTDBConnectionException,
StatementExecutionException {
- super.after();
- }
-}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/flink/it/Utils.java
b/integration-test/src/test/java/org/apache/iotdb/flink/it/Utils.java
deleted file mode 100644
index 87e39b6fe66..00000000000
--- a/integration-test/src/test/java/org/apache/iotdb/flink/it/Utils.java
+++ /dev/null
@@ -1,94 +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.flink.it;
-
-import org.apache.iotdb.rpc.IoTDBConnectionException;
-import org.apache.iotdb.rpc.StatementExecutionException;
-import org.apache.iotdb.session.Session;
-
-import org.apache.tsfile.enums.TSDataType;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class Utils {
- private Utils() {}
-
- protected static void prepareData(String deviceId, String host, int port)
- throws IoTDBConnectionException, StatementExecutionException {
- Session session = new Session.Builder().host(host).port(port).build();
- session.open(false);
- List<Long> times = new ArrayList<>();
- List<List<String>> measurementsList = new ArrayList<>();
- List<List<TSDataType>> typesList = new ArrayList<>();
- List<List<Object>> valuesList = new ArrayList<>();
-
- ArrayList<String> measurements =
- new ArrayList<String>() {
- {
- for (int i = 0; i < 6; i++) {
- add(String.format("s%d", i));
- }
- }
- };
- ArrayList<TSDataType> types =
- new ArrayList<TSDataType>() {
- {
- add(TSDataType.INT32);
- add(TSDataType.INT64);
- add(TSDataType.FLOAT);
- add(TSDataType.DOUBLE);
- add(TSDataType.BOOLEAN);
- add(TSDataType.TEXT);
- }
- };
- ArrayList<Object> values =
- new ArrayList<Object>() {
- {
- add(1);
- add(1L);
- add(1F);
- add(1D);
- add(true);
- add("hello world");
- }
- };
- for (int i = 1; i <= 1000; i++) {
- times.add(Long.valueOf(i));
- measurementsList.add(measurements);
- typesList.add(types);
- valuesList.add(values);
- }
- session.insertRecordsOfOneDevice(deviceId, times, measurementsList,
typesList, valuesList);
- session.executeNonQueryStatement("flush");
- session.close();
- }
-
- public static void cleanData(String host, int port) throws
IoTDBConnectionException {
- Session session = new Session.Builder().host(host).port(port).build();
- session.open(false);
- try {
- session.executeNonQueryStatement("delete storage group root.**");
- session.executeNonQueryStatement("drop pipe flink_cdc_test");
- } catch (StatementExecutionException e) {
- // do nothing
- }
- session.close();
- }
-}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/spark/it/AbstractTest.java
b/integration-test/src/test/java/org/apache/iotdb/spark/it/AbstractTest.java
deleted file mode 100644
index df179e6cc29..00000000000
--- a/integration-test/src/test/java/org/apache/iotdb/spark/it/AbstractTest.java
+++ /dev/null
@@ -1,55 +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.spark.it;
-
-import org.apache.iotdb.it.env.EnvFactory;
-import org.apache.iotdb.rpc.IoTDBConnectionException;
-
-import org.apache.spark.sql.SparkSession;
-
-public class AbstractTest {
- protected SparkSession spark;
-
- protected static String ip;
- protected static String port;
-
- protected String jdbcUrl;
-
- public void before() throws ClassNotFoundException, IoTDBConnectionException
{
- EnvFactory.getEnv().initClusterEnvironment();
- ip = EnvFactory.getEnv().getIP();
- port = EnvFactory.getEnv().getPort();
-
- jdbcUrl = String.format("jdbc:iotdb://%s:%s/", ip, port);
-
- spark =
- SparkSession.builder()
- .config("spark.master", "local")
- .appName("spark-iotdb-connector read test")
- .getOrCreate();
- }
-
- public void after() throws IoTDBConnectionException {
- if (spark != null) {
- spark.sparkContext().stop();
- }
-
- EnvFactory.getEnv().cleanClusterEnvironment();
- }
-}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/spark/it/ReadTest.java
b/integration-test/src/test/java/org/apache/iotdb/spark/it/ReadTest.java
deleted file mode 100644
index 04fc763789b..00000000000
--- a/integration-test/src/test/java/org/apache/iotdb/spark/it/ReadTest.java
+++ /dev/null
@@ -1,145 +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.spark.it;
-
-import org.apache.iotdb.rpc.IoTDBConnectionException;
-import org.apache.iotdb.spark.db.Transformer;
-
-import org.apache.spark.sql.Dataset;
-import org.apache.spark.sql.Row;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-public class ReadTest extends AbstractTest {
-
- @Before
- @Override
- public void before() throws ClassNotFoundException, IoTDBConnectionException
{
- super.before();
- Utils.prepareData(jdbcUrl);
- }
-
- @After
- @Override
- public void after() throws IoTDBConnectionException {
- super.after();
- }
-
- @Test
- public void testShowData() {
- Dataset<Row> df =
- spark
- .read()
- .format("org.apache.iotdb.spark.db")
- .option("url", jdbcUrl)
- .option("sql", "select ** from root")
- .load();
- Assert.assertEquals(7505, df.count());
- }
-
- @Test
- public void testShowDataWithPartition() {
- Dataset<Row> df =
- spark
- .read()
- .format("org.apache.iotdb.spark.db")
- .option("url", jdbcUrl)
- .option("sql", "select ** from root")
- .option("lowerBound", 1)
- .option("upperBound", System.nanoTime() / 1000 / 1000)
- .option("numPartition", 10)
- .load();
-
- Assert.assertEquals(7505, df.count());
- }
-
- @Test
- public void testFilterData() {
- Dataset<Row> df =
- spark
- .read()
- .format("org.apache.iotdb.spark.db")
- .option("url", jdbcUrl)
- .option("sql", "select ** from root where time < 2000 and time >
1000")
- .load();
-
- Assert.assertEquals(499, df.count());
- }
-
- @Test
- public void testFilterDataWithPartition() {
- Dataset<Row> df =
- spark
- .read()
- .format("org.apache.iotdb.spark.db")
- .option("url", jdbcUrl)
- .option("sql", "select ** from root where time < 2000 and time >
1000")
- .option("lowerBound", 1)
- .option("upperBound", 10000)
- .option("numPartition", 10)
- .load();
-
- Assert.assertEquals(499, df.count());
- }
-
- @Test
- public void testTransformToNarrow() {
- Dataset<Row> df =
- spark
- .read()
- .format("org.apache.iotdb.spark.db")
- .option("url", jdbcUrl)
- .option("sql", "select ** from root where time < 1100 and time >
1000")
- .load();
-
- Dataset<Row> narrowDf = Transformer.toNarrowForm(spark, df);
- Assert.assertEquals(198, narrowDf.count());
- }
-
- @Test
- public void testTransformBackToWide() {
- Dataset<Row> df =
- spark
- .read()
- .format("org.apache.iotdb.spark.db")
- .option("url", jdbcUrl)
- .option("sql", "select ** from root where time < 1100 and time >
1000")
- .load();
- Dataset<Row> narrowDf = Transformer.toNarrowForm(spark, df);
- Dataset<Row> wideDf = Transformer.toWideForm(spark, narrowDf);
- Assert.assertEquals(99, wideDf.count());
- }
-
- @Test
- public void testAggregateSql() {
- Dataset<Row> df =
- spark
- .read()
- .format("org.apache.iotdb.spark.db")
- .option("url", jdbcUrl)
- .option("sql", "select count(d0.s0),count(d0.s1) from
root.vehicle")
- .load();
-
- Row row = df.collectAsList().get(0);
- Assert.assertEquals("7500", row.get(0).toString());
- Assert.assertEquals("7500", row.get(1).toString());
- }
-}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/spark/it/Utils.java
b/integration-test/src/test/java/org/apache/iotdb/spark/it/Utils.java
deleted file mode 100644
index 69ec5c0a5ef..00000000000
--- a/integration-test/src/test/java/org/apache/iotdb/spark/it/Utils.java
+++ /dev/null
@@ -1,95 +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.spark.it;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.Statement;
-import java.util.Locale;
-
-public class Utils {
- private static final String insertTemplate =
- "INSERT INTO root.vehicle.d0(timestamp,s0,s1,s2,s3,s4)" + "
VALUES(%d,%d,%d,%f,%s,%s)";
-
- private static String[] data =
- new String[] {
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware)
"
- + "values(1, 1.1, false, 11)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware)
"
- + "values(2, 2.2, true, 22)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware)
"
- + "values(3, 3.3, false, 33 )",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware)
"
- + "values(4, 4.4, false, 44)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware)
"
- + "values(5, 5.5, false, 55)"
- };
-
- protected static void prepareData(String jdbcUrl) throws
ClassNotFoundException {
- Class.forName("org.apache.iotdb.jdbc.IoTDBDriver");
- try (Connection connection = DriverManager.getConnection(jdbcUrl, "root",
"root");
- Statement statement = connection.createStatement()) {
-
- for (String sql : data) {
- statement.execute(sql);
- }
- // prepare BufferWrite file
- for (int i = 5000; i < 7000; i++) {
- statement.execute(
- String.format(
- Locale.ENGLISH, insertTemplate, i, i, i, (double) i, "'" + i +
"'", "true"));
- }
- statement.execute("flush");
- for (int i = 7500; i < 8500; i++) {
- statement.execute(
- String.format(
- Locale.ENGLISH, insertTemplate, i, i, i, (double) i, "'" + i +
"'", "false"));
- }
- statement.execute("flush");
- // prepare Unseq-File
- for (int i = 500; i < 1500; i++) {
- statement.execute(
- String.format(
- Locale.ENGLISH, insertTemplate, i, i, i, (double) i, "'" + i +
"'", "true"));
- }
- statement.execute("flush");
- for (int i = 3000; i < 6500; i++) {
- statement.execute(
- String.format(
- Locale.ENGLISH, insertTemplate, i, i, i, (double) i, "'" + i +
"'", "false"));
- }
-
- // prepare BufferWrite cache
- for (int i = 9000; i < 10000; i++) {
- statement.execute(
- String.format(
- Locale.ENGLISH, insertTemplate, i, i, i, (double) i, "'" + i +
"'", "true"));
- }
- // prepare Overflow cache
- for (int i = 2000; i < 2500; i++) {
- statement.execute(
- String.format(
- Locale.ENGLISH, insertTemplate, i, i, i, (double) i, "'" + i +
"'", "false"));
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/spark/it/WriteTest.java
b/integration-test/src/test/java/org/apache/iotdb/spark/it/WriteTest.java
deleted file mode 100644
index d7010465480..00000000000
--- a/integration-test/src/test/java/org/apache/iotdb/spark/it/WriteTest.java
+++ /dev/null
@@ -1,116 +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.spark.it;
-
-import org.apache.iotdb.isession.SessionDataSet;
-import org.apache.iotdb.rpc.IoTDBConnectionException;
-import org.apache.iotdb.rpc.StatementExecutionException;
-import org.apache.iotdb.session.Session;
-
-import org.apache.spark.sql.*;
-import org.apache.spark.sql.types.*;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class WriteTest extends AbstractTest {
- private Session session;
-
- @Before
- @Override
- public void before() throws IoTDBConnectionException, ClassNotFoundException
{
- super.before();
- session = new Session(ip, port, "root", "root");
- session.open();
- }
-
- @After
- @Override
- public void after() throws IoTDBConnectionException {
- session.close();
- super.after();
- }
-
- @Test
- public void testInsertWideData() throws IoTDBConnectionException,
StatementExecutionException {
- List<Row> rows = new ArrayList<>();
- rows.add(RowFactory.create(1L, 1, 1L, 1.0F, 1.0D, true, "hello"));
- rows.add(RowFactory.create(2L, 2, 2L, 2.0F, 2.0D, false, "world"));
-
- StructField[] structFields =
- new StructField[] {
- new StructField("Time", DataTypes.LongType, false, Metadata.empty()),
- new StructField("root.test.d0.s0", DataTypes.IntegerType, true,
Metadata.empty()),
- new StructField("root.test.d0.s1", DataTypes.LongType, true,
Metadata.empty()),
- new StructField("root.test.d0.s2", DataTypes.FloatType, true,
Metadata.empty()),
- new StructField("root.test.d0.s3", DataTypes.DoubleType, true,
Metadata.empty()),
- new StructField("root.test.d0.s4", DataTypes.BooleanType, true,
Metadata.empty()),
- new StructField("root.test.d0.s5", DataTypes.StringType, true,
Metadata.empty())
- };
- StructType structType = new StructType(structFields);
-
- Dataset<Row> df = spark.createDataFrame(rows, structType);
-
- df.write().format("org.apache.iotdb.spark.db").option("url",
jdbcUrl).save();
-
- SessionDataSet result = session.executeQueryStatement("select ** from
root");
- int size = 0;
- while (result.hasNext()) {
- result.next();
- size++;
- }
- Assert.assertEquals(2, size);
- }
-
- @Test
- public void testInsertNarrowData() throws IoTDBConnectionException,
StatementExecutionException {
- List<Row> rows = new ArrayList<>();
- rows.add(RowFactory.create(1L, "root.test.d0", 1, 1L, 1.0F, 1.0D, true,
"hello"));
- rows.add(RowFactory.create(2L, "root.test.d0", 2, 2L, 2.0F, 2.0D, false,
"world"));
-
- StructField[] structFields =
- new StructField[] {
- new StructField("Time", DataTypes.LongType, false, Metadata.empty()),
- new StructField("Device", DataTypes.StringType, false,
Metadata.empty()),
- new StructField("s0", DataTypes.IntegerType, true, Metadata.empty()),
- new StructField("s1", DataTypes.LongType, true, Metadata.empty()),
- new StructField("s2", DataTypes.FloatType, true, Metadata.empty()),
- new StructField("s3", DataTypes.DoubleType, true, Metadata.empty()),
- new StructField("s4", DataTypes.BooleanType, true, Metadata.empty()),
- new StructField("s5", DataTypes.StringType, true, Metadata.empty())
- };
- StructType structType = new StructType(structFields);
-
- Dataset<Row> df = spark.createDataFrame(rows, structType);
-
- df.write().format("org.apache.iotdb.spark.db").option("url",
jdbcUrl).save();
-
- SessionDataSet result = session.executeQueryStatement("select ** from
root");
- int size = 0;
- while (result.hasNext()) {
- result.next();
- size++;
- }
- Assert.assertEquals(2, size);
- }
-}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/zeppelin/it/IoTDBInterpreterIT.java
b/integration-test/src/test/java/org/apache/iotdb/zeppelin/it/IoTDBInterpreterIT.java
deleted file mode 100644
index 0888da9391e..00000000000
---
a/integration-test/src/test/java/org/apache/iotdb/zeppelin/it/IoTDBInterpreterIT.java
+++ /dev/null
@@ -1,390 +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.zeppelin.it;
-
-import org.apache.iotdb.it.env.EnvFactory;
-import org.apache.iotdb.it.framework.IoTDBTestRunner;
-import org.apache.iotdb.itbase.category.LocalStandaloneIT;
-
-import org.apache.zeppelin.interpreter.InterpreterResult;
-import org.apache.zeppelin.interpreter.InterpreterResult.Code;
-import org.apache.zeppelin.iotdb.IoTDBInterpreter;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-
-import java.io.IOException;
-import java.util.Locale;
-import java.util.Properties;
-
-@RunWith(IoTDBTestRunner.class)
-@Category({LocalStandaloneIT.class})
-public class IoTDBInterpreterIT {
-
- private static IoTDBInterpreter interpreter;
-
- static final String IOTDB_HOST = "iotdb.host";
- static final String IOTDB_PORT = "iotdb.port";
- static final String IOTDB_USERNAME = "iotdb.username";
- static final String IOTDB_PASSWORD = "iotdb.password";
- static final String IOTDB_FETCH_SIZE = "iotdb.fetchSize";
- static final String IOTDB_ZONE_ID = "iotdb.zoneId";
- static final String IOTDB_ENABLE_RPC_COMPRESSION =
"iotdb.enable.rpc.compression";
- static final String IOTDB_TIME_DISPLAY_TYPE = "iotdb.time.display.type";
-
- static final String SET_TIMESTAMP_DISPLAY = "set time_display_type";
-
- @BeforeClass
- public static void open() {
- EnvFactory.getEnv().initClusterEnvironment();
- Properties properties = new Properties();
- properties.put(IOTDB_HOST, EnvFactory.getEnv().getIP());
- properties.put(IOTDB_PORT, EnvFactory.getEnv().getPort());
- properties.put(IOTDB_USERNAME, "root");
- properties.put(IOTDB_PASSWORD, "root");
- properties.put(IOTDB_FETCH_SIZE, "10000");
- properties.put(IOTDB_ZONE_ID, "UTC");
- properties.put(IOTDB_ENABLE_RPC_COMPRESSION, "false");
- properties.put(IOTDB_TIME_DISPLAY_TYPE, "long");
- interpreter = new IoTDBInterpreter(properties);
- interpreter.open();
- initInsert();
- }
-
- private static void initInsert() {
- interpreter.internalInterpret("CREATE DATABASE root.test.wf01", null);
- interpreter.internalInterpret(
- "INSERT INTO root.test.wf01.wt01 (timestamp, temperature, status,
hardware) VALUES (1, 1.1, false, 11)",
- null);
- interpreter.internalInterpret(
- "INSERT INTO root.test.wf01.wt01 (timestamp, temperature, status,
hardware) VALUES (2, 2.2, true, 22)",
- null);
- interpreter.internalInterpret(
- "INSERT INTO root.test.wf01.wt01 (timestamp, temperature, status,
hardware) VALUES (3, 3.3, false, 33)",
- null);
- interpreter.internalInterpret(
- "INSERT INTO root.test.wf01.wt01 (timestamp, temperature, status,
hardware) VALUES (4, 4.4, false, 44)",
- null);
- interpreter.internalInterpret(
- "INSERT INTO root.test.wf01.wt01 (timestamp, temperature, status,
hardware) VALUES (5, 5.5, false, 55)",
- null);
-
- interpreter.internalInterpret("CREATE DATABASE root.test.wf02", null);
- interpreter.internalInterpret(
- "INSERT INTO root.test.wf02.wt02 (timestamp, temperature, status,
hardware) VALUES (44, 4.4, false, 44)",
- null);
- interpreter.internalInterpret(
- "INSERT INTO root.test.wf02.wt02 (timestamp, temperature, status,
hardware) VALUES (54, 5.5, false, 55)",
- null);
- }
-
- @AfterClass
- public static void close() throws IOException {
- interpreter.close();
- EnvFactory.getEnv().cleanClusterEnvironment();
- }
-
- @Test
- public void testNonQuery() {
- for (int i = 0; i < 100; i++) {
- String script =
- String.format(
- Locale.ENGLISH,
- "INSERT INTO root.test.wf02(timestamp,temperature)
VALUES(%d,%f)",
- i,
- Math.random() * 10);
- InterpreterResult actual = interpreter.internalInterpret(script, null);
- Assert.assertNotNull(actual);
- Assert.assertEquals(Code.SUCCESS, actual.code());
- Assert.assertEquals("Sql executed.", actual.message().get(0).getData());
- }
- }
-
- @Test
- public void testSelectColumnStatement() {
- InterpreterResult actual =
- interpreter.internalInterpret("select status from
root.test.wf01.wt01", null);
- String gt =
- "Time\troot.test.wf01.wt01.status\n"
- + "1\tfalse\n"
- + "2\ttrue\n"
- + "3\tfalse\n"
- + "4\tfalse\n"
- + "5\tfalse";
- Assert.assertNotNull(actual);
- Assert.assertEquals(Code.SUCCESS, actual.code());
- Assert.assertEquals(gt, actual.message().get(0).getData());
- }
-
- @Test
- public void testSetTimeDisplay() {
- String longGT =
- "Time\troot.test.wf01.wt01.status\n"
- + "1\tfalse\n"
- + "2\ttrue\n"
- + "3\tfalse\n"
- + "4\tfalse\n"
- + "5\tfalse";
- String isoGT =
- "Time\troot.test.wf01.wt01.status\n"
- + "1970-01-01T00:00:00.001Z\tfalse\n"
- + "1970-01-01T00:00:00.002Z\ttrue\n"
- + "1970-01-01T00:00:00.003Z\tfalse\n"
- + "1970-01-01T00:00:00.004Z\tfalse\n"
- + "1970-01-01T00:00:00.005Z\tfalse";
- String specialGT =
- "Time\troot.test.wf01.wt01.status\n"
- + "1970-01-01 00:00:00.001\tfalse\n"
- + "1970-01-01 00:00:00.002\ttrue\n"
- + "1970-01-01 00:00:00.003\tfalse\n"
- + "1970-01-01 00:00:00.004\tfalse\n"
- + "1970-01-01 00:00:00.005\tfalse";
- String specialGT2 =
- "Time\troot.test.wf01.wt01.status\n"
- + "1970-01 00:00\tfalse\n"
- + "1970-01 00:00\ttrue\n"
- + "1970-01 00:00\tfalse\n"
- + "1970-01 00:00\tfalse\n"
- + "1970-01 00:00\tfalse";
-
- testSetTimeDisplay("yyyy-MM-dd HH:mm:ss.SSS", specialGT);
- testSetTimeDisplay("yyyy-dd mm:ss", specialGT2);
- testSetTimeDisplay("iso8601", isoGT);
- testSetTimeDisplay("default", isoGT);
- testSetTimeDisplay("long", longGT);
- testSetTimeDisplay("number", longGT);
- }
-
- private void testSetTimeDisplay(String timeDisplay, String gt) {
- InterpreterResult actual =
- interpreter.internalInterpret(SET_TIMESTAMP_DISPLAY + "=" +
timeDisplay, null);
- Assert.assertNotNull(actual);
- Assert.assertEquals(Code.SUCCESS, actual.code());
- Assert.assertEquals(
- "Time display type has set to " + timeDisplay,
actual.message().get(0).getData());
- actual = interpreter.internalInterpret("select status from
root.test.wf01.wt01", null);
- Assert.assertNotNull(actual);
- Assert.assertEquals(Code.SUCCESS, actual.code());
- Assert.assertEquals(gt, actual.message().get(0).getData());
- }
-
- @Test
- public void testSelectColumnStatementWithTimeFilter() {
- InterpreterResult actual =
- interpreter.internalInterpret(
- "select temperature, status, hardware from root.test.wf01.wt01
where time > 2 and time < 6",
- null);
- String gt =
-
"Time\troot.test.wf01.wt01.temperature\troot.test.wf01.wt01.status\troot.test.wf01.wt01.hardware\n"
- + "3\t3.3\tfalse\t33.0\n"
- + "4\t4.4\tfalse\t44.0\n"
- + "5\t5.5\tfalse\t55.0";
- Assert.assertNotNull(actual);
- Assert.assertEquals(Code.SUCCESS, actual.code());
- Assert.assertEquals(gt, actual.message().get(0).getData());
- }
-
- @Test
- public void testException() {
- InterpreterResult actual;
- String wrongSql;
-
- wrongSql = "select * from";
- actual = interpreter.internalInterpret(wrongSql, null);
- Assert.assertNotNull(actual);
- Assert.assertEquals(Code.ERROR, actual.code());
- Assert.assertTrue(
- actual
- .message()
- .get(0)
- .getData()
- .contains("SQLException: 700: Error occurred while parsing SQL to
physical plan"));
-
- wrongSql = "select * from a";
- actual = interpreter.internalInterpret(wrongSql, null);
- Assert.assertNotNull(actual);
- Assert.assertEquals(Code.ERROR, actual.code());
- Assert.assertTrue(
- actual
- .message()
- .get(0)
- .getData()
- .contains("SQLException: 700: Error occurred while parsing SQL to
physical plan"));
-
- wrongSql = "select * from root a";
- actual = interpreter.internalInterpret(wrongSql, null);
- Assert.assertNotNull(actual);
- Assert.assertEquals(Code.ERROR, actual.code());
- Assert.assertTrue(
- actual
- .message()
- .get(0)
- .getData()
- .contains("SQLException: 700: Error occurred while parsing SQL to
physical plan"));
- }
-
- @Test
- public void TestMultiLines() {
- String insert =
- "CREATE DATABASE root.test.wf01.wt01;\n"
- + "CREATE TIMESERIES root.test.wf01.wt01.status WITH
DATATYPE=BOOLEAN, ENCODING=PLAIN;\n"
- + "CREATE TIMESERIES root.test.wf01.wt01.temperature WITH
DATATYPE=FLOAT, ENCODING=PLAIN;\n"
- + "CREATE TIMESERIES root.test.wf01.wt01.hardware WITH
DATATYPE=INT32, ENCODING=PLAIN;\n"
- + "\n"
- + "INSERT INTO root.test.wf01.wt01 (timestamp, temperature,
status, hardware)\n"
- + "VALUES (1, 1.1, false, 11);\n"
- + "\n"
- + "INSERT INTO root.test.wf01.wt01 (timestamp, temperature,
status, hardware)\n"
- + "VALUES (2, 2.2, true, 22);\n"
- + "\n"
- + "INSERT INTO root.test.wf01.wt01 (timestamp, temperature,
status, hardware)\n"
- + "VALUES (3, 3.3, false, 33);\n"
- + "\n"
- + "INSERT INTO root.test.wf01.wt01 (timestamp, temperature,
status, hardware)\n"
- + "VALUES (4, 4.4, false, 44);\n"
- + "\n"
- + "INSERT INTO root.test.wf01.wt01 (timestamp, temperature,
status, hardware)\n"
- + "VALUES (5, 5.5, false, 55);\n"
- + "\n"
- + "\n";
- String[] gt =
- new String[] {
- "CREATE DATABASE root.test.wf01.wt01",
- "CREATE TIMESERIES root.test.wf01.wt01.status WITH DATATYPE=BOOLEAN,
ENCODING=PLAIN",
- "CREATE TIMESERIES root.test.wf01.wt01.temperature WITH
DATATYPE=FLOAT, ENCODING=PLAIN",
- "CREATE TIMESERIES root.test.wf01.wt01.hardware WITH DATATYPE=INT32,
ENCODING=PLAIN",
- "INSERT INTO root.test.wf01.wt01 (timestamp, temperature, status,
hardware) VALUES (1, 1.1, false, 11)",
- "INSERT INTO root.test.wf01.wt01 (timestamp, temperature, status,
hardware) VALUES (2, 2.2, true, 22)",
- "INSERT INTO root.test.wf01.wt01 (timestamp, temperature, status,
hardware) VALUES (3, 3.3, false, 33)",
- "INSERT INTO root.test.wf01.wt01 (timestamp, temperature, status,
hardware) VALUES (4, 4.4, false, 44)",
- "INSERT INTO root.test.wf01.wt01 (timestamp, temperature, status,
hardware) VALUES (5, 5.5, false, 55)",
- };
- Assert.assertArrayEquals(gt, IoTDBInterpreter.parseMultiLinesSQL(insert));
- }
-
- @Test
- public void TestMultiLines2() {
- String query =
- "INSERT INTO root.test.wf01.wt01 (timestamp, temperature, status,
hardware)\n"
- + "VALUES (4, 4.4, false, 44);\n"
- + "\n"
- + "INSERT INTO root.test.wf01.wt01 (timestamp, temperature,
status, hardware)\n"
- + "VALUES (5, 5.5, false, 55);\n"
- + "\n"
- + "\n"
- + "SELECT *\n"
- + "FROM root.test.wf01.wt01\n"
- + "WHERE time >= 1\n"
- + "\tAND time <= 6;";
-
- String[] gt =
- new String[] {
- "INSERT INTO root.test.wf01.wt01 (timestamp, temperature, status,
hardware) VALUES (4, 4.4, false, 44)",
- "INSERT INTO root.test.wf01.wt01 (timestamp, temperature, status,
hardware) VALUES (5, 5.5, false, 55)",
- "SELECT * FROM root.test.wf01.wt01 WHERE time >= 1 AND time <= 6",
- };
- Assert.assertArrayEquals(gt, IoTDBInterpreter.parseMultiLinesSQL(query));
- }
-
- @Test
- public void testShowTimeseries() {
- InterpreterResult actual = interpreter.internalInterpret("show
timeseries", null);
- String gt =
-
"Timeseries\tAlias\tDatabase\tDataType\tEncoding\tCompression\tTags\tAttributes\tDeadband\tDeadbandParameters\tViewType\n"
- +
"root.test.wf01.wt01.temperature\tnull\troot.test.wf01\tDOUBLE\tGORILLA\tLZ4\tnull\tnull\tnull\tnull\tBASE\n"
- +
"root.test.wf01.wt01.status\tnull\troot.test.wf01\tBOOLEAN\tRLE\tLZ4\tnull\tnull\tnull\tnull\tBASE\n"
- +
"root.test.wf01.wt01.hardware\tnull\troot.test.wf01\tDOUBLE\tGORILLA\tLZ4\tnull\tnull\tnull\tnull\tBASE\n"
- +
"root.test.wf02.wt02.temperature\tnull\troot.test.wf02\tDOUBLE\tGORILLA\tLZ4\tnull\tnull\tnull\tnull\tBASE\n"
- +
"root.test.wf02.wt02.status\tnull\troot.test.wf02\tBOOLEAN\tRLE\tLZ4\tnull\tnull\tnull\tnull\tBASE\n"
- +
"root.test.wf02.wt02.hardware\tnull\troot.test.wf02\tDOUBLE\tGORILLA\tLZ4\tnull\tnull\tnull\tnull\tBASE";
- Assert.assertNotNull(actual);
- Assert.assertEquals(Code.SUCCESS, actual.code());
- Assert.assertEquals(gt, actual.message().get(0).getData());
- }
-
- @Test
- public void testShowDevices() {
- InterpreterResult actual = interpreter.internalInterpret("show devices",
null);
- String gt =
- "Device\tIsAligned\tTemplate\n"
- + "root.test.wf01.wt01\tfalse\tnull\n"
- + "root.test.wf02.wt02\tfalse\tnull";
- Assert.assertNotNull(actual);
- Assert.assertEquals(Code.SUCCESS, actual.code());
- Assert.assertEquals(gt, actual.message().get(0).getData());
- }
-
- @Test
- public void testShowDevicesWithSg() {
- InterpreterResult actual = interpreter.internalInterpret("show devices
with database", null);
- String gt =
- "Device\tDatabase\tIsAligned\tTemplate\n"
- + "root.test.wf01.wt01\troot.test.wf01\tfalse\tnull\n"
- + "root.test.wf02.wt02\troot.test.wf02\tfalse\tnull";
- Assert.assertNotNull(actual);
- Assert.assertEquals(Code.SUCCESS, actual.code());
- Assert.assertEquals(gt, actual.message().get(0).getData());
- }
-
- @Test
- public void testShowAllTTL() {
- interpreter.internalInterpret("SET TTL TO root.test.wf01 12345", null);
- InterpreterResult actual = interpreter.internalInterpret("SHOW ALL TTL",
null);
- String gt = "Database\tTTL\n" + "root.test.wf02\tnull\n" +
"root.test.wf01\t12345";
- Assert.assertNotNull(actual);
- Assert.assertEquals(Code.SUCCESS, actual.code());
- Assert.assertEquals(gt, actual.message().get(0).getData());
- }
-
- @Test
- public void testShowTTL() {
- interpreter.internalInterpret("SET TTL TO root.test.wf01 12345", null);
- InterpreterResult actual = interpreter.internalInterpret("SHOW TTL ON
root.test.wf01", null);
- String gt = "Database\tTTL\n" + "root.test.wf01\t12345";
- Assert.assertNotNull(actual);
- Assert.assertEquals(Code.SUCCESS, actual.code());
- Assert.assertEquals(gt, actual.message().get(0).getData());
- }
-
- @Test
- public void testShowStorageGroup() {
- InterpreterResult actual = interpreter.internalInterpret("SHOW DATABASES",
null);
- String gt =
-
"Database\tTTL\tSchemaReplicationFactor\tDataReplicationFactor\tTimePartitionInterval\n"
- + "root.test.wf02\tnull\t1\t1\t604800000\n"
- + "root.test.wf01\tnull\t1\t1\t604800000";
- Assert.assertNotNull(actual);
- Assert.assertEquals(Code.SUCCESS, actual.code());
- Assert.assertEquals(gt, actual.message().get(0).getData());
- }
-
- @Test
- public void testListUser() {
- interpreter.internalInterpret("CREATE USER user1 'password1'", null);
- InterpreterResult actual = interpreter.internalInterpret("LIST USER",
null);
- String gt = "user\n" + "root\n" + "user1";
- Assert.assertNotNull(actual);
- Assert.assertEquals(Code.SUCCESS, actual.code());
- Assert.assertEquals(gt, actual.message().get(0).getData());
- }
-}