Skip to content

Commit ed3c39a

Browse files
committed
Merge branch 'master' into fix-wal-disabled-but-remain-acquire-mem
2 parents 9b1fabc + 7f03f36 commit ed3c39a

File tree

259 files changed

+8313
-1543
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

259 files changed

+8313
-1543
lines changed

integration-test/src/test/java/org/apache/iotdb/db/it/cq/IoTDBCQIT.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void testCreateWrongCQ() {
7272
fail();
7373
} catch (Exception e) {
7474
assertEquals(
75-
TSStatusCode.INTERNAL_SERVER_ERROR.getStatusCode()
75+
TSStatusCode.SEMANTIC_ERROR.getStatusCode()
7676
+ ": CQ: Specifying time range in GROUP BY TIME clause is prohibited.",
7777
e.getMessage());
7878
}
@@ -92,7 +92,7 @@ public void testCreateWrongCQ() {
9292
fail();
9393
} catch (Exception e) {
9494
assertEquals(
95-
TSStatusCode.INTERNAL_SERVER_ERROR.getStatusCode()
95+
TSStatusCode.SEMANTIC_ERROR.getStatusCode()
9696
+ ": CQ: Specifying time filters in the query body is prohibited.",
9797
e.getMessage());
9898
}
@@ -128,7 +128,7 @@ public void testCreateWrongCQ() {
128128
fail();
129129
} catch (Exception e) {
130130
assertEquals(
131-
TSStatusCode.INTERNAL_SERVER_ERROR.getStatusCode()
131+
TSStatusCode.SEMANTIC_ERROR.getStatusCode()
132132
+ ": CQ: The query body misses an INTO clause.",
133133
e.getMessage());
134134
}
@@ -149,7 +149,7 @@ public void testCreateWrongCQ() {
149149
fail();
150150
} catch (Exception e) {
151151
assertEquals(
152-
TSStatusCode.INTERNAL_SERVER_ERROR.getStatusCode()
152+
TSStatusCode.SEMANTIC_ERROR.getStatusCode()
153153
+ ": CQ: Every interval [50] should not be lower than the `continuous_query_minimum_every_interval` [1000] configured.",
154154
e.getMessage());
155155
}
@@ -189,7 +189,7 @@ public void testCreateWrongCQ() {
189189
fail();
190190
} catch (Exception e) {
191191
assertEquals(
192-
TSStatusCode.INTERNAL_SERVER_ERROR.getStatusCode()
192+
TSStatusCode.SEMANTIC_ERROR.getStatusCode()
193193
+ ": CQ: The start time offset should be greater than 0.",
194194
e.getMessage());
195195
}
@@ -229,7 +229,7 @@ public void testCreateWrongCQ() {
229229
fail();
230230
} catch (Exception e) {
231231
assertEquals(
232-
TSStatusCode.INTERNAL_SERVER_ERROR.getStatusCode()
232+
TSStatusCode.SEMANTIC_ERROR.getStatusCode()
233233
+ ": CQ: The start time offset should be greater than end time offset.",
234234
e.getMessage());
235235
}
@@ -249,7 +249,7 @@ public void testCreateWrongCQ() {
249249
fail();
250250
} catch (Exception e) {
251251
assertEquals(
252-
TSStatusCode.INTERNAL_SERVER_ERROR.getStatusCode()
252+
TSStatusCode.SEMANTIC_ERROR.getStatusCode()
253253
+ ": CQ: The start time offset should be greater than end time offset.",
254254
e.getMessage());
255255
}
@@ -269,7 +269,7 @@ public void testCreateWrongCQ() {
269269
fail();
270270
} catch (Exception e) {
271271
assertEquals(
272-
TSStatusCode.INTERNAL_SERVER_ERROR.getStatusCode()
272+
TSStatusCode.SEMANTIC_ERROR.getStatusCode()
273273
+ ": CQ: The start time offset should be greater than or equal to every interval.",
274274
e.getMessage());
275275
}

integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/tablemodel/manual/enhanced/IoTDBPipeIdempotentIT.java

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,23 @@ public void testCreateTableIdempotent() throws Exception {
5858
testTableConfigIdempotent(Collections.emptyList(), "create table test()");
5959
}
6060

61+
@Test
62+
public void testCreateTableViewIdempotent() throws Exception {
63+
testTableConfigIdempotent(
64+
Collections.emptyList(), "create table view test(s1 field int32) as root.a.** restrict");
65+
}
66+
6167
@Test
6268
public void testAlterTableAddColumnIdempotent() throws Exception {
6369
testTableConfigIdempotent(
64-
Collections.singletonList("create table test()"), "alter table test add column a id");
70+
Collections.singletonList("create table test()"), "alter table test add column a tag");
71+
}
72+
73+
@Test
74+
public void testAlterViewAddColumnIdempotent() throws Exception {
75+
testTableConfigIdempotent(
76+
Collections.singletonList("create table view test(s1 field int32) as root.a.** restrict"),
77+
"alter view test add column a tag");
6578
}
6679

