You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2023/11/20 03:16:11 UTC

(iotdb) branch fix_insertTablets_no_error created (now f20afec5aac)

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

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


      at f20afec5aac Fix insertTablets API didn't return schema validation error

This branch includes the following new commits:

     new f20afec5aac Fix insertTablets API didn't return schema validation error

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 insertTablets API didn't return schema validation error

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

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

commit f20afec5aacd983e4c3a3d3ebf8543aebc8af976
Author: HTHou <hh...@outlook.com>
AuthorDate: Mon Nov 20 11:15:53 2023 +0800

    Fix insertTablets API didn't return schema validation error
---
 .../iotdb/session/it/IoTDBSessionSimpleIT.java     | 66 +++++++++++++++++++++-
 .../crud/InsertMultiTabletsStatement.java          |  9 +++
 2 files changed, 73 insertions(+), 2 deletions(-)

diff --git a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionSimpleIT.java b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionSimpleIT.java
index 6601e3593be..03c24cb3e4d 100644
--- a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionSimpleIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionSimpleIT.java
@@ -93,7 +93,7 @@ public class IoTDBSessionSimpleIT {
       schemaList.add(new MeasurementSchema("s2", TSDataType.DOUBLE));
       schemaList.add(new MeasurementSchema("s3", TSDataType.TEXT));
 
-      Tablet tablet = new Tablet("root.sg.d", schemaList, 10);
+      Tablet tablet = new Tablet("root.sg.d1", schemaList, 10);
 
       long timestamp = System.currentTimeMillis();
 
@@ -123,11 +123,73 @@ public class IoTDBSessionSimpleIT {
         assertEquals(15L, rowRecord.getFields().get(2).getLongV());
       }
     } catch (Exception e) {
-      e.printStackTrace();
       fail(e.getMessage());
     }
   }
 
+  @Test
+  @Category({LocalStandaloneIT.class, ClusterIT.class})
+  public void insertPartialTabletsTest() {
+    try (ISession session = EnvFactory.getEnv().getSessionConnection()) {
+      session.createTimeseries(
+          "root.sg.d2.s2", TSDataType.BOOLEAN, TSEncoding.PLAIN, CompressionType.SNAPPY);
+
+      List<MeasurementSchema> schemaList = new ArrayList<>();
+      schemaList.add(new MeasurementSchema("s1", TSDataType.INT64));
+      schemaList.add(new MeasurementSchema("s2", TSDataType.DOUBLE));
+      schemaList.add(new MeasurementSchema("s3", TSDataType.TEXT));
+
+      Tablet tablet1 = new Tablet("root.sg.d1", schemaList, 10);
+      Tablet tablet2 = new Tablet("root.sg.d2", schemaList, 10);
+      Tablet tablet3 = new Tablet("root.sg.d3", schemaList, 10);
+
+      Map<String, Tablet> tabletMap = new HashMap<>();
+      tabletMap.put("root.sg.d1", tablet1);
+      tabletMap.put("root.sg.d2", tablet2);
+      tabletMap.put("root.sg.d3", tablet3);
+
+      long timestamp = System.currentTimeMillis();
+
+      for (long row = 0; row < 15; row++) {
+        int rowIndex1 = tablet1.rowSize++;
+        tablet1.addTimestamp(rowIndex1, timestamp);
+        tablet1.addValue("s1", rowIndex1, 1L);
+        tablet1.addValue("s2", rowIndex1, 1D);
+        tablet1.addValue("s3", rowIndex1, new Binary("1", TSFileConfig.STRING_CHARSET));
+
+        int rowIndex2 = tablet2.rowSize++;
+        tablet2.addTimestamp(rowIndex2, timestamp);
+        tablet2.addValue("s1", rowIndex2, 1L);
+        tablet2.addValue("s2", rowIndex2, 1D);
+        tablet2.addValue("s3", rowIndex2, new Binary("1", TSFileConfig.STRING_CHARSET));
+
+        int rowIndex3 = tablet3.rowSize++;
+        tablet3.addTimestamp(rowIndex3, timestamp);
+        tablet3.addValue("s1", rowIndex3, 1L);
+        tablet3.addValue("s2", rowIndex3, 1D);
+        tablet3.addValue("s3", rowIndex3, new Binary("1", TSFileConfig.STRING_CHARSET));
+
+        if (tablet1.rowSize == tablet1.getMaxRowNumber()) {
+          session.insertTablets(tabletMap);
+          tablet1.reset();
+          tablet2.reset();
+          tablet3.reset();
+        }
+        timestamp++;
+      }
+
+      if (tablet1.rowSize != 0) {
+        session.insertTablets(tabletMap);
+        tablet1.reset();
+        tablet2.reset();
+        tablet3.reset();
+      }
+      fail();
+    } catch (Exception e) {
+      Assert.assertTrue(e.getMessage().contains("DataType"));
+    }
+  }
+
   @Test
   @Category({LocalStandaloneIT.class, ClusterIT.class})
   public void insertByStrAndInferTypeTest() {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/crud/InsertMultiTabletsStatement.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/crud/InsertMultiTabletsStatement.java
index da695c21d11..969af58cd82 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/crud/InsertMultiTabletsStatement.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/crud/InsertMultiTabletsStatement.java
@@ -87,6 +87,15 @@ public class InsertMultiTabletsStatement extends InsertBaseStatement {
         .collect(Collectors.toList());
   }
 
+  @Override
+  public void updateAfterSchemaValidation() {
+    for (InsertTabletStatement insertTabletStatement : insertTabletStatementList) {
+      if (!this.hasFailedMeasurements() && insertTabletStatement.hasFailedMeasurements()) {
+        this.failedMeasurementIndex2Info = insertTabletStatement.failedMeasurementIndex2Info;
+      }
+    }
+  }
+
   @Override
   protected boolean checkAndCastDataType(int columnIndex, TSDataType dataType) {
     return false;