This is an automated email from the ASF dual-hosted git repository.
jiangtian 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 ec06abee8fc Fix template extension with null value (#15103)
ec06abee8fc is described below
commit ec06abee8fc9d8034b570051585b77f253ce9316
Author: Jiang Tian <[email protected]>
AuthorDate: Tue Mar 18 09:30:52 2025 +0800
Fix template extension with null value (#15103)
---
.../org/apache/iotdb/db/it/schema/IoTDBExtendTemplateIT.java | 7 +++++++
.../plan/analyze/schema/TemplateSchemaFetcher.java | 11 +++++++++--
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git
a/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBExtendTemplateIT.java
b/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBExtendTemplateIT.java
index 9945843b091..f3d53c3a461 100644
---
a/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBExtendTemplateIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBExtendTemplateIT.java
@@ -142,10 +142,15 @@ public class IoTDBExtendTemplateIT extends
AbstractSchemaIT {
statement.execute("SET DEVICE TEMPLATE t1 to root.db");
+ // single-row insertion
statement.execute("INSERT INTO root.db.d1(time, s1, s3) values(1, 1,
1)");
statement.execute("INSERT INTO root.db.d2(time, s4, s5) values(1, 1,
1)");
statement.execute("INSERT INTO root.db1.d1(time, s2, s3) values(1, 1,
1)");
+ // multi-row insertion with null
+ statement.execute(
+ "INSERT INTO root.db.d1(time, s1, s6) values(1, 1, 1), (2, 2, null),
(3, 3, 3)");
+
String[] sqls =
new String[] {
"show timeseries",
@@ -159,11 +164,13 @@ public class IoTDBExtendTemplateIT extends
AbstractSchemaIT {
"root.db.d1.s3,null,root.db,DOUBLE,GORILLA,LZ4,null,null,null,null,BASE,",
"root.db.d1.s4,null,root.db,DOUBLE,GORILLA,LZ4,null,null,null,null,BASE,",
"root.db.d1.s5,null,root.db,DOUBLE,GORILLA,LZ4,null,null,null,null,BASE,",
+
"root.db.d1.s6,null,root.db,DOUBLE,GORILLA,LZ4,null,null,null,null,BASE,",
"root.db.d2.s1,null,root.db,INT64,PLAIN,LZ4,null,null,null,null,BASE,",
"root.db.d2.s2,null,root.db,DOUBLE,RLE,LZ4,null,null,null,null,BASE,",
"root.db.d2.s3,null,root.db,DOUBLE,GORILLA,LZ4,null,null,null,null,BASE,",
"root.db.d2.s4,null,root.db,DOUBLE,GORILLA,LZ4,null,null,null,null,BASE,",
"root.db.d2.s5,null,root.db,DOUBLE,GORILLA,LZ4,null,null,null,null,BASE,",
+
"root.db.d2.s6,null,root.db,DOUBLE,GORILLA,LZ4,null,null,null,null,BASE,",
"root.db1.d1.s2,null,root.db1,DOUBLE,GORILLA,LZ4,null,null,null,null,BASE,",
"root.db1.d1.s3,null,root.db1,DOUBLE,GORILLA,LZ4,null,null,null,null,BASE,"))
};
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/TemplateSchemaFetcher.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/TemplateSchemaFetcher.java
index 3ce3fde5569..3516182bbf1 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/TemplateSchemaFetcher.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/TemplateSchemaFetcher.java
@@ -142,12 +142,19 @@ class TemplateSchemaFetcher {
measurements = schemaComputationWithAutoCreation.getMeasurements();
for (int j = 0; j < measurements.length; j++) {
if (!template.hasSchema(measurements[j])) {
+ TSDataType dataType =
schemaComputationWithAutoCreation.getDataType(j);
+ if (dataType == null) {
+ // the data type is not provided and cannot be inferred (the value
is also null),
+ // skip this measurement
+ continue;
+ }
+
extensionMeasurementMap
.computeIfAbsent(template.getName(), TemplateExtendInfo::new)
.addMeasurement(
measurements[j],
- schemaComputationWithAutoCreation.getDataType(j),
-
getDefaultEncoding(schemaComputationWithAutoCreation.getDataType(j)),
+ dataType,
+ getDefaultEncoding(dataType),
TSFileDescriptor.getInstance().getConfig().getCompressor());
}
}