6780
@Test
@@ -71,18 +84,55 @@ public void testAlterTableSetPropertiesIdempotent() throws Exception {
7184
"alter table test set properties ttl=100");
7285
}
7386

87+
@Test
88+
public void testAlterViewSetPropertiesIdempotent() throws Exception {
89+
testTableConfigIdempotent(
90+
Collections.singletonList("create table view test(s1 field int32) as root.a.** restrict"),
91+
"alter view test set properties ttl=100");
92+
}
93+
7494
@Test
7595
public void testAlterTableDropColumnIdempotent() throws Exception {
7696
testTableConfigIdempotent(
77-
Collections.singletonList("create table test(a id, b attribute, c int32)"),
97+
Collections.singletonList("create table test(a tag, b attribute, c int32)"),
7898
"alter table test drop column b");
7999
}
80100

101+
@Test
102+
public void testAlterViewDropColumnIdempotent() throws Exception {
103+
testTableConfigIdempotent(
104+
Collections.singletonList(
105+
"create table view test(a tag, s1 field int32) as root.a.** restrict"),
106+
"alter view test drop column a");
107+
}
108+
81109
@Test
82110
public void testDropTableIdempotent() throws Exception {
83111
testTableConfigIdempotent(Collections.singletonList("create table test()"), "drop table test");
84112
}
85113

114+
@Test
115+
public void testDropViewIdempotent() throws Exception {
116+
testTableConfigIdempotent(
117+
Collections.singletonList("create table view test(s1 field int32) as root.a.** restrict"),
118+
"drop view test");
119+
}
120+
121+
@Test
122+
public void testRenameViewColumnIdempotent() throws Exception {
123+
testTableConfigIdempotent(
124+
Collections.singletonList(
125+
"create table view test(a tag, s1 field int32) as root.a.** restrict"),
126+
"alter view test rename column a to b");
127+
}
128+
129+
@Test
130+
public void testRenameViewIdempotent() throws Exception {
131+
testTableConfigIdempotent(
132+
Collections.singletonList("create table view test(s1 field int32) as root.a.** restrict"),
133+
"alter view test rename to test1");
134+
}
135+
86136
@Test
87137
public void testTableCreateUserIdempotent() throws Exception {
88138
testTableConfigIdempotent(Collections.emptyList(), "create user newUser 'password'");

integration-test/src/test/java/org/apache/iotdb/pipe/it/single/IoTDBPipeAggregateIT.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ public void testAggregator() throws Exception {
6666
processorAttributes.put("output.database", "root.testdb");
6767
processorAttributes.put(
6868
"output.measurements", "Avg1, peak1, rms1, var1, skew1, kurt1, ff1, cf1, pf1");
69-
processorAttributes.put("operators", "avg, peak, rms, var, skew, kurt, ff, cf, pf, cE");
69+
processorAttributes.put(
70+
"operators", "avg, peak, rms, var, skew, kurt, ff, cf, pf, cE, max, min");
7071
processorAttributes.put("sliding.seconds", "60");
7172

7273
connectorAttributes.put("sink", "write-back-sink");
@@ -115,7 +116,7 @@ public void testAggregator() throws Exception {
115116
env,
116117
"select count(*) from root.testdb.** group by level=1",
117118
"count(root.testdb.*.*.*.*),",
118-
Collections.singleton("20,"));
119+
Collections.singleton("24,"));
119120

120121
// Test manually renamed timeSeries count
121122
TestUtils.assertDataEventuallyOnEnv(

integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDatabaseIT.java

Lines changed: 107 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,12 @@ public void testInformationSchema() throws SQLException {
389389
"topics,INF,",
390390
"pipe_plugins,INF,",
391391
"pipes,INF,",
392-
"subscriptions,INF,")));
392+
"subscriptions,INF,",
393+
"views,INF,",
394+
"models,INF,",
395+
"functions,INF,",
396+
"configurations,INF,",
397+
"keywords,INF,")));
393398

