You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ji...@apache.org on 2024/08/16 08:09:54 UTC
(iotdb) branch fix_table_model_insert_keyword created (now fe343541271)
This is an automated email from the ASF dual-hosted git repository.
jiangtian pushed a change to branch fix_table_model_insert_keyword
in repository https://gitbox.apache.org/repos/asf/iotdb.git
at fe343541271 Fix that table-model cannot use tree-model keywords as column names
This branch includes the following new commits:
new fe343541271 Fix that table-model cannot use tree-model keywords as column names
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(iotdb) 01/01: Fix that table-model cannot use tree-model keywords as column names
Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jiangtian pushed a commit to branch fix_table_model_insert_keyword
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit fe343541271ca49602723099f41f6f5b13cd5c94
Author: Tian Jiang <jt...@163.com>
AuthorDate: Fri Aug 16 16:09:41 2024 +0800
Fix that table-model cannot use tree-model keywords as column names
---
.../relational/it/db/it/IoTDBInsertTableIT.java | 76 ++++++++++++++++++++++
.../protocol/thrift/impl/ClientRPCServiceImpl.java | 5 +-
2 files changed, 80 insertions(+), 1 deletion(-)
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
index 1908b36f80f..0101fa18001 100644
--- 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
@@ -27,10 +27,13 @@ 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.IoTDBConnectionException;
+import org.apache.iotdb.rpc.StatementExecutionException;
import org.apache.iotdb.rpc.TSStatusCode;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.read.common.RowRecord;
+import org.apache.tsfile.utils.Binary;
import org.apache.tsfile.write.record.Tablet;
import org.apache.tsfile.write.schema.IMeasurementSchema;
import org.apache.tsfile.write.schema.MeasurementSchema;
@@ -42,12 +45,14 @@ import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
+import java.nio.charset.Charset;
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.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -616,6 +621,77 @@ public class IoTDBInsertTableIT {
}
}
+ @Test
+ public void testInsertKeyword() throws IoTDBConnectionException, StatementExecutionException {
+ try (ISession session = EnvFactory.getEnv().getSessionConnection(BaseEnv.TABLE_SQL_DIALECT)) {
+ session.executeNonQueryStatement("USE \"test\"");
+ session.executeNonQueryStatement(
+ "create table table20 ("
+ + "device_id string id,"
+ + "attribute STRING ATTRIBUTE,"
+ + "boolean boolean MEASUREMENT,"
+ + "int32 int32 MEASUREMENT,"
+ + "int64 int64 MEASUREMENT,"
+ + "float float MEASUREMENT,"
+ + "double double MEASUREMENT,"
+ + "text text MEASUREMENT,"
+ + "string string MEASUREMENT,"
+ + "blob blob MEASUREMENT,"
+ + "timestamp01 timestamp MEASUREMENT,"
+ + "date date MEASUREMENT)");
+
+ List<IMeasurementSchema> schemas = new ArrayList<>();
+ schemas.add(new MeasurementSchema("device_id", TSDataType.STRING));
+ schemas.add(new MeasurementSchema("attribute", TSDataType.STRING));
+ schemas.add(new MeasurementSchema("boolean", TSDataType.BOOLEAN));
+ schemas.add(new MeasurementSchema("int32", TSDataType.INT32));
+ schemas.add(new MeasurementSchema("int64", TSDataType.INT64));
+ schemas.add(new MeasurementSchema("float", TSDataType.FLOAT));
+ schemas.add(new MeasurementSchema("double", TSDataType.DOUBLE));
+ schemas.add(new MeasurementSchema("text", TSDataType.TEXT));
+ schemas.add(new MeasurementSchema("string", TSDataType.STRING));
+ schemas.add(new MeasurementSchema("blob", TSDataType.BLOB));
+ schemas.add(new MeasurementSchema("timestamp", TSDataType.TIMESTAMP));
+ schemas.add(new MeasurementSchema("date", TSDataType.DATE));
+ final List<Tablet.ColumnType> columnTypes =
+ Arrays.asList(
+ Tablet.ColumnType.ID,
+ Tablet.ColumnType.ATTRIBUTE,
+ Tablet.ColumnType.MEASUREMENT,
+ Tablet.ColumnType.MEASUREMENT,
+ Tablet.ColumnType.MEASUREMENT,
+ Tablet.ColumnType.MEASUREMENT,
+ Tablet.ColumnType.MEASUREMENT,
+ Tablet.ColumnType.MEASUREMENT,
+ Tablet.ColumnType.MEASUREMENT,
+ Tablet.ColumnType.MEASUREMENT,
+ Tablet.ColumnType.MEASUREMENT,
+ Tablet.ColumnType.MEASUREMENT);
+
+ long timestamp = 0;
+ Tablet tablet = new Tablet("table20", schemas, columnTypes, 10);
+
+ for (long row = 0; row < 10; row++) {
+ int rowIndex = tablet.rowSize++;
+ tablet.addTimestamp(rowIndex, timestamp + row);
+ tablet.addValue("device_id", rowIndex, "1");
+ tablet.addValue("attribute", rowIndex, "1");
+ tablet.addValue("boolean", rowIndex, true);
+ tablet.addValue("int32", rowIndex, Integer.valueOf("1"));
+ tablet.addValue("int64", rowIndex, Long.valueOf("1"));
+ tablet.addValue("float", rowIndex, Float.valueOf("1.0"));
+ tablet.addValue("double", rowIndex, Double.valueOf("1.0"));
+ tablet.addValue("text", rowIndex, "true");
+ tablet.addValue("string", rowIndex, "true");
+ tablet.addValue("blob", rowIndex, new Binary("iotdb", Charset.defaultCharset()));
+ tablet.addValue("timestamp", rowIndex, 1L);
+ tablet.addValue("date", rowIndex, LocalDate.parse("2024-08-15"));
+ }
+ session.insertRelationalTablet(tablet, true);
+ session.executeNonQueryStatement("drop database db1");
+ }
+ }
+
private List<Integer> checkHeader(
ResultSetMetaData resultSetMetaData, String expectedHeaderStrings, int[] expectedTypes)
throws SQLException {
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 e4a78f3a8f8..9db15b4a954 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
@@ -2167,7 +2167,10 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
}
// check whether measurement is legal according to syntax convention
- req.setMeasurements(PathUtils.checkIsLegalSingleMeasurementsAndUpdate(req.getMeasurements()));
+ if (!req.isWriteToTable()) {
+ req.setMeasurements(
+ PathUtils.checkIsLegalSingleMeasurementsAndUpdate(req.getMeasurements()));
+ }
// Step 1: transfer from TSInsertTabletReq to Statement
InsertTabletStatement statement = StatementGenerator.createStatement(req);
// return success when this statement is empty because server doesn't need to execute it