Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
9aa0e6d
partial
Caideyipi May 19, 2025
69328e5
Partial
Caideyipi May 19, 2025
c2adf08
Update confignode.thrift
Caideyipi May 19, 2025
741589f
table schema
Caideyipi May 19, 2025
a25d674
Update CreateTableProcedure.java
Caideyipi May 19, 2025
b78baa4
Partial
Caideyipi May 19, 2025
6c8d342
Update ConfigMTree.java
Caideyipi May 19, 2025
fd526e3
Update confignode.thrift
Caideyipi May 19, 2025
abf7572
Partial
Caideyipi May 19, 2025
36cb154
Update ShowCreateTableTask.java
Caideyipi May 19, 2025
832dc6a
Update ShowCreateViewTask.java
Caideyipi May 19, 2025
0d49ba8
partial
Caideyipi May 19, 2025
eedbd1c
Update InformationSchemaUtils.java
Caideyipi May 19, 2025
51aa84d
Partial
Caideyipi May 19, 2025
4e98a2d
Partial
Caideyipi May 20, 2025
e6993aa
Partial
Caideyipi May 20, 2025
8669113
Merge branch 'master' of https://github.com/apache/iotdb into need_la…
Caideyipi May 20, 2025
9f35a60
partial
Caideyipi May 20, 2025
678c34d
Update IdentifierParser.g4
Caideyipi May 20, 2025
d54543a
partial
Caideyipi May 20, 2025
2b51fa2
Partial
Caideyipi May 20, 2025
b3c70ad
Update IoTDBTableIT.java
Caideyipi May 20, 2025
ce420f6
Merge branch 'master' of https://github.com/apache/iotdb into need_la…
Caideyipi May 20, 2025
f5d3d75
Update IoTDBDatabaseIT.java
Caideyipi May 20, 2025
31b094f
Update IoTDBDatabaseIT.java
Caideyipi May 20, 2025
4e9582a
Update IoTDBTableIT.java
Caideyipi May 20, 2025
a46ea18
Refactor
Caideyipi May 20, 2025
8715629
partial
Caideyipi May 20, 2025
bb21903
Update PartitionCache.java
Caideyipi May 20, 2025
3cc569d
Update PartitionCache.java
Caideyipi May 20, 2025
7c23045
Partial
Caideyipi May 20, 2025
504c97c
Partial
Caideyipi May 20, 2025
c5ef08e
Update IoTDBTableIT.java
Caideyipi May 20, 2025
e191f35
Merge branch 'master' of https://github.com/apache/iotdb into need_la…
Caideyipi May 20, 2025
8569987
Update IoTDBTableIT.java
Caideyipi May 20, 2025
040457a
Fix
Caideyipi May 20, 2025
01180dc
Merge branch 'master' of https://github.com/apache/iotdb into need_la…
Caideyipi Oct 27, 2025
fb8aa46
fix-merge
Caideyipi Oct 27, 2025
cdf52b7
fix
Caideyipi Oct 27, 2025
ccc2459
fix
Caideyipi Oct 27, 2025
da3fbc6
fix
Caideyipi Oct 27, 2025
def810d
IT-fix
Caideyipi Oct 27, 2025
3786e3e
Update IoTDBDatabaseIT.java
Caideyipi Oct 27, 2025
dc42172
Merge branch 'master' of https://github.com/apache/iotdb into need_la…
Caideyipi Nov 17, 2025
8a763b4
fix
Caideyipi Nov 20, 2025
efefd90
fix
Caideyipi Dec 10, 2025
42ec9de
Merge branch 'master' of https://github.com/apache/iotdb into need_la…
Caideyipi Jan 5, 2026
2362349
fix
Caideyipi Jan 6, 2026
56bdfc3
Merge branch 'master' of https://github.com/apache/iotdb into need_la…
Caideyipi Apr 29, 2026
d6aa0b8
fix
Caideyipi Apr 29, 2026
dd373ca
fix
Caideyipi Apr 29, 2026
64a7832
Merge branch 'master' of https://github.com/apache/iotdb into need_la…
Caideyipi Jun 8, 2026
e5be5f2
Fix show create table last cache expectation
Caideyipi Jun 8, 2026
a8dc589
Merge remote-tracking branch 'cai/need_last_cache' into need_last_cache
Caideyipi Jun 8, 2026
7050f1e
Merge branch 'master' of https://github.com/apache/iotdb into need_la…
Caideyipi Jun 29, 2026
7e36f6c
Added tests
Caideyipi Jun 30, 2026
cab78e9
Clear last cache when disabling need_last_cache
Caideyipi Jul 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public void testManageDatabase() {

statement.execute("alter database if exists test1 set properties ttl='INF'");
statement.execute("alter database test set properties ttl=default");
statement.execute("alter database test set properties need_last_cache=false");

String[] databaseNames = new String[] {"test"};
String[] TTLs = new String[] {"INF"};
Expand Down Expand Up @@ -168,6 +169,7 @@ public void testManageDatabase() {
assertTrue(resultSet.getInt(7) >= defaultSchemaRegionGroupNum[cnt]);
assertEquals(dataRegionGroupNum[cnt], resultSet.getInt(8));
assertTrue(resultSet.getInt(9) >= defaultDataRegionGroupNum[cnt]);
assertFalse(resultSet.getBoolean(10));
cnt++;
}
assertEquals(databaseNames.length, cnt);
Expand Down Expand Up @@ -318,6 +320,37 @@ public void testShowCreateDatabase() throws SQLException {
}
}