394399
TestUtils.assertResultSetEqual(
395400
statement.executeQuery("desc databases"),
@@ -412,7 +417,8 @@ public void testInformationSchema() throws SQLException {
412417
"table_name,STRING,TAG,",
413418
"ttl(ms),STRING,ATTRIBUTE,",
414419
"status,STRING,ATTRIBUTE,",
415-
"comment,STRING,ATTRIBUTE,")));
420+
"comment,STRING,ATTRIBUTE,",
421+
"table_type,STRING,ATTRIBUTE,")));
416422
TestUtils.assertResultSetEqual(
417423
statement.executeQuery("desc columns"),
418424
"ColumnName,DataType,Category,",
@@ -472,6 +478,41 @@ public void testInformationSchema() throws SQLException {
472478
"topic_name,STRING,TAG,",
473479
"consumer_group_name,STRING,TAG,",
474480
"subscribed_consumers,STRING,ATTRIBUTE,")));
481+
TestUtils.assertResultSetEqual(
482+
statement.executeQuery("desc views"),
483+
"ColumnName,DataType,Category,",
484+
new HashSet<>(
485+
Arrays.asList(
486+
"database,STRING,TAG,",
487+
"table_name,STRING,TAG,",
488+
"view_definition,STRING,ATTRIBUTE,")));
489+
TestUtils.assertResultSetEqual(
490+
statement.executeQuery("desc models"),
491+
"ColumnName,DataType,Category,",
492+
new HashSet<>(
493+
Arrays.asList(
494+
"model_id,STRING,TAG,",
495+
"model_type,STRING,ATTRIBUTE,",
496+
"state,STRING,ATTRIBUTE,",
497+
"configs,STRING,ATTRIBUTE,",
498+
"notes,STRING,ATTRIBUTE,")));
499+
TestUtils.assertResultSetEqual(
500+
statement.executeQuery("desc functions"),
501+
"ColumnName,DataType,Category,",
502+
new HashSet<>(
503+
Arrays.asList(
504+
"function_table,STRING,TAG,",
505+
"function_type,STRING,ATTRIBUTE,",
506+
"class_name(udf),STRING,ATTRIBUTE,",
507+
"state,STRING,ATTRIBUTE,")));
508+
TestUtils.assertResultSetEqual(
509+
statement.executeQuery("desc configurations"),
510+
"ColumnName,DataType,Category,",
511+
new HashSet<>(Arrays.asList("variable,STRING,TAG,", "value,STRING,ATTRIBUTE,")));
512+
TestUtils.assertResultSetEqual(
513+
statement.executeQuery("desc keywords"),
514+
"ColumnName,DataType,Category,",
515+
new HashSet<>(Arrays.asList("word,STRING,TAG,", "reserved,INT32,ATTRIBUTE,")));
475516

476517
// Currently only root can query information_schema
477518
Assert.assertThrows(
@@ -490,6 +531,8 @@ public void testInformationSchema() throws SQLException {
490531
statement.execute("create database test");
491532
statement.execute(
492533
"create table test.test (a tag, b attribute, c int32 comment 'turbine') comment 'test'");
534+
statement.execute(
535+
"CREATE TABLE VIEW test.view_table (tag1 STRING TAG,tag2 STRING TAG,s11 INT32 FIELD,s3 INT32 FIELD FROM s2) AS root.a.** WITH (ttl=100) RESTRICT");
493536

494537
TestUtils.assertResultSetEqual(
495538
statement.executeQuery("select * from databases"),
@@ -500,23 +543,29 @@ public void testInformationSchema() throws SQLException {
500543
"test,INF,1,1,604800000,0,0,")));
501544
TestUtils.assertResultSetEqual(
502545
statement.executeQuery("show devices from tables where status = 'USING'"),
503-
"database,table_name,ttl(ms),status,comment,",
546+
"database,table_name,ttl(ms),status,comment,table_type,",
504547
new HashSet<>(
505548
Arrays.asList(
506-
"information_schema,databases,INF,USING,null,",
507-
"information_schema,tables,INF,USING,null,",
508-
"information_schema,columns,INF,USING,null,",
509-
"information_schema,queries,INF,USING,null,",
510-
"information_schema,regions,INF,USING,null,",
511-
"information_schema,topics,INF,USING,null,",
512-
"information_schema,pipe_plugins,INF,USING,null,",
513-
"information_schema,pipes,INF,USING,null,",
514-
"information_schema,subscriptions,INF,USING,null,",
515-
"test,test,INF,USING,test,")));
549+
"information_schema,databases,INF,USING,null,SYSTEM VIEW,",
550+
"information_schema,tables,INF,USING,null,SYSTEM VIEW,",
551+
"information_schema,columns,INF,USING,null,SYSTEM VIEW,",
552+
"information_schema,queries,INF,USING,null,SYSTEM VIEW,",
553+
"information_schema,regions,INF,USING,null,SYSTEM VIEW,",
554+
"information_schema,topics,INF,USING,null,SYSTEM VIEW,",
555+
"information_schema,pipe_plugins,INF,USING,null,SYSTEM VIEW,",
556+
"information_schema,pipes,INF,USING,null,SYSTEM VIEW,",
557+
"information_schema,subscriptions,INF,USING,null,SYSTEM VIEW,",
558+
"information_schema,views,INF,USING,null,SYSTEM VIEW,",
559+
"information_schema,models,INF,USING,null,SYSTEM VIEW,",
560+
"information_schema,functions,INF,USING,null,SYSTEM VIEW,",
561+
"information_schema,configurations,INF,USING,null,SYSTEM VIEW,",
562+
"information_schema,keywords,INF,USING,null,SYSTEM VIEW,",
563+
"test,test,INF,USING,test,BASE TABLE,",
564+
"test,view_table,100,USING,null,TREE_TO_TABLE VIEW,")));
516565
TestUtils.assertResultSetEqual(
517566
statement.executeQuery("count devices from tables where status = 'USING'"),
518567
"count(devices),",
519-
Collections.singleton("10,"));
568+
Collections.singleton("16,"));
520569
TestUtils.assertResultSetEqual(
521570
statement.executeQuery(
522571
"select * from columns where table_name = 'queries' or database = 'test'"),
@@ -532,7 +581,12 @@ public void testInformationSchema() throws SQLException {
532581
"test,test,time,TIMESTAMP,TIME,USING,null,",
533582
"test,test,a,STRING,TAG,USING,null,",
534583
"test,test,b,STRING,ATTRIBUTE,USING,null,",
535-
"test,test,c,INT32,FIELD,USING,turbine,")));
584+
"test,test,c,INT32,FIELD,USING,turbine,",
585+
"test,view_table,time,TIMESTAMP,TIME,USING,null,",
586+
"test,view_table,tag1,STRING,TAG,USING,null,",
587+
"test,view_table,tag2,STRING,TAG,USING,null,",
588+
"test,view_table,s11,INT32,FIELD,USING,null,",
589+
"test,view_table,s3,INT32,FIELD,USING,null,")));
536590

