This is an automated email from the ASF dual-hosted git repository.
jackietien 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 b0fa6bdf100 When the queries aligned series has some inconsistent data
types in memtable, the other column will also be ignored
b0fa6bdf100 is described below
commit b0fa6bdf100232f4c0ca6a023894aa9395c18bfe
Author: shuwenwei <[email protected]>
AuthorDate: Fri Jun 6 02:48:55 2025 +0800
When the queries aligned series has some inconsistent data types in
memtable, the other column will also be ignored
---
.../IoTDBTableViewQueryWithNotMatchedDataTypeIT.java | 3 ++-
.../schemaregion/utils/ResourceByPathUtils.java | 14 +-------------
.../dataregion/memtable/AlignedWritableMemChunk.java | 13 +++++++++++--
3 files changed, 14 insertions(+), 16 deletions(-)
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBTableViewQueryWithNotMatchedDataTypeIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBTableViewQueryWithNotMatchedDataTypeIT.java
index 1e342a13a4a..068942ad250 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBTableViewQueryWithNotMatchedDataTypeIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBTableViewQueryWithNotMatchedDataTypeIT.java
@@ -94,7 +94,8 @@ public class IoTDBTableViewQueryWithNotMatchedDataTypeIT {
public void test() throws IoTDBConnectionException,
StatementExecutionException {
try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
session.executeNonQueryStatement("USE " + DATABASE_NAME);
- SessionDataSet sessionDataSet = session.executeQueryStatement("select *
from view1");
+ SessionDataSet sessionDataSet =
+ session.executeQueryStatement("select * from view1 where current is
not null");
Assert.assertFalse(sessionDataSet.hasNext());
sessionDataSet.close();
}
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;
}