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

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

commit 9d9edb29297b0e08b8894c5510ed29bc7ea280e4
Author: shuwenwei <[email protected]>
AuthorDate: Thu Jun 5 17:29:33 2025 +0800

    When the aligned series has some inconsistent types in the memtable, the 
other column will also be ignored
---
 .../schemaregion/utils/ResourceByPathUtils.java            | 14 +-------------
 .../dataregion/memtable/AlignedWritableMemChunk.java       | 13 +++++++++++--
 2 files changed, 12 insertions(+), 15 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/utils/ResourceByPathUtils.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/utils/ResourceByPathUtils.java
index e5288adc76d..79d34bd3ee9 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/utils/ResourceByPathUtils.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/utils/ResourceByPathUtils.java
@@ -66,7 +66,6 @@ import java.io.IOException;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -318,18 +317,6 @@ class AlignedResourceByPathUtils extends 
ResourceByPathUtils {
     }
     AlignedWritableMemChunk alignedMemChunk =
         ((AlignedWritableMemChunkGroup) 
memTableMap.get(deviceID)).getAlignedMemChunk();
-
-    // check If data type matches
-    Map<String, TSDataType> dataTypeMap = new 
HashMap<>(alignedMemChunk.getSchemaList().size());
-    for (IMeasurementSchema schema : alignedMemChunk.getSchemaList()) {
-      dataTypeMap.put(schema.getMeasurementName(), schema.getType());
-    }
-    for (IMeasurementSchema schema : alignedFullPath.getSchemaList()) {
-      TSDataType dataTypeInMemChunk = 
dataTypeMap.get(schema.getMeasurementName());
-      if (dataTypeInMemChunk != null && dataTypeInMemChunk != 
schema.getType()) {
-        return null;
-      }
-    }
     // only need to do this check for tree model
     if (context.isIgnoreAllNullRows()) {
       boolean containsMeasurement = false;
@@ -350,6 +337,7 @@ class AlignedResourceByPathUtils extends 
ResourceByPathUtils {
             context, alignedMemChunk, modsToMemtable == null, 
globalTimeFilter);
 
     // column index list for the query
+    // Columns with inconsistent types will be ignored and set -1
     List<Integer> columnIndexList =
         alignedMemChunk.buildColumnIndexList(alignedFullPath.getSchemaList());
 
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/memtable/AlignedWritableMemChunk.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/memtable/AlignedWritableMemChunk.java
index d20866d0c79..d41ef855d36 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/memtable/AlignedWritableMemChunk.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/memtable/AlignedWritableMemChunk.java
@@ -834,9 +834,18 @@ public class AlignedWritableMemChunk extends 
AbstractWritableMemChunk {
 
   public List<Integer> buildColumnIndexList(List<IMeasurementSchema> 
schemaList) {
     List<Integer> columnIndexList = new ArrayList<>();
-    for (IMeasurementSchema measurementSchema : schemaList) {
+    for (IMeasurementSchema requiredMeasurementSchema : schemaList) {
+      Integer measurementIndex =
+          
measurementIndexMap.get(requiredMeasurementSchema.getMeasurementName());
+      if (measurementIndex == null) {
+        columnIndexList.add(-1);
+        continue;
+      }
+      IMeasurementSchema schemaInMemChunk = 
this.schemaList.get(measurementIndex);
       columnIndexList.add(
-          
measurementIndexMap.getOrDefault(measurementSchema.getMeasurementName(), -1));
+          schemaInMemChunk.getType() == requiredMeasurementSchema.getType()
+              ? measurementIndex
+              : -1);
     }
     return columnIndexList;
   }

Reply via email to