537591
statement.execute(
538592
"create pipe a2b with source('double-living'='true') with sink ('sink'='write-back-sink')");
@@ -544,16 +598,51 @@ public void testInformationSchema() throws SQLException {
544598
statement.executeQuery(
545599
"select * from pipe_plugins where plugin_name = 'IOTDB-THRIFT-SINK'"),
546600
"plugin_name,plugin_type,class_name,plugin_jar,",
547-
new HashSet<>(
548-
Arrays.asList(
549-
"IOTDB-THRIFT-SINK,Builtin,org.apache.iotdb.commons.pipe.agent.plugin.builtin.connector.iotdb.thrift.IoTDBThriftConnector,null,")));
601+
Collections.singleton(
602+
"IOTDB-THRIFT-SINK,Builtin,org.apache.iotdb.commons.pipe.agent.plugin.builtin.connector.iotdb.thrift.IoTDBThriftConnector,null,"));
550603

551604
statement.execute("create topic tp with ('start-time'='2025-01-13T10:03:19.229+08:00')");
552605
TestUtils.assertResultSetEqual(
553606
statement.executeQuery("select * from topics where topic_name = 'tp'"),
554607
"topic_name,topic_configs,",
555608
Collections.singleton(
556609
"tp,{__system.sql-dialect=table, start-time=2025-01-13T10:03:19.229+08:00},"));
610+
611+
TestUtils.assertResultSetEqual(
612+
statement.executeQuery("select * from views"),
613+
"database,table_name,view_definition,",
614+
Collections.singleton(
615+
"test,view_table,CREATE TABLE VIEW \"view_table\" (\"tag1\" STRING TAG,\"tag2\" STRING TAG,\"s11\" INT32 FIELD,\"s3\" INT32 FIELD FROM \"s2\") AS root.a.** WITH (ttl=100) RESTRICT,"));
616+
617+
TestUtils.assertResultSetEqual(
618+
statement.executeQuery(
619+
"select model_id from information_schema.models where model_type = 'BUILT_IN_FORECAST'"),
620+
"model_id,",
621+
new HashSet<>(
622+
Arrays.asList(
623+
"_STLForecaster,", "_NaiveForecaster,", "_ARIMA,", "_ExponentialSmoothing,")));
624+
625+
TestUtils.assertResultSetEqual(
626+
statement.executeQuery(
627+
"select distinct(function_type) from information_schema.functions"),
628+
"function_type,",
629+
new HashSet<>(
630+
Arrays.asList(
631+
"built-in scalar function,",
632+
"built-in aggregate function,",
633+
"built-in table function,")));
634+
635+
TestUtils.assertResultSetEqual(
636+
statement.executeQuery(
637+
"select value from information_schema.configurations where variable = 'TimestampPrecision'"),
638+
"value,",
639+
Collections.singleton("ms,"));
640+
641+
TestUtils.assertResultSetEqual(
642+
statement.executeQuery(
643+
"select * from information_schema.keywords where reserved > 0 limit 1"),
644+
"word,reserved,",
645+
Collections.singleton("AINODES,1,"));
557646
}
558647
}
559648

0 commit comments

Comments
 (0)