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

justinchen pushed a commit to branch rc/2.0.4
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/rc/2.0.4 by this push:
     new e8a25efa12d Fixed the bug that update / delete devices with no effect 
may end up changing all the devices
e8a25efa12d is described below

commit e8a25efa12d80c58d1664df33a832d23336f6ffc
Author: Caideyipi <[email protected]>
AuthorDate: Thu May 15 19:29:04 2025 +0800

    Fixed the bug that update / delete devices with no effect may end up 
changing all the devices
---
 .../iotdb/relational/it/schema/IoTDBDeviceIT.java  |   6 +
 .../config/executor/ClusterConfigTaskExecutor.java |   5 +
 .../relational/analyzer/StatementAnalyzer.java     |   7 +-
 .../fetcher/TableDeviceCacheAttributeGuard.java    |   4 +-
 .../metadata/fetcher/TableDeviceSchemaFetcher.java |   6 +-
 .../fetcher/TableDeviceSchemaValidator.java        |   6 +-
 .../plan/relational/sql/ast/DeleteDevice.java      |  18 ++-
 .../schemaregion/impl/SchemaRegionMemoryImpl.java  |   4 +-
 .../fetcher/cache/TableDeviceSchemaCacheTest.java  | 127 +++++++++++----------
 .../iotdb/commons/path/ExtendedPartialPath.java    |  12 ++
 10 files changed, 121 insertions(+), 74 deletions(-)

diff --git 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDeviceIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDeviceIT.java
index 578d807a6dd..7b023b4e9f6 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDeviceIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDeviceIT.java
@@ -226,6 +226,9 @@ public class IoTDBDeviceIT {
             e.getMessage());
       }
 
