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

justinchen 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 18cd382b186 Pipe: Fixed the potential NPE in receiver tablet 
construction (#16648)
18cd382b186 is described below

commit 18cd382b1861b6472f818931cbe800a9a05629df
Author: Caideyipi <[email protected]>
AuthorDate: Mon Oct 27 10:14:05 2025 +0800

    Pipe: Fixed the potential NPE in receiver tablet construction (#16648)
---
 .../plan/statement/crud/InsertTabletStatement.java | 34 ++++++++++++++++++++--
 1 file changed, 31 insertions(+), 3 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/crud/InsertTabletStatement.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/crud/InsertTabletStatement.java
index 4680c313ba5..749a2422b01 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/crud/InsertTabletStatement.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/crud/InsertTabletStatement.java
@@ -113,9 +113,13 @@ public class InsertTabletStatement extends 
InsertBaseStatement implements ISchem
     }
     setAligned(isAligned);
     setTimes(tablet.getTimestamps());
-    
setColumns(Arrays.stream(tablet.getValues()).map(this::convertTableColumn).toArray());
-    setBitMaps(tablet.getBitMaps());
     setRowCount(tablet.getRowSize());
+    final Object[] columns = new Object[tablet.getValues().length];
+    for (int i = 0; i < tablet.getValues().length; ++i) {
+      columns[i] = convertTableColumn(tablet.getValues()[i], 
tablet.getRowSize(), dataTypes[i]);
+    }
+    setColumns(columns);
+    setBitMaps(tablet.getBitMaps());
 
     if (Objects.nonNull(databaseName)) {
       setWriteToTable(true);
@@ -127,7 +131,7 @@ public class InsertTabletStatement extends 
InsertBaseStatement implements ISchem
     }
   }
 
-  private Object convertTableColumn(final Object input) {
+  private Object convertTableColumn(final Object input, final int rowCount, 
final TSDataType type) {
     if (input instanceof LocalDate[]) {
       return Arrays.stream(((LocalDate[]) input))
           .map(date -> Objects.nonNull(date) ? 
DateUtils.parseDateExpressionToInt(date) : 0)
@@ -137,6 +141,30 @@ public class InsertTabletStatement extends 
InsertBaseStatement implements ISchem
       return Arrays.stream(((Binary[]) input))
           .map(binary -> Objects.nonNull(binary) ? binary : Binary.EMPTY_VALUE)
           .toArray(Binary[]::new);
+    } else if (input == null) {
+      switch (type) {
+        case BOOLEAN:
+          return new boolean[rowCount];
+        case INT32:
+        case DATE:
+          return new int[rowCount];
+        case INT64:
+        case TIMESTAMP:
+          return new long[rowCount];
+        case FLOAT:
+          return new float[rowCount];
+        case DOUBLE:
+          return new double[rowCount];
+        case TEXT:
+        case BLOB:
+        case STRING:
+          final Binary[] result = new Binary[rowCount];
+          Arrays.fill(result, Binary.EMPTY_VALUE);
+          return result;
+        default:
+          throw new UnSupportedDataTypeException(
+              String.format("data type %s is not supported when convert data 
at client", type));
+      }
     }
 
     return input;

Reply via email to