@Test
public void testNeedLastCacheDatabaseProperty() throws SQLException {
try (final Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
final Statement statement = connection.createStatement()) {
statement.execute("create database need_cache_false with (need_last_cache=false)");
statement.execute("create database need_cache_default");

assertDatabaseNeedLastCache(statement, "need_cache_false", false);
assertDatabaseNeedLastCache(statement, "need_cache_default", true);

statement.execute("alter database need_cache_false set properties need_last_cache=true");
assertDatabaseNeedLastCache(statement, "need_cache_false", true);

statement.execute("alter database need_cache_false set properties need_last_cache=false");
assertDatabaseNeedLastCache(statement, "need_cache_false", false);

statement.execute("alter database need_cache_false set properties need_last_cache=default");
assertDatabaseNeedLastCache(statement, "need_cache_false", true);

try {
statement.execute("create database need_cache_invalid with (need_last_cache=1)");
fail("non-boolean need_last_cache should be rejected");
} catch (final SQLException e) {
assertEquals(
"701: need_last_cache value must be a BooleanLiteral, but now is LongLiteral, value: 1",
e.getMessage());
}
}
}

@Test
public void testShowCreatePipe() throws SQLException {
try (final Connection connection =
Expand All @@ -343,6 +376,30 @@ public void testShowCreateInformationSchemaDatabase() throws SQLException {
}
}

private static void assertDatabaseNeedLastCache(
final Statement statement, final String database, final boolean expected)
throws SQLException {
try (final ResultSet resultSet = statement.executeQuery("SHOW DATABASES DETAILS")) {
boolean found = false;
while (resultSet.next()) {
if (!database.equals(resultSet.getString("Database"))) {
continue;
}
found = true;
assertEquals(expected, resultSet.getBoolean("NeedLastCache"));
}
assertTrue(found);
}

TestUtils.assertResultSetEqual(
statement.executeQuery(
"select database, need_last_cache from information_schema.databases where database = '"
+ database
+ "'"),
"database,need_last_cache,",
Collections.singleton(database + "," + expected + ","));
}

private static void assertShowCreateSystemDatabaseFails(
final Statement statement, final String database) throws SQLException {
try {
Expand Down Expand Up @@ -500,7 +557,8 @@ public void testInformationSchema() throws SQLException {
"schema_region_group_num,INT32,ATTRIBUTE,",
"max_schema_region_group_num,INT32,ATTRIBUTE,",
"data_region_group_num,INT32,ATTRIBUTE,",
"max_data_region_group_num,INT32,ATTRIBUTE,")));
"max_data_region_group_num,INT32,ATTRIBUTE,",
"need_last_cache,BOOLEAN,ATTRIBUTE,")));
TestUtils.assertResultSetEqual(
statement.executeQuery("desc tables"),
"ColumnName,DataType,Category,",
Expand All @@ -511,7 +569,8 @@ public void testInformationSchema() throws SQLException {
"ttl(ms),STRING,ATTRIBUTE,",
"status,STRING,ATTRIBUTE,",
"comment,STRING,ATTRIBUTE,",
"table_type,STRING,ATTRIBUTE,")));
"table_type,STRING,ATTRIBUTE,",
"need_last_cache,BOOLEAN,ATTRIBUTE,")));
TestUtils.assertResultSetEqual(
statement.executeQuery("desc columns"),
"ColumnName,DataType,Category,",
Expand Down Expand Up @@ -705,7 +764,7 @@ public void testInformationSchema() throws SQLException {
statement.execute(
"create table test.test (a tag, b attribute, c int32 comment 'turbine') comment 'test'");
statement.execute(
"CREATE VIEW test.view_table (tag1 STRING TAG,tag2 STRING TAG,s11 INT32 FIELD,s3 INT32 FIELD FROM s2) RESTRICT WITH (ttl=100) AS root.\"a\".**");
"CREATE VIEW test.view_table (tag1 STRING TAG,tag2 STRING TAG,s11 INT32 FIELD,s3 INT32 FIELD FROM s2) RESTRICT WITH (ttl=100, need_last_cache=true) AS root.\"a\".**");
Comment thread
jt2594838 marked this conversation as resolved.

try (final ResultSet resultSet = statement.executeQuery("select * from databases")) {
final ResultSetMetaData metaData = resultSet.getMetaData();
Expand All @@ -722,6 +781,7 @@ public void testInformationSchema() throws SQLException {
for (int columnIndex = 3; columnIndex <= 9; columnIndex++) {
assertNull(resultSet.getObject(columnIndex));
}
assertFalse(resultSet.getBoolean(10));
} else {
assertEquals("test", resultSet.getString(1));
assertEquals("INF", resultSet.getString(2));
Expand All @@ -732,39 +792,40 @@ public void testInformationSchema() throws SQLException {
assertTrue(resultSet.getInt(7) >= 1);
assertEquals(0, resultSet.getInt(8));
assertTrue(resultSet.getInt(9) >= 2);
assertTrue(resultSet.getBoolean(10));
}
cnt++;
}
assertEquals(2, cnt);
}
TestUtils.assertResultSetEqual(
statement.executeQuery("show devices from tables where status = 'USING'"),
"database,table_name,ttl(ms),status,comment,table_type,",
"database,table_name,ttl(ms),status,comment,table_type,need_last_cache,",
new HashSet<>(
Arrays.asList(
"information_schema,databases,INF,USING,null,SYSTEM VIEW,",
"information_schema,tables,INF,USING,null,SYSTEM VIEW,",
"information_schema,columns,INF,USING,null,SYSTEM VIEW,",
"information_schema,queries,INF,USING,null,SYSTEM VIEW,",
"information_schema,regions,INF,USING,null,SYSTEM VIEW,",
"information_schema,topics,INF,USING,null,SYSTEM VIEW,",
"information_schema,pipe_plugins,INF,USING,null,SYSTEM VIEW,",
"information_schema,pipes,INF,USING,null,SYSTEM VIEW,",
"information_schema,services,INF,USING,null,SYSTEM VIEW,",
"information_schema,subscriptions,INF,USING,null,SYSTEM VIEW,",
"information_schema,views,INF,USING,null,SYSTEM VIEW,",
"information_schema,functions,INF,USING,null,SYSTEM VIEW,",
"information_schema,configurations,INF,USING,null,SYSTEM VIEW,",
"information_schema,keywords,INF,USING,null,SYSTEM VIEW,",
"information_schema,nodes,INF,USING,null,SYSTEM VIEW,",
"information_schema,table_disk_usage,INF,USING,null,SYSTEM VIEW,",
"information_schema,config_nodes,INF,USING,null,SYSTEM VIEW,",
"information_schema,data_nodes,INF,USING,null,SYSTEM VIEW,",
"information_schema,connections,INF,USING,null,SYSTEM VIEW,",
"information_schema,current_queries,INF,USING,null,SYSTEM VIEW,",
"information_schema,queries_costs_histogram,INF,USING,null,SYSTEM VIEW,",
"test,test,INF,USING,test,BASE TABLE,",
"test,view_table,100,USING,null,VIEW FROM TREE,")));
"information_schema,databases,INF,USING,null,SYSTEM VIEW,false,",
"information_schema,tables,INF,USING,null,SYSTEM VIEW,false,",
"information_schema,columns,INF,USING,null,SYSTEM VIEW,false,",
"information_schema,queries,INF,USING,null,SYSTEM VIEW,false,",
"information_schema,regions,INF,USING,null,SYSTEM VIEW,false,",
"information_schema,topics,INF,USING,null,SYSTEM VIEW,false,",
"information_schema,pipe_plugins,INF,USING,null,SYSTEM VIEW,false,",
"information_schema,pipes,INF,USING,null,SYSTEM VIEW,false,",
"information_schema,services,INF,USING,null,SYSTEM VIEW,false,",
"information_schema,subscriptions,INF,USING,null,SYSTEM VIEW,false,",
"information_schema,views,INF,USING,null,SYSTEM VIEW,false,",
"information_schema,functions,INF,USING,null,SYSTEM VIEW,false,",
"information_schema,configurations,INF,USING,null,SYSTEM VIEW,false,",
"information_schema,keywords,INF,USING,null,SYSTEM VIEW,false,",
"information_schema,nodes,INF,USING,null,SYSTEM VIEW,false,",
"information_schema,table_disk_usage,INF,USING,null,SYSTEM VIEW,false,",
"information_schema,config_nodes,INF,USING,null,SYSTEM VIEW,false,",
"information_schema,data_nodes,INF,USING,null,SYSTEM VIEW,false,",
"information_schema,connections,INF,USING,null,SYSTEM VIEW,false,",
"information_schema,current_queries,INF,USING,null,SYSTEM VIEW,false,",
"information_schema,queries_costs_histogram,INF,USING,null,SYSTEM VIEW,false,",
"test,test,INF,USING,test,BASE TABLE,true,",
"test,view_table,100,USING,null,VIEW FROM TREE,true,")));
TestUtils.assertResultSetEqual(
statement.executeQuery("count devices from tables where status = 'USING'"),
"count(devices),",
Expand Down Expand Up @@ -811,7 +872,7 @@ public void testInformationSchema() throws SQLException {
statement.executeQuery("select * from views"),
"database,table_name,view_definition,",
Collections.singleton(
"test,view_table,CREATE VIEW \"view_table\" (\"time\" TIMESTAMP TIME,\"tag1\" STRING TAG,\"tag2\" STRING TAG,\"s11\" INT32 FIELD,\"s3\" INT32 FIELD FROM \"s2\") RESTRICT WITH (ttl=100) AS root.\"a\".**,"));
"test,view_table,CREATE VIEW \"view_table\" (\"time\" TIMESTAMP TIME,\"tag1\" STRING TAG,\"tag2\" STRING TAG,\"s11\" INT32 FIELD,\"s3\" INT32 FIELD FROM \"s2\") RESTRICT WITH (ttl=100, need_last_cache=true) AS root.\"a\".**,"));

