Skip to content

Commit 52da698

Browse files
authored
Fixed the NPE of TableDeviceLastEntry
1 parent 5933818 commit 52da698

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBDeletionTableIT.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,28 @@ public void testRangeDelete() throws SQLException {
356356
cleanData(4);
357357
}
358358

359+
@Test
360+
public void testSuccessfullyInvalidateCache() throws SQLException {
361+
prepareData(4, 1);
362+
try (Connection connection = EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
363+
Statement statement = connection.createStatement()) {
364+
statement.execute("use test");
365+
statement.executeQuery(
366+
"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'");
367+
368+
// [1, 400] -> [1, 299]
369+
statement.execute("DELETE FROM vehicle4 WHERE time >= 300");
370+
try (ResultSet set = statement.executeQuery("SELECT s0 FROM vehicle4")) {
371+
int cnt = 0;
372+
while (set.next()) {
373+
cnt++;
374+
}
375+
assertEquals(299, cnt);
376+
}
377+
}
378+
cleanData(4);
379+
}
380+
359381
@Test
360382
public void testFullDeleteWithoutWhereClause() throws SQLException {
361383
prepareData(5, 1);

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/cache/TableDeviceLastCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ int tryUpdate(
160160
"",
161161
(time, tvPair) ->
162162
tvPair.getTimestamp() < finalLastTime
163-
? new TimeValuePair(finalLastTime, null)
163+
? new TimeValuePair(finalLastTime, EMPTY_PRIMITIVE_TYPE)
164164
: tvPair);
165165
return diff.get();
166166
}

0 commit comments

Comments
 (0)