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 2025/01/03 05:03:42 UTC

(iotdb) branch new_test_case created (now 661ce7df0fe)

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

jiangtian pushed a change to branch new_test_case
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at 661ce7df0fe Fix that place-holder tag column are not Binary[]

This branch includes the following new commits:

     new 9ccf0d6bd92 add new test case
     new 661ce7df0fe Fix that place-holder tag column are not Binary[]

The 2 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) 02/02: Fix that place-holder tag column are not Binary[]

Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 661ce7df0feba18128781289e11cfd8454d271e5
Author: Tian Jiang <jt...@163.com>
AuthorDate: Fri Jan 3 13:03:33 2025 +0800

    Fix that place-holder tag column are not Binary[]
---
 .../iotdb/relational/it/session/IoTDBSessionRelationalIT.java       | 2 +-
 .../src/main/java/org/apache/iotdb/db/utils/CommonUtils.java        | 6 ------
 2 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/integration-test/src/test/java/org/apache/iotdb/relational/it/session/IoTDBSessionRelationalIT.java b/integration-test/src/test/java/org/apache/iotdb/relational/it/session/IoTDBSessionRelationalIT.java
index 99c6759690b..0ab30d29d5e 100644
--- a/integration-test/src/test/java/org/apache/iotdb/relational/it/session/IoTDBSessionRelationalIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/relational/it/session/IoTDBSessionRelationalIT.java
@@ -1494,7 +1494,7 @@ public class IoTDBSessionRelationalIT {
 
       for (int row = 0; row < 15; row++) {
         tablet.addTimestamp(row, timestamp);
-        tablet.addValue("tag2", row, "tag:" + timestamp);
+        tablet.addValue("tag2", row, "string");
         tablet.addValue("s2", row, timestamp);
         timestamp ++;
       }
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/CommonUtils.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/CommonUtils.java
index 36cd5616820..d83379bd738 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/CommonUtils.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/CommonUtils.java
@@ -379,12 +379,6 @@ public class CommonUtils {
         break;
       case TEXT:
       case STRING:
-        if (columnCategory.equals(TsTableColumnCategory.FIELD)) {
-          valueColumn = new Binary[rowNum];
-        } else {
-          valueColumn = new String[rowNum];
-        }
-        break;
       case BLOB:
         valueColumn = new Binary[rowNum];
         break;


(iotdb) 01/02: add new test case

Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 9ccf0d6bd921e69bdf161f72e534838af4cbb663
Author: Tian Jiang <jt...@163.com>
AuthorDate: Fri Jan 3 10:59:40 2025 +0800

    add new test case
---
 .../it/session/IoTDBSessionRelationalIT.java       | 151 ++++++++++++++++-----
 1 file changed, 116 insertions(+), 35 deletions(-)

diff --git a/integration-test/src/test/java/org/apache/iotdb/relational/it/session/IoTDBSessionRelationalIT.java b/integration-test/src/test/java/org/apache/iotdb/relational/it/session/IoTDBSessionRelationalIT.java
index 50ae3f55b6e..99c6759690b 100644
--- a/integration-test/src/test/java/org/apache/iotdb/relational/it/session/IoTDBSessionRelationalIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/relational/it/session/IoTDBSessionRelationalIT.java
@@ -801,7 +801,7 @@ public class IoTDBSessionRelationalIT {
 
   @Test
   @Category({LocalStandaloneIT.class, ClusterIT.class})
-  public void autoCreatetagColumnTest()
+  public void autoCreateTagColumnTest()
       throws IoTDBConnectionException, StatementExecutionException {
     try (ITableSession session = EnvFactory.getEnv().getTableSessionConnection()) {
       session.executeNonQueryStatement("USE \"db1\"");
@@ -824,52 +824,54 @@ public class IoTDBSessionRelationalIT {
               columnTypes,
               15);
 
-      for (long row = 0; row < 15; row++) {
-        int rowIndex = tablet.getRowSize();
-        tablet.addTimestamp(rowIndex, timestamp + row);
-        tablet.addValue("tag2", rowIndex, "tag:" + row);
-        tablet.addValue("attr1", rowIndex, "attr:" + row);
-        tablet.addValue("m1", rowIndex, row * 1.0);
-        if (tablet.getRowSize() == tablet.getMaxRowNumber()) {
-          session.insert(tablet);
-          tablet.reset();
-        }
+      for (int row = 0; row < 15; row++) {
+        tablet.addTimestamp(row, timestamp);
+        tablet.addValue("tag2", row, "tag:" + timestamp);
+        tablet.addValue("attr1", row, "attr:" + timestamp);
+        tablet.addValue("m1", row, timestamp * 1.0);
+        timestamp ++;
       }
 
-      if (tablet.getRowSize() != 0) {
-        session.insert(tablet);
-        tablet.reset();
+      session.insert(tablet);
+      tablet.reset();
+
+      SessionDataSet dataSet = session.executeQueryStatement("select * from table8 order by time");
+      int cnt = 0;
+      while (dataSet.hasNext()) {
+        RowRecord rowRecord = dataSet.next();
+        long t = rowRecord.getFields().get(0).getLongV();
+        // tag 1 should be null
+        assertNull(rowRecord.getFields().get(1).getDataType());
+        assertEquals("tag:" + t, rowRecord.getFields().get(2).getBinaryV().toString());
+        assertEquals("attr:" + t, rowRecord.getFields().get(3).getBinaryV().toString());
+        assertEquals(t * 1.0, rowRecord.getFields().get(4).getDoubleV(), 0.0001);
+        cnt++;
       }
+      assertEquals(15, cnt);
 
       session.executeNonQueryStatement("FLush");
 
-      for (long row = 15; row < 30; row++) {
-        int rowIndex = tablet.getRowSize();
-        tablet.addTimestamp(rowIndex, timestamp + row);
-        tablet.addValue("tag2", rowIndex, "tag:" + row);
-        tablet.addValue("attr1", rowIndex, "attr:" + row);
-        tablet.addValue("m1", rowIndex, row * 1.0);
-        if (tablet.getRowSize() == tablet.getMaxRowNumber()) {
-          session.insert(tablet);
-          tablet.reset();
-        }
+      for (int row = 0; row < 15; row++) {
+        tablet.addTimestamp(row, timestamp);
+        tablet.addValue("tag2", row, "tag:" + timestamp);
+        tablet.addValue("attr1", row, "attr:" + timestamp);
+        tablet.addValue("m1", row, timestamp * 1.0);
+        timestamp ++;
       }
 
-      if (tablet.getRowSize() != 0) {
-        session.insert(tablet);
-        tablet.reset();
-      }
+      session.insert(tablet);
+      tablet.reset();
 
-      SessionDataSet dataSet = session.executeQueryStatement("select * from table8 order by time");
-      int cnt = 0;
+      dataSet = session.executeQueryStatement("select * from table8 order by time");
+      cnt = 0;
       while (dataSet.hasNext()) {
         RowRecord rowRecord = dataSet.next();
-        timestamp = rowRecord.getFields().get(0).getLongV();
+        long t = rowRecord.getFields().get(0).getLongV();
         // tag 1 should be null
         assertNull(rowRecord.getFields().get(1).getDataType());
-        assertEquals("tag:" + timestamp, rowRecord.getFields().get(2).getBinaryV().toString());
-        assertEquals("attr:" + timestamp, rowRecord.getFields().get(3).getBinaryV().toString());
-        assertEquals(timestamp * 1.0, rowRecord.getFields().get(4).getDoubleV(), 0.0001);
+        assertEquals("tag:" + t, rowRecord.getFields().get(2).getBinaryV().toString());
+        assertEquals("attr:" + t, rowRecord.getFields().get(3).getBinaryV().toString());
+        assertEquals(t * 1.0, rowRecord.getFields().get(4).getDoubleV(), 0.0001);
         cnt++;
       }
       assertEquals(30, cnt);
@@ -878,7 +880,7 @@ public class IoTDBSessionRelationalIT {
 
   @Test
   @Category({LocalStandaloneIT.class, ClusterIT.class})
-  public void autoAdjusttagTest() throws IoTDBConnectionException, StatementExecutionException {
+  public void autoAdjustTagTest() throws IoTDBConnectionException, StatementExecutionException {
     try (ITableSession session = EnvFactory.getEnv().getTableSessionConnection()) {
       session.executeNonQueryStatement("USE \"db1\"");
       // the tag order in the table is (tag1, tag2)
@@ -1464,4 +1466,83 @@ public class IoTDBSessionRelationalIT {
       session.executeNonQueryStatement("SET CONFIGURATION \"enable_partial_insert\"=\"true\"");
     }
   }
+
+  @Test
+  @Category({LocalStandaloneIT.class, ClusterIT.class})
+  public void autoCreateTagColumnTest2()
+      throws IoTDBConnectionException, StatementExecutionException {
+    int testNum = 17;
+    try (ITableSession session = EnvFactory.getEnv().getTableSessionConnection()) {
+      session.executeNonQueryStatement("USE \"db1\"");
+      // only one column in this table, and others should be auto-created
+      session.executeNonQueryStatement("CREATE TABLE table" + testNum + " (tag1 string tag, s1 text field)");
+
+      List<IMeasurementSchema> schemaList = new ArrayList<>();
+      schemaList.add(new MeasurementSchema("tag2", TSDataType.STRING));
+      schemaList.add(new MeasurementSchema("s2", TSDataType.INT64));
+      final List<ColumnCategory> columnTypes =
+          Arrays.asList(ColumnCategory.TAG, ColumnCategory.FIELD);
+
+      long timestamp = 0;
+      Tablet tablet =
+          new Tablet(
+              "table" + testNum,
+              IMeasurementSchema.getMeasurementNameList(schemaList),
+              IMeasurementSchema.getDataTypeList(schemaList),
+              columnTypes,
+              15);
+
+      for (int row = 0; row < 15; row++) {
+        tablet.addTimestamp(row, timestamp);
+        tablet.addValue("tag2", row, "tag:" + timestamp);
+        tablet.addValue("s2", row, timestamp);
+        timestamp ++;
+      }
+
+      session.insert(tablet);
+      tablet.reset();
+
+      SessionDataSet dataSet = session.executeQueryStatement("select * from table" + testNum + " order by time");
+      int cnt = 0;
+      while (dataSet.hasNext()) {
+        RowRecord rowRecord = dataSet.next();
+        long t = rowRecord.getFields().get(0).getLongV();
+        // tag 1 should be null
+        assertNull(rowRecord.getFields().get(1).getDataType());
+        // s1 should be null
+        assertNull(rowRecord.getFields().get(2).getDataType());
+        assertEquals("tag:" + t, rowRecord.getFields().get(3).getBinaryV().toString());
+        assertEquals(t, rowRecord.getFields().get(4).getLongV());
+        cnt++;
+      }
+      assertEquals(15, cnt);
+
+      session.executeNonQueryStatement("FLush");
+
+      for (int row = 0; row < 15; row++) {
+        tablet.addTimestamp(row, timestamp);
+        tablet.addValue("tag2", row, "tag:" + timestamp);
+        tablet.addValue("s2", row, timestamp);
+        timestamp ++;
+      }
+
+      session.insert(tablet);
+      tablet.reset();
+
+      dataSet = session.executeQueryStatement("select * from table" + testNum + " order by time");
+      cnt = 0;
+      while (dataSet.hasNext()) {
+        RowRecord rowRecord = dataSet.next();
+        long t = rowRecord.getFields().get(0).getLongV();
+        // tag 1 should be null
+        assertNull(rowRecord.getFields().get(1).getDataType());
+        // s1 should be null
+        assertNull(rowRecord.getFields().get(2).getDataType());
+        assertEquals("tag:" + t, rowRecord.getFields().get(3).getBinaryV().toString());
+        assertEquals(t, rowRecord.getFields().get(4).getLongV());
+        cnt++;
+      }
+      assertEquals(30, cnt);
+    }
+  }
 }