TestUtils.assertResultSetEqual(
statement.executeQuery(
Expand Down Expand Up @@ -870,12 +931,26 @@ public void testMixedDatabase() throws SQLException {

try (final Connection connection = EnvFactory.getEnv().getConnection();
final Statement statement = connection.createStatement()) {
statement.execute("create database root.test");
statement.execute("create database root.test with NEED_LAST_CACHE=false");
try (final ResultSet resultSet = statement.executeQuery("SHOW DATABASES DETAILS root.test")) {
assertTrue(resultSet.next());
assertEquals("root.test", resultSet.getString("Database"));
assertFalse(resultSet.getBoolean("NeedLastCache"));
assertFalse(resultSet.next());
}
Assert.assertThrows(
IoTDBSQLException.class,
() ->
statement.execute(
"alter database root.test WITH MAX_SCHEMA_REGION_GROUP_NUM=2, MAX_DATA_REGION_GROUP_NUM=3"));
try {
statement.execute("alter database root.test WITH NEED_LAST_CACHE=true");
fail("tree database need_last_cache alter should be rejected");
} catch (final SQLException e) {
assertEquals(
"701: The tree model database does not support alter need last cache now.",
e.getMessage());
}
statement.execute("insert into root.test.d1 (s1) values(1)");
statement.execute("drop database root.test");
}
Expand Down Expand Up @@ -994,8 +1069,9 @@ public void testDBAuth() throws SQLException {
Collections.singleton("information_schema,INF,null,null,null,"));
TestUtils.assertResultSetEqual(
userStmt.executeQuery("select * from information_schema.databases"),
"database,ttl(ms),schema_replication_factor,data_replication_factor,time_partition_interval,schema_region_group_num,max_schema_region_group_num,data_region_group_num,max_data_region_group_num,",
Collections.singleton("information_schema,INF,null,null,null,null,null,null,null,"));
"database,ttl(ms),schema_replication_factor,data_replication_factor,time_partition_interval,schema_region_group_num,max_schema_region_group_num,data_region_group_num,max_data_region_group_num,need_last_cache,",
Collections.singleton(
"information_schema,INF,null,null,null,null,null,null,null,false,"));
}

try (final Connection adminCon = EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
Expand Down
Loading
Loading