+      // Test filter with no effect
+      statement.execute("update table0 set model = null where model = 'A' and 
model = 'B'");
+
       // Test null
       statement.execute("update table0 set model = null where model <> 
substring(device_id, 1, 1)");
       TestUtils.assertResultSetEqual(
@@ -249,6 +252,9 @@ public class IoTDBDeviceIT {
       TestUtils.assertResultSetSize(
           statement.executeQuery("show devices from table0 offset 1 limit 1"), 
1);
 
+      // Test delete devices with no effect
+      statement.execute("delete devices from table0 where region_id = '1' and 
region_id = '2'");
+
       // Test delete devices
       statement.execute("delete devices from table0 where region_id = '1' and 
plant_id = '木兰'");
       TestUtils.assertResultSetSize(statement.executeQuery("show devices from 
table0"), 1);
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java
index cd930632bd6..d3b6a139455 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java
@@ -4049,6 +4049,11 @@ public class ClusterConfigTaskExecutor implements 
IConfigTaskExecutor {
   public SettableFuture<ConfigTaskResult> deleteDevice(
       final DeleteDevice deleteDevice, final String queryId, final SessionInfo 
sessionInfo) {
     final SettableFuture<ConfigTaskResult> future = SettableFuture.create();
+    if (!deleteDevice.isMayDeleteDevice()) {
+      DeleteDeviceTask.buildTSBlock(0, future);
+      return future;
+    }
+
     try (final ConfigNodeClient client =
         
CLUSTER_DELETION_CONFIG_NODE_CLIENT_MANAGER.borrowClient(ConfigNodeInfo.CONFIG_REGION_ID))
 {
 
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/StatementAnalyzer.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/StatementAnalyzer.java
index 4db6547bb6e..c8c95d1cc7e 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/StatementAnalyzer.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/StatementAnalyzer.java
@@ -473,7 +473,7 @@ public class StatementAnalyzer {
       final TranslationMap translationMap = analyzeTraverseDevice(node, 
context, true);
       final TsTable table =
           DataNodeTableCache.getInstance().getTable(node.getDatabase(), 
node.getTableName());
-      node.parseRawExpression(
+      if (!node.parseRawExpression(
           null,
           table,
           table.getColumnList().stream()
@@ -482,7 +482,10 @@ public class StatementAnalyzer {
                       
columnSchema.getColumnCategory().equals(TsTableColumnCategory.ATTRIBUTE))
               .map(TsTableColumnSchema::getColumnName)
               .collect(Collectors.toList()),
-          queryContext);
+          queryContext)) {
+        analysis.setFinishQueryAfterAnalyze();
+        return null;
+      }
 
       // If node.location is absent, this is a pipe-transferred update, namely 
the assignments are
       // already parsed at the sender
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableDeviceCacheAttributeGuard.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableDeviceCacheAttributeGuard.java
index 45aee85fda3..5710aeee724 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableDeviceCacheAttributeGuard.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableDeviceCacheAttributeGuard.java
@@ -39,7 +39,7 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.LinkedBlockingDeque;
 import java.util.stream.Collectors;
 
-import static 
org.apache.iotdb.db.queryengine.plan.relational.metadata.fetcher.TableDeviceSchemaFetcher.convertIdValuesToDeviceID;
+import static 
org.apache.iotdb.db.queryengine.plan.relational.metadata.fetcher.TableDeviceSchemaFetcher.convertTagValuesToDeviceID;
 
 public class TableDeviceCacheAttributeGuard {
 
@@ -147,7 +147,7 @@ public class TableDeviceCacheAttributeGuard {
                       (nodes, attributes) ->
                           cache.updateAttributes(
                               database,
-                              convertIdValuesToDeviceID(table, 
nodes.toArray(new String[0])),
+                              convertTagValuesToDeviceID(table, 
nodes.toArray(new String[0])),
                               attributes)));
     } else {
       ((UpdateClearContainer) container)
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableDeviceSchemaFetcher.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableDeviceSchemaFetcher.java
index 18228b1a86d..04517b176b8 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableDeviceSchemaFetcher.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableDeviceSchemaFetcher.java
@@ -205,7 +205,7 @@ public class TableDeviceSchemaFetcher {
   }
 
   // Used by show/count device and update device.
-  // Update device will not access cache
+  // Update / Delete device will not access cache
   public boolean parseFilter4TraverseDevice(
       final String database,
       final TsTable tableInstance,
@@ -337,7 +337,7 @@ public class TableDeviceSchemaFetcher {
       idValues[idFilter.getIndex()] = ((PreciseFilter) childFilter).getValue();
     }
 
-    final IDeviceID deviceID = 
convertIdValuesToDeviceID(tableInstance.getTableName(), idValues);
+    final IDeviceID deviceID = 
convertTagValuesToDeviceID(tableInstance.getTableName(), idValues);
     final Map<String, Binary> attributeMap = 
cache.getDeviceAttribute(database, deviceID);
 
     // 1. AttributeMap == null means cache miss
@@ -370,7 +370,7 @@ public class TableDeviceSchemaFetcher {
     return true;
   }
 
-  public static IDeviceID convertIdValuesToDeviceID(
+  public static IDeviceID convertTagValuesToDeviceID(
       final String tableName, final String[] idValues) {
     // Convert to IDeviceID
     final String[] deviceIdNodes = new String[idValues.length + 1];
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableDeviceSchemaValidator.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableDeviceSchemaValidator.java
index 466033864a2..7d0e827d75b 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableDeviceSchemaValidator.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableDeviceSchemaValidator.java
@@ -46,7 +46,7 @@ import java.util.Map;
 import java.util.Objects;
 import java.util.stream.Collectors;
 
-import static 
org.apache.iotdb.db.queryengine.plan.relational.metadata.fetcher.TableDeviceSchemaFetcher.convertIdValuesToDeviceID;
+import static 
org.apache.iotdb.db.queryengine.plan.relational.metadata.fetcher.TableDeviceSchemaFetcher.convertTagValuesToDeviceID;
 
 public class TableDeviceSchemaValidator {
   private final SqlParser relationSqlParser = new SqlParser();
@@ -127,7 +127,7 @@ public class TableDeviceSchemaValidator {
           TableDeviceSchemaCache.getInstance()
               .getDeviceAttribute(
                   schemaValidation.getDatabase(),
-                  convertIdValuesToDeviceID(
+                  convertTagValuesToDeviceID(
                       schemaValidation.getTableName(), (String[]) 
deviceIdList.get(i)));
       if (attributeMap == null) {
         result.missingDeviceIndexList.add(i);
@@ -165,7 +165,7 @@ public class TableDeviceSchemaValidator {
     for (final int index : previousValidateResult.missingDeviceIndexList) {
       final Map<String, Binary> attributeMap =
           fetchedDeviceSchema.get(
-              convertIdValuesToDeviceID(
+              convertTagValuesToDeviceID(
                   schemaValidation.getTableName(), (String[]) 
deviceIdList.get(index)));
       if (attributeMap == null) {
         result.missingDeviceIndexList.add(index);
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/DeleteDevice.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/DeleteDevice.java
index 34cecc64e1c..3130128e23a 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/DeleteDevice.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/DeleteDevice.java
@@ -24,6 +24,7 @@ import org.apache.iotdb.commons.schema.column.ColumnHeader;
 import org.apache.iotdb.commons.schema.filter.SchemaFilter;
 import org.apache.iotdb.commons.schema.table.TsTable;
 import org.apache.iotdb.commons.schema.table.column.TsTableColumnSchema;
+import org.apache.iotdb.db.queryengine.common.MPPQueryContext;
 import org.apache.iotdb.db.queryengine.common.SessionInfo;
 import 
org.apache.iotdb.db.queryengine.execution.operator.schema.source.DeviceBlackListConstructor;
 import 
org.apache.iotdb.db.queryengine.execution.operator.schema.source.TableDeviceQuerySource;
@@ -32,6 +33,7 @@ import 
org.apache.iotdb.db.queryengine.plan.analyze.AnalyzeUtils;
 import org.apache.iotdb.db.queryengine.plan.analyze.TypeProvider;
 import org.apache.iotdb.db.queryengine.plan.planner.LocalExecutionPlanner;
 import 
org.apache.iotdb.db.queryengine.plan.planner.plan.parameter.InputLocation;
+import org.apache.iotdb.db.queryengine.plan.relational.metadata.DeviceEntry;
 import org.apache.iotdb.db.queryengine.plan.relational.metadata.Metadata;
 import org.apache.iotdb.db.queryengine.plan.relational.planner.Symbol;
 import 
org.apache.iotdb.db.queryengine.transformation.dag.column.ColumnTransformer;
@@ -65,13 +67,27 @@ public class DeleteDevice extends AbstractTraverseDevice {
 
   // Used for data deletion
   private List<TableDeletionEntry> modEntries;
+  private boolean mayDeleteDevice;
 
   public DeleteDevice(final NodeLocation location, final Table table, final 
Expression where) {
     super(location, table, where);
   }
 
+  @Override
+  public boolean parseRawExpression(
+      final Map<String, List<DeviceEntry>> entries,
+      final TsTable tableInstance,
+      final List<String> attributeColumns,
+      final MPPQueryContext context) {
+    return mayDeleteDevice =
+        super.parseRawExpression(entries, tableInstance, attributeColumns, 
context);
+  }
+
+  public boolean isMayDeleteDevice() {
+    return mayDeleteDevice;
+  }
+
   public void parseModEntries(final TsTable table) {
-    // TODO: Fallback to precise devices if modEnries parsing failure 
encountered
     modEntries = AnalyzeUtils.parseExpressions2ModEntries(where, table);
   }
 
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/impl/SchemaRegionMemoryImpl.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/impl/SchemaRegionMemoryImpl.java
index 8eb8d2e0a7f..f09a900522a 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/impl/SchemaRegionMemoryImpl.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/impl/SchemaRegionMemoryImpl.java
@@ -152,7 +152,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 
 import static 
org.apache.iotdb.db.queryengine.plan.planner.TableOperatorGenerator.makeLayout;
-import static 
org.apache.iotdb.db.queryengine.plan.relational.metadata.fetcher.TableDeviceSchemaFetcher.convertIdValuesToDeviceID;
+import static 
org.apache.iotdb.db.queryengine.plan.relational.metadata.fetcher.TableDeviceSchemaFetcher.convertTagValuesToDeviceID;
 import static org.apache.tsfile.common.constant.TsFileConstant.PATH_SEPARATOR;
 
 /**
@@ -1449,7 +1449,7 @@ public class SchemaRegionMemoryImpl implements 
ISchemaRegion {
     if (!isRecovering) {
       TableDeviceSchemaCache.getInstance()
           .updateAttributes(
-              databaseName, convertIdValuesToDeviceID(tableName, deviceId), 
resultMap);
+              databaseName, convertTagValuesToDeviceID(tableName, deviceId), 
resultMap);
     }
     deviceAttributeCacheUpdater.update(tableName, deviceId, resultMap);
   }
diff --git 
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/cache/TableDeviceSchemaCacheTest.java
 
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/cache/TableDeviceSchemaCacheTest.java
index 2a22c20d832..a439baa46e7 100644
--- 
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/cache/TableDeviceSchemaCacheTest.java
+++ 
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/cache/TableDeviceSchemaCacheTest.java
@@ -54,7 +54,7 @@ import java.util.Optional;
 import java.util.OptionalLong;
 import java.util.concurrent.ConcurrentHashMap;
 
-import static 
org.apache.iotdb.db.queryengine.plan.relational.metadata.fetcher.TableDeviceSchemaFetcher.convertIdValuesToDeviceID;
+import static 
org.apache.iotdb.db.queryengine.plan.relational.metadata.fetcher.TableDeviceSchemaFetcher.convertTagValuesToDeviceID;
 
 public class TableDeviceSchemaCacheTest {
 
@@ -180,72 +180,74 @@ public class TableDeviceSchemaCacheTest {
     attributeMap.put(attributeName2, new Binary("monthly", 
TSFileConfig.STRING_CHARSET));
     cache.putAttributes(
         database1,
-        convertIdValuesToDeviceID(table1, new String[] {"hebei", "p_1", 
"d_0"}),
+        convertTagValuesToDeviceID(table1, new String[] {"hebei", "p_1", 
"d_0"}),
         new ConcurrentHashMap<>(attributeMap));
     Assert.assertEquals(
         attributeMap,
         cache.getDeviceAttribute(
-            database1, convertIdValuesToDeviceID(table1, new String[] 
{"hebei", "p_1", "d_0"})));
+            database1, convertTagValuesToDeviceID(table1, new String[] 
{"hebei", "p_1", "d_0"})));
     Assert.assertNull(
         cache.getDeviceAttribute(
-            database1, convertIdValuesToDeviceID(table1, new String[] 
{"hebei", "p_1", "d_1"})));
+            database1, convertTagValuesToDeviceID(table1, new String[] 
{"hebei", "p_1", "d_1"})));
 
     attributeMap.put(attributeName1, new Binary("old", 
TSFileConfig.STRING_CHARSET));
     cache.putAttributes(
         database1,
-        convertIdValuesToDeviceID(table1, new String[] {"hebei", "p_1", 
"d_1"}),
+        convertTagValuesToDeviceID(table1, new String[] {"hebei", "p_1", 
"d_1"}),
         new HashMap<>(attributeMap));
     Assert.assertEquals(
         attributeMap,
         cache.getDeviceAttribute(
-            database1, convertIdValuesToDeviceID(table1, new String[] 
{"hebei", "p_1", "d_1"})));
+            database1, convertTagValuesToDeviceID(table1, new String[] 
{"hebei", "p_1", "d_1"})));
 
     attributeMap.put(attributeName2, new Binary("daily", 
TSFileConfig.STRING_CHARSET));
     cache.putAttributes(
         database1,
-        convertIdValuesToDeviceID(table1, new String[] {"shandong", "p_1", 
"d_1"}),
+        convertTagValuesToDeviceID(table1, new String[] {"shandong", "p_1", 
"d_1"}),
         new ConcurrentHashMap<>(attributeMap));
     Assert.assertNull(
         cache.getDeviceAttribute(
-            database1, convertIdValuesToDeviceID(table1, new String[] 
{"hebei", "p_1", "d_0"})));
+            database1, convertTagValuesToDeviceID(table1, new String[] 
{"hebei", "p_1", "d_0"})));
     Assert.assertEquals(
         attributeMap,
         cache.getDeviceAttribute(
-            database1, convertIdValuesToDeviceID(table1, new String[] 
{"shandong", "p_1", "d_1"})));
+            database1,
+            convertTagValuesToDeviceID(table1, new String[] {"shandong", 
"p_1", "d_1"})));
 
     final String table2 = "t2";
     attributeMap.put(attributeName1, new Binary("new", 
TSFileConfig.STRING_CHARSET));
     attributeMap.put(attributeName2, new Binary("monthly", 
TSFileConfig.STRING_CHARSET));
     cache.putAttributes(
         database1,
-        convertIdValuesToDeviceID(table2, new String[] {"hebei", "p_1", 
"d_0"}),
+        convertTagValuesToDeviceID(table2, new String[] {"hebei", "p_1", 
"d_0"}),
         new ConcurrentHashMap<>(attributeMap));
     Assert.assertEquals(
         attributeMap,
         cache.getDeviceAttribute(
-            database1, convertIdValuesToDeviceID(table2, new String[] 
{"hebei", "p_1", "d_0"})));
+            database1, convertTagValuesToDeviceID(table2, new String[] 
{"hebei", "p_1", "d_0"})));
     Assert.assertNull(
         cache.getDeviceAttribute(
-            database1, convertIdValuesToDeviceID(table1, new String[] 
{"hebei", "p_1", "d_1"})));
+            database1, convertTagValuesToDeviceID(table1, new String[] 
{"hebei", "p_1", "d_1"})));
 
     attributeMap.put("type", new Binary("old", TSFileConfig.STRING_CHARSET));
     cache.putAttributes(
         database1,
-        convertIdValuesToDeviceID(table2, new String[] {"hebei", "p_1", 
"d_1"}),
+        convertTagValuesToDeviceID(table2, new String[] {"hebei", "p_1", 
"d_1"}),
         new ConcurrentHashMap<>(attributeMap));
     Assert.assertEquals(
         attributeMap,
         cache.getDeviceAttribute(
-            database1, convertIdValuesToDeviceID(table2, new String[] 
{"hebei", "p_1", "d_1"})));
+            database1, convertTagValuesToDeviceID(table2, new String[] 
{"hebei", "p_1", "d_1"})));
     Assert.assertNull(
         cache.getDeviceAttribute(
-            database1, convertIdValuesToDeviceID(table1, new String[] 
{"shandong", "p_1", "d_1"})));
+            database1,
+            convertTagValuesToDeviceID(table1, new String[] {"shandong", 
"p_1", "d_1"})));
 
     cache.invalidateAttributes(
-        database1, convertIdValuesToDeviceID(table2, new String[] {"hebei", 
"p_1", "d_1"}));
+        database1, convertTagValuesToDeviceID(table2, new String[] {"hebei", 
"p_1", "d_1"}));
     Assert.assertNull(
         cache.getDeviceAttribute(
-            database1, convertIdValuesToDeviceID(table2, new String[] 
{"hebei", "p_1", "d_1"})));
+            database1, convertTagValuesToDeviceID(table2, new String[] 
{"hebei", "p_1", "d_1"})));
   }
 
   @Test
@@ -256,12 +258,12 @@ public class TableDeviceSchemaCacheTest {
 
     // Test get from empty cache
     Assert.assertNull(
-        cache.getLastEntry(database1, convertIdValuesToDeviceID(table1, 
device0), "s0"));
+        cache.getLastEntry(database1, convertTagValuesToDeviceID(table1, 
device0), "s0"));
     Assert.assertFalse(
         cache
             .getLastRow(
                 database1,
-                convertIdValuesToDeviceID(table1, device0),
+                convertTagValuesToDeviceID(table1, device0),
                 "s0",
                 Collections.singletonList("s1"))
             .isPresent());
@@ -269,7 +271,7 @@ public class TableDeviceSchemaCacheTest {
         cache
             .getLastRow(
                 database1,
-                convertIdValuesToDeviceID(table1, device0),
+                convertTagValuesToDeviceID(table1, device0),
                 "",
                 Collections.singletonList("s1"))
             .isPresent());
@@ -283,65 +285,65 @@ public class TableDeviceSchemaCacheTest {
     updateLastCache4Query(
         cache,
         database1,
-        convertIdValuesToDeviceID(table1, device0),
+        convertTagValuesToDeviceID(table1, device0),
         new String[] {"s0", "s1", "s2"},
         new TimeValuePair[] {tv0, tv1, tv2});
 
     Assert.assertEquals(
-        tv0, cache.getLastEntry(database1, convertIdValuesToDeviceID(table1, 
device0), "s0"));
+        tv0, cache.getLastEntry(database1, convertTagValuesToDeviceID(table1, 
device0), "s0"));
     Assert.assertEquals(
-        tv1, cache.getLastEntry(database1, convertIdValuesToDeviceID(table1, 
device0), "s1"));
+        tv1, cache.getLastEntry(database1, convertTagValuesToDeviceID(table1, 
device0), "s1"));
     Assert.assertEquals(
-        tv2, cache.getLastEntry(database1, convertIdValuesToDeviceID(table1, 
device0), "s2"));
+        tv2, cache.getLastEntry(database1, convertTagValuesToDeviceID(table1, 
device0), "s2"));
 
     // Write update existing
     final TimeValuePair tv3 = new TimeValuePair(1L, new 
TsPrimitiveType.TsInt(3));
 
     cache.updateLastCacheIfExists(
         database1,
-        convertIdValuesToDeviceID(table1, device0),
+        convertTagValuesToDeviceID(table1, device0),
         new String[] {"s0", "s1", "s2", "s3"},
         new TimeValuePair[] {tv3, tv3, tv3, tv3});
 
     Assert.assertEquals(
-        tv3, cache.getLastEntry(database1, convertIdValuesToDeviceID(table1, 
device0), "s0"));
+        tv3, cache.getLastEntry(database1, convertTagValuesToDeviceID(table1, 
device0), "s0"));
     Assert.assertEquals(
-        tv3, cache.getLastEntry(database1, convertIdValuesToDeviceID(table1, 
device0), "s1"));
+        tv3, cache.getLastEntry(database1, convertTagValuesToDeviceID(table1, 
device0), "s1"));
     Assert.assertEquals(
-        tv2, cache.getLastEntry(database1, convertIdValuesToDeviceID(table1, 
device0), "s2"));
+        tv2, cache.getLastEntry(database1, convertTagValuesToDeviceID(table1, 
device0), "s2"));
     Assert.assertNull(
-        cache.getLastEntry(database1, convertIdValuesToDeviceID(table1, 
device0), "s3"));
+        cache.getLastEntry(database1, convertTagValuesToDeviceID(table1, 
device0), "s3"));
 
     // Test null hit measurements
     cache.initOrInvalidateLastCache(
-        database1, convertIdValuesToDeviceID(table1, device0), new String[] 
{"s4"}, false);
+        database1, convertTagValuesToDeviceID(table1, device0), new String[] 
{"s4"}, false);
 
     // Miss if the "null" time value pair is not in cache, meaning that the
     // entry is evicted
     Assert.assertNull(
-        cache.getLastEntry(database1, convertIdValuesToDeviceID(table1, 
device0), "s4"));
+        cache.getLastEntry(database1, convertTagValuesToDeviceID(table1, 
device0), "s4"));
 
     // Common query
     updateLastCache4Query(
         cache,
         database1,
-        convertIdValuesToDeviceID(table1, device0),
+        convertTagValuesToDeviceID(table1, device0),
         new String[] {"s4"},
         new TimeValuePair[] {TableDeviceLastCache.EMPTY_TIME_VALUE_PAIR});
 
     Assert.assertSame(
         TableDeviceLastCache.EMPTY_TIME_VALUE_PAIR,
-        cache.getLastEntry(database1, convertIdValuesToDeviceID(table1, 
device0), "s4"));
+        cache.getLastEntry(database1, convertTagValuesToDeviceID(table1, 
device0), "s4"));
 
     // Test null miss measurements
     Assert.assertNull(
-        cache.getLastEntry(database1, convertIdValuesToDeviceID(table1, 
device0), "s5"));
+        cache.getLastEntry(database1, convertTagValuesToDeviceID(table1, 
device0), "s5"));
 
     // Test lastRow
     Optional<Pair<OptionalLong, TsPrimitiveType[]>> result =
         cache.getLastRow(
             database1,
-            convertIdValuesToDeviceID(table1, device0),
+            convertTagValuesToDeviceID(table1, device0),
             "",
             Collections.singletonList("s2"));
     Assert.assertFalse(result.isPresent());
@@ -349,14 +351,14 @@ public class TableDeviceSchemaCacheTest {
     updateLastCache4Query(
         cache,
         database1,
-        convertIdValuesToDeviceID(table1, device0),
+        convertTagValuesToDeviceID(table1, device0),
         new String[] {""},
         new TimeValuePair[] {new TimeValuePair(2L, 
TableDeviceLastCache.EMPTY_PRIMITIVE_TYPE)});
 
     result =
         cache.getLastRow(
             database1,
-            convertIdValuesToDeviceID(table1, device0),
+            convertTagValuesToDeviceID(table1, device0),
             "",
             Collections.singletonList("s2"));
     Assert.assertTrue(result.isPresent());
@@ -368,7 +370,7 @@ public class TableDeviceSchemaCacheTest {
     result =
         cache.getLastRow(
             database1,
-            convertIdValuesToDeviceID(table1, device0),
+            convertTagValuesToDeviceID(table1, device0),
             "s0",
             Arrays.asList("s0", "", "s1", "s4", "s5"));
     Assert.assertTrue(result.isPresent());
@@ -388,7 +390,7 @@ public class TableDeviceSchemaCacheTest {
     result =
         cache.getLastRow(
             database1,
-            convertIdValuesToDeviceID(table1, device0),
+            convertTagValuesToDeviceID(table1, device0),
             "s4",
             Arrays.asList("s0", "s1", "s5"));
     Assert.assertTrue(result.isPresent());
@@ -398,16 +400,16 @@ public class TableDeviceSchemaCacheTest {
         cache
             .getLastRow(
                 database1,
-                convertIdValuesToDeviceID(table1, device0),
+                convertTagValuesToDeviceID(table1, device0),
                 "s5",
                 Arrays.asList("s0", "s1", "s5"))
             .isPresent());
 
     final String table2 = "t2";
-    cache.invalidateLastCache(database1, convertIdValuesToDeviceID(table1, 
device0));
+    cache.invalidateLastCache(database1, convertTagValuesToDeviceID(table1, 
device0));
     cache.invalidate(database1);
     Assert.assertNull(
-        cache.getLastEntry(database1, convertIdValuesToDeviceID(table1, 
device0), "s2"));
+        cache.getLastEntry(database1, convertTagValuesToDeviceID(table1, 
device0), "s2"));
 
     // Invalidate table
     final String[] device1 = new String[] {"hebei", "p_1", "d_1"};
@@ -419,38 +421,38 @@ public class TableDeviceSchemaCacheTest {
     updateLastCache4Query(
         cache,
         database1,
-        convertIdValuesToDeviceID(table2, device0),
+        convertTagValuesToDeviceID(table2, device0),
         tempMeasurements,
         tempTimeValuePairs);
     updateLastCache4Query(
         cache,
         database1,
-        convertIdValuesToDeviceID(table2, device1),
+        convertTagValuesToDeviceID(table2, device1),
         tempMeasurements,
         tempTimeValuePairs);
     updateLastCache4Query(
         cache,
         database1,
-        convertIdValuesToDeviceID(table2, device2),
+        convertTagValuesToDeviceID(table2, device2),
         tempMeasurements,
         tempTimeValuePairs);
 
     // Test cache eviction
     Assert.assertNull(
-        cache.getLastEntry(database1, convertIdValuesToDeviceID(table2, 
device0), "s2"));
+        cache.getLastEntry(database1, convertTagValuesToDeviceID(table2, 
device0), "s2"));
 
     cache.invalidateLastCache(database1, table2);
 
     Assert.assertNull(
-        cache.getLastEntry(database1, convertIdValuesToDeviceID(table2, 
device1), "s2"));
+        cache.getLastEntry(database1, convertTagValuesToDeviceID(table2, 
device1), "s2"));
     Assert.assertNull(
-        cache.getLastEntry(database1, convertIdValuesToDeviceID(table2, 
device2), "s2"));
+        cache.getLastEntry(database1, convertTagValuesToDeviceID(table2, 
device2), "s2"));
 
     // Test Long.MIN_VALUE
     updateLastCache4Query(
         cache,
         database1,
-        convertIdValuesToDeviceID(table2, device0),
+        convertTagValuesToDeviceID(table2, device0),
         new String[] {"", "s2"},
         new TimeValuePair[] {
           new TimeValuePair(Long.MIN_VALUE, 
TableDeviceLastCache.EMPTY_PRIMITIVE_TYPE),
@@ -459,7 +461,7 @@ public class TableDeviceSchemaCacheTest {
 
     result =
         cache.getLastRow(
-            database1, convertIdValuesToDeviceID(table2, device0), "", 
Arrays.asList("s2", "s3"));
+            database1, convertTagValuesToDeviceID(table2, device0), "", 
Arrays.asList("s2", "s3"));
     Assert.assertTrue(result.isPresent());
     Assert.assertTrue(result.get().getLeft().isPresent());
     Assert.assertEquals(OptionalLong.of(Long.MIN_VALUE), 
result.get().getLeft());
@@ -470,13 +472,16 @@ public class TableDeviceSchemaCacheTest {
     updateLastCache4Query(
         cache,
         database1,
-        convertIdValuesToDeviceID(table2, device0),
+        convertTagValuesToDeviceID(table2, device0),
         new String[] {"s3"},
         new TimeValuePair[] {new TimeValuePair(Long.MIN_VALUE, new 
TsPrimitiveType.TsInt(3))});
 
     result =
         cache.getLastRow(
-            database1, convertIdValuesToDeviceID(table2, device0), "s3", 
Arrays.asList("s2", "s3"));
+            database1,
+            convertTagValuesToDeviceID(table2, device0),
+            "s3",
+            Arrays.asList("s2", "s3"));
     Assert.assertTrue(result.isPresent());
     Assert.assertTrue(result.get().getLeft().isPresent());
     Assert.assertEquals(OptionalLong.of(Long.MIN_VALUE), 
result.get().getLeft());
@@ -488,7 +493,7 @@ public class TableDeviceSchemaCacheTest {
 
     result =
         cache.getLastRow(
-            database1, convertIdValuesToDeviceID(table2, device0), "", 
Arrays.asList("s2", "s3"));
+            database1, convertTagValuesToDeviceID(table2, device0), "", 
Arrays.asList("s2", "s3"));
     Assert.assertTrue(result.isPresent());
     Assert.assertTrue(result.get().getLeft().isPresent());
     Assert.assertEquals(OptionalLong.of(Long.MIN_VALUE), 
result.get().getLeft());
@@ -513,36 +518,36 @@ public class TableDeviceSchemaCacheTest {
 
     cache.updateLastCacheIfExists(
         database1,
-        convertIdValuesToDeviceID(table2, device0),
+        convertTagValuesToDeviceID(table2, device0),
         testMeasurements,
         testTimeValuePairs);
     cache.updateLastCacheIfExists(
         database2,
-        convertIdValuesToDeviceID(table1, device0),
+        convertTagValuesToDeviceID(table1, device0),
         testMeasurements,
         testTimeValuePairs);
 
     Assert.assertNull(
-        cache.getLastEntry(database1, convertIdValuesToDeviceID(table2, 
device0), "s2"));
+        cache.getLastEntry(database1, convertTagValuesToDeviceID(table2, 
device0), "s2"));
     Assert.assertNull(
-        cache.getLastEntry(database2, convertIdValuesToDeviceID(table1, 
device0), "s2"));
+        cache.getLastEntry(database2, convertTagValuesToDeviceID(table1, 
device0), "s2"));
 
     updateLastCache4Query(
         cache,
         database1,
-        convertIdValuesToDeviceID(table1, device0),
+        convertTagValuesToDeviceID(table1, device0),
         new String[] {"s0"},
         new TimeValuePair[] {new TimeValuePair(0L, new 
TsPrimitiveType.TsInt(2))});
     cache.updateLastCacheIfExists(
         database1,
-        convertIdValuesToDeviceID(table1, device0),
+        convertTagValuesToDeviceID(table1, device0),
         testMeasurements,
         testTimeValuePairs);
 
     Assert.assertEquals(
-        tv3, cache.getLastEntry(database1, convertIdValuesToDeviceID(table1, 
device0), "s0"));
+        tv3, cache.getLastEntry(database1, convertTagValuesToDeviceID(table1, 
device0), "s0"));
     Assert.assertNull(
-        cache.getLastEntry(database1, convertIdValuesToDeviceID(table1, 
device0), "s2"));
+        cache.getLastEntry(database1, convertTagValuesToDeviceID(table1, 
device0), "s2"));
   }
 
   private void updateLastCache4Query(
diff --git 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/path/ExtendedPartialPath.java
 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/path/ExtendedPartialPath.java
index 18fa1db23ef..04a8cf7b4db 100644
--- 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/path/ExtendedPartialPath.java
+++ 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/path/ExtendedPartialPath.java
@@ -46,4 +46,16 @@ public class ExtendedPartialPath extends PartialPath {
   public boolean isNormalPath() {
     return matchFunctions.isEmpty();
   }
+
+  @Override
+  public String toString() {
+    return "ExtendedPartialPath{"
+        + "fullPath="
+        + getFullPath()
+        + ", matchFunctions="
+        + matchFunctions
+        + ", isRestrict="
+        + isRestrict
+        + '}';
+  }
 }

Reply via email to