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

shuwenwei pushed a commit to branch fix-insert-tablet-effective-row-count
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit b3d4c5f9558f11bc2ce21943967a512a64d6dfbc
Author: shuwenwei <[email protected]>
AuthorDate: Wed Nov 11 15:13:37 2026 +0800

    Fix relational insert tablet redirect row count
---
 .../node/write/RelationalInsertTabletNode.java     |  4 +--
 .../planner/node/write/WritePlanNodeSplitTest.java | 29 ++++++++++++++++++++++
 2 files changed, 31 insertions(+), 2 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/write/RelationalInsertTabletNode.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/write/RelationalInsertTabletNode.java
index 50924da4447..28bd6eeffa4 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/write/RelationalInsertTabletNode.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/write/RelationalInsertTabletNode.java
@@ -287,8 +287,8 @@ public class RelationalInsertTabletNode extends 
InsertTabletNode {
         subRanges.add(splitInfo.ranges.get(2 * i + 1));
       }
     }
-    final List<TDataNodeLocation> redirectNodeList = new 
ArrayList<>(times.length);
-    for (int i = 0; i < times.length; i++) {
+    final List<TDataNodeLocation> redirectNodeList = new ArrayList<>(rowCount);
+    for (int i = 0; i < rowCount; i++) {
       final IDeviceID deviceId = getDeviceID(i);
       redirectNodeList.add(dataNodeLocationMap.get(deviceId));
     }
diff --git 
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/planner/node/write/WritePlanNodeSplitTest.java
 
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/planner/node/write/WritePlanNodeSplitTest.java
index f7da4e06144..f4d83b19e7f 100644
--- 
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/planner/node/write/WritePlanNodeSplitTest.java
+++ 
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/planner/node/write/WritePlanNodeSplitTest.java
@@ -411,6 +411,35 @@ public class WritePlanNodeSplitTest {
     }
   }
 
+  @Test
+  public void testSplitRelationalInsertTabletUsesRowCountForRedirects()
+      throws IllegalPathException {
+    RelationalInsertTabletNode relationalInsertTabletNode =
+        new RelationalInsertTabletNode(new PlanNodeId("plan node with spare 
row capacity"));
+    relationalInsertTabletNode.setTargetPath(new PartialPath("root.sg1"));
+    relationalInsertTabletNode.setTimes(new long[] {1, 2, 3, 4});
+    relationalInsertTabletNode.setDataTypes(new TSDataType[] 
{TSDataType.STRING, TSDataType.INT32});
+    Binary device = new Binary("d1", StandardCharsets.UTF_8);
+    relationalInsertTabletNode.setColumns(
+        new Object[] {new Binary[] {device, device, device, device}, new int[] 
{10, 20, 30, 40}});
+    relationalInsertTabletNode.setColumnCategories(
+        new TsTableColumnCategory[] {TsTableColumnCategory.TAG, 
TsTableColumnCategory.FIELD});
+    relationalInsertTabletNode.setRowCount(2);
+
+    DataPartitionQueryParam dataPartitionQueryParam = new 
DataPartitionQueryParam();
+    
dataPartitionQueryParam.setDeviceID(relationalInsertTabletNode.getDeviceID(0));
+    dataPartitionQueryParam.setTimePartitionSlotList(
+        relationalInsertTabletNode.getTimePartitionSlots());
+    Analysis analysis = new Analysis();
+    analysis.setDataPartitionInfo(
+        getDataPartition(Collections.singletonList(dataPartitionQueryParam)));
+
+    List<WritePlanNode> splitNodes = 
relationalInsertTabletNode.splitByPartition(analysis);
+
+    Assert.assertEquals(1, splitNodes.size());
+    Assert.assertEquals(2, analysis.getRedirectNodeList().size());
+  }
+
   @Test
   public void testInsertMultiTablets() throws IllegalPathException {
     InsertMultiTabletsNode insertMultiTabletsNode =

Reply via email to