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 52da69813b0 Fixed the NPE of TableDeviceLastEntry
52da69813b0 is described below

commit 52da69813b0223c80e854321e048efd9736767ae
Author: Caideyipi <[email protected]>
AuthorDate: Fri Jan 24 14:13:48 2025 +0800

    Fixed the NPE of TableDeviceLastEntry
---
 .../relational/it/db/it/IoTDBDeletionTableIT.java  | 22 ++++++++++++++++++++++
 .../fetcher/cache/TableDeviceLastCache.java        |  2 +-
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBDeletionTableIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBDeletionTableIT.java
index c63a76e09f8..95eee41d007 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBDeletionTableIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBDeletionTableIT.java
@@ -356,6 +356,28 @@ public class IoTDBDeletionTableIT {
     cleanData(4);
   }
 
+  @Test
+  public void testSuccessfullyInvalidateCache() throws SQLException {
+    prepareData(4, 1);
+    try (Connection connection = 
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+        Statement statement = connection.createStatement()) {
+      statement.execute("use test");
+      statement.executeQuery(
+          "SELECT last(time), last_by(s0,time), last_by(s1,time), 
last_by(s2,time), last_by(s3,time), last_by(s4,time) FROM vehicle4 where 
deviceId = 'd0'");
+
+      // [1, 400] -> [1, 299]
+      statement.execute("DELETE FROM vehicle4 WHERE time >= 300");
+      try (ResultSet set = statement.executeQuery("SELECT s0 FROM vehicle4")) {
+        int cnt = 0;
+        while (set.next()) {
+          cnt++;
+        }
+        assertEquals(299, cnt);
+      }
+    }
+    cleanData(4);
+  }
+
   @Test
   public void testFullDeleteWithoutWhereClause() throws SQLException {
     prepareData(5, 1);
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/cache/TableDeviceLastCache.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/cache/TableDeviceLastCache.java
index 3f3c1d2a053..5bf81970987 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/cache/TableDeviceLastCache.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/cache/TableDeviceLastCache.java
@@ -160,7 +160,7 @@ public class TableDeviceLastCache {
         "",
         (time, tvPair) ->
             tvPair.getTimestamp() < finalLastTime
-                ? new TimeValuePair(finalLastTime, null)
+                ? new TimeValuePair(finalLastTime, EMPTY_PRIMITIVE_TYPE)
                 : tvPair);
     return diff.get();
   }

Reply via email to