Skip to content

Commit 2ef2f2b

Browse files
committed
Merge branch 'master' into update_last_cache_in_load
# Conflicts: # iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/LoadTsFileManager.java
2 parents 566c2b8 + f6b2d07 commit 2ef2f2b

273 files changed

Lines changed: 10037 additions & 2499 deletions

File tree

Some content is hidden

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

LICENSE

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,3 +270,18 @@ The following files include code modified from Apache Kafka project.
270270

271271
Project page: https://github.com/apache/kafka
272272
License: https://github.com/apache/kafka/blob/trunk/LICENSE
273+
274+
--------------------------------------------------------------------------------
275+
276+
The following files include code modified from Stream-Lib project.
277+
278+
./iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/Counter.java
279+
./iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/DoublyLinkedList.java
280+
./iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/ExternalizableUtil.java
281+
./iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/ITopK.java
282+
./iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/ListNode2.java
283+
./iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/Pair.java
284+
./iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/approximate/StreamSummary.java
285+
286+
Project page: https://github.com/addthis/stream-lib
287+
License: https://github.com/addthis/stream-lib/blob/master/LICENSE.txt

example/mqtt-customize/src/main/java/org/apache/iotdb/mqtt/server/CustomizedJsonPayloadFormatter.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.apache.iotdb.db.protocol.mqtt.TreeMessage;
2525

2626
import io.netty.buffer.ByteBuf;
27+
import org.apache.commons.lang3.NotImplementedException;
2728

2829
import java.util.ArrayList;
2930
import java.util.Arrays;
@@ -33,7 +34,7 @@
3334
public class CustomizedJsonPayloadFormatter implements PayloadFormatter {
3435

3536
@Override
36-
public List<Message> format(ByteBuf payload) {
37+
public List<Message> format(String topic, ByteBuf payload) {
3738
// Suppose the payload is a json format
3839
if (payload == null) {
3940
return Collections.emptyList();
@@ -54,6 +55,12 @@ public List<Message> format(ByteBuf payload) {
5455
return ret;
5556
}
5657

58+
@Override
59+
@Deprecated
60+
public List<Message> format(ByteBuf payload) {
61+
throw new NotImplementedException();
62+
}
63+
5764
@Override
5865
public String getName() {
5966
// set the value of mqtt_payload_formatter in iotdb-common.properties as the following string:

integration-test/src/main/java/org/apache/iotdb/it/env/cluster/node/DataNodeWrapper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ protected MppJVMConfig initVMConfig() {
168168
.setMaxHeapSize(EnvUtils.getIntFromSysVar(DATANODE_MAX_HEAP_SIZE, 256, clusterIndex))
169169
.setMaxDirectMemorySize(
170170
EnvUtils.getIntFromSysVar(DATANODE_MAX_DIRECT_MEMORY_SIZE, 256, clusterIndex))
171+
.setTimezone("Asia/Shanghai")
171172
.build();
172173
}
173174

integration-test/src/test/java/org/apache/iotdb/ainode/it/AINodeBasicIT.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ private void errorTest(String sql, String errorMessage) {
107107
@Test
108108
public void aiNodeConnectionTest() {
109109
String sql = "SHOW AINODES";
110-
String title = "NodeID,Status,RpcAddress,RpcPort";
110+
String title = "NodeID,Status,InternalAddress,InternalPort";
111111
try (Connection connection = EnvFactory.getEnv().getConnection();
112112
Statement statement = connection.createStatement()) {
113113

@@ -176,6 +176,26 @@ public void ModelOperationTest() {
176176
}
177177
}
178178

179+
@Test
180+
public void callInferenceTest2() {
181+
String sql =
182+
"CALL INFERENCE(_holtwinters, \"select s0 from root.AI.data\", predict_length=6, generateTime=true)";
183+
try (Connection connection = EnvFactory.getEnv().getConnection();
184+
Statement statement = connection.createStatement()) {
185+
try (ResultSet resultSet = statement.executeQuery(sql)) {
186+
ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
187+
checkHeader(resultSetMetaData, "Time,output0");
188+
int count = 0;
189+
while (resultSet.next()) {
190+
count++;
191+
}
192+
assertEquals(6, count);
193+
}
194+
} catch (SQLException e) {
195+
fail(e.getMessage());
196+
}
197+
}
198+
179199
@Test
180200
public void callInferenceTest() {
181201
String sql =

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,9 @@ public void testLoadWithConvertOnTypeMismatchForTableModel() throws Exception {
970970
statement.execute(String.format("create database if not exists %s", SchemaConfig.DATABASE_0));
971971
statement.execute(String.format("use %s", SchemaConfig.DATABASE_0));
972972
statement.execute(convert2TableSQL(SchemaConfig.TABLE_0, schemaList1, columnCategories));
973-
statement.execute(String.format("load '%s'", file.getAbsolutePath()));
973+
statement.execute(
974+
String.format(
975+
"load '%s' with ('database'='%s')", file.getAbsolutePath(), SchemaConfig.DATABASE_0));
974976
try (final ResultSet resultSet =
975977
statement.executeQuery(String.format("select count(*) from %s", SchemaConfig.TABLE_0))) {
976978
if (resultSet.next()) {

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public void testSetDefaultSGLevel() throws SQLException {
165165
statement.execute("INSERT INTO root.fail(timestamp, s1) VALUES (1, 1)");
166166
} catch (SQLException e) {
167167
assertEquals(
168-
"509: root.fail is not a legal path, because it is no longer than default sg level: 3",
168+
"509: An error occurred when executing getDeviceToDatabase():root.fail is not a legal path, because it is no longer than default sg level: 3",
169169
e.getMessage());
170170
}
171171

@@ -176,6 +176,7 @@ public void testSetDefaultSGLevel() throws SQLException {
176176
assertTrue(e.getMessage().contains("Illegal defaultStorageGroupLevel: -1, should >= 1"));
177177
}
178178

179+
// Failed updates will not change the files.
179180
// Failed updates will not change the files.
180181
assertFalse(
181182
checkConfigFileContains(
@@ -197,6 +198,15 @@ public void testSetDefaultSGLevel() throws SQLException {
197198
// the default value should take effect
198199
Assert.assertEquals("root.a", databases.getString(1));
199200
assertFalse(databases.next());
201+
202+
// create timeseries with an illegal path
203+
try {
204+
statement.execute("CREATE TIMESERIES root.db1.s3 WITH datatype=INT32");
205+
} catch (SQLException e) {
206+
assertEquals(
207+
"509: An error occurred when executing getDeviceToDatabase():root.db1 is not a legal path, because it is no longer than default sg level: 3",
208+
e.getMessage());
209+
}
200210
}
201211
}
202212
}

integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/tablemodel/manual/basic/IoTDBPipePermissionIT.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,49 @@ public void testReceiverPermission() throws Exception {
309309
TestUtils.executeNonQueryWithRetry(senderEnv, "flush");
310310
TestUtils.executeNonQueryWithRetry(receiverEnv, "flush");
311311
});
312+
313+
// Alter pipe, skip if no privileges
314+
try (final Connection connection = senderEnv.getConnection(BaseEnv.TABLE_SQL_DIALECT);
315+
final Statement statement = connection.createStatement()) {
316+
statement.execute("alter pipe testPipe modify sink ('skipif'='no-privileges')");
317+
} catch (final SQLException e) {
318+
e.printStackTrace();
319+
fail(e.getMessage());
320+
}
321+
322+
final String dbName2 = "test2";
323+
324+
// Write some data
325+
if (!TableModelUtils.insertData(dbName2, tbName, 0, 100, senderEnv)) {
326+
return;
327+
}
328+
329+
// Shall not be transferred
330+
TestUtils.assertDataAlwaysOnEnv(
331+
receiverEnv, "count databases", "count,", Collections.singleton("2,"), (String) null);
332+
333+
if (!TestUtils.tryExecuteNonQueryWithRetry(
334+
"information_schema",
335+
BaseEnv.TABLE_SQL_DIALECT,
336+
receiverEnv,
337+
"grant insert,create on database test2 to user testUser")) {
338+
return;
339+
}
340+
341+
if (!TableModelUtils.insertData(dbName2, tbName, 100, 200, senderEnv)) {
342+
return;
343+
}
344+
345+
// Will finally pass
346+
TableModelUtils.assertCountData(
347+
dbName2,
348+
tbName,
349+
100,
350+
receiverEnv,
351+
o -> {
352+
TestUtils.executeNonQueryWithRetry(senderEnv, "flush");
353+
TestUtils.executeNonQueryWithRetry(receiverEnv, "flush");
354+
});
312355
}
313356
}
314357
}

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

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2775,7 +2775,34 @@ public void exceptionTest() {
27752775

27762776
tableAssertTestFail(
27772777
"select * from table0 asof (tolerance 1s) left join table1 on table0.time<=table1.time",
2778-
"Tolerance in ASOF JOIN is only support INNER type now",
2778+
"Tolerance in ASOF JOIN only supports INNER type now",
2779+
DATABASE_NAME);
2780+
2781+
tableAssertTestFail(
2782+
"select * from table0 asof right join table1 on table0.time<=table1.time",
2783+
"ASOF JOIN does not support RIGHT type now",
2784+
DATABASE_NAME);
2785+
2786+
tableAssertTestFail(
2787+
"select * from table0 asof full join table1 on table0.time<=table1.time",
2788+
"ASOF JOIN does not support FULL type now",
2789+
DATABASE_NAME);
2790+
}
2791+
2792+
@Test
2793+
public void aggregationTableScanWithJoinTest() {
2794+
expectedHeader = new String[] {"date", "_col1", "date", "_col3"};
2795+
retArray = new String[] {"1970-01-01T00:00:00.000Z,2,1970-01-01T00:00:00.000Z,2,"};
2796+
// Join may rename the 'time' column, so we need to ensure the correctness of
2797+
// AggregationTableScan in this case
2798+
tableResultSetEqualTest(
2799+
"select * from ("
2800+
+ "select date_bin(1ms,time) as date,count(*)from table0 group by date_bin(1ms,time)) t0 "
2801+
+ "join ("
2802+
+ "select date_bin(1ms,time) as date,count(*)from table1 where time=0 group by date_bin(1ms,time)) t1 "
2803+
+ "on t0.date = t1.date",
2804+
expectedHeader,
2805+
retArray,
27792806
DATABASE_NAME);
27802807
}
27812808

integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTDBMaintainAuthIT.java

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -165,20 +165,10 @@ public void maintainAuthTest() {
165165
PASSWORD);
166166

167167
// case 12: show queries
168-
// user1 with select on information_schema.queries
169-
tableAssertTestFail(
170-
"SHOW QUERIES",
171-
TSStatusCode.NO_PERMISSION.getStatusCode()
172-
+ ": Access Denied: No permissions for this operation, only root user is allowed",
173-
USER_1,
174-
PASSWORD);
175-
// user2 without select on information_schema.queries
176-
tableAssertTestFail(
177-
"SHOW QUERIES",
178-
TSStatusCode.NO_PERMISSION.getStatusCode()
179-
+ ": Access Denied: No permissions for this operation, only root user is allowed",
180-
USER_2,
181-
PASSWORD);
168+
// non-root users can access its own queries
169+
expectedHeader =
170+
new String[] {"query_id", "start_time", "datanode_id", "elapsed_time", "statement", "user"};
171+
tableQueryNoVerifyResultTest("show queries", expectedHeader, USER_2, PASSWORD);
182172

183173
// case 13: kill query
184174
// user2

integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTDBTableAggregationIT.java

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4165,6 +4165,51 @@ public void approxCountDistinctTest() {
41654165
DATABASE_NAME);
41664166
}
41674167

4168+
@Test
4169+
public void approxMostFrequentTest() {
4170+
String[] expectedHeader = buildHeaders(7);
4171+
String[] retArray =
4172+
new String[] {
4173+
"{\"50000\":8},{\"30.0\":8},{\"55.0\":8},{\"true\":12},{\"0xcafebabe55\":8},{\"1727158540000\":12},{\"20240924\":20},"
4174+
};
4175+
tableResultSetEqualTest(
4176+
"select approx_most_frequent(s2, 1, 10), approx_most_frequent(s3, 1, 10), approx_most_frequent(s4, 1, 10), approx_most_frequent(s5, 1, 10), approx_most_frequent(s8, 1, 10), approx_most_frequent(s9, 1, 10), approx_most_frequent(s10, 1, 10) from table1",
4177+
expectedHeader,
4178+
retArray,
4179+
DATABASE_NAME);
4180+
4181+
expectedHeader = new String[] {"time", "province", "_col2"};
4182+
retArray =
4183+
new String[] {
4184+
"2024-09-24T06:15:30.000Z,beijing,{},",
4185+
"2024-09-24T06:15:31.000Z,beijing,{\"31000\":2},",
4186+
"2024-09-24T06:15:35.000Z,beijing,{\"35000\":2},",
4187+
"2024-09-24T06:15:36.000Z,beijing,{},",
4188+
"2024-09-24T06:15:40.000Z,beijing,{\"40000\":2},",
4189+
"2024-09-24T06:15:41.000Z,beijing,{},",
4190+
"2024-09-24T06:15:46.000Z,beijing,{\"46000\":2},",
4191+
"2024-09-24T06:15:50.000Z,beijing,{\"50000\":4},",
4192+
"2024-09-24T06:15:51.000Z,beijing,{},",
4193+
"2024-09-24T06:15:55.000Z,beijing,{},",
4194+
"2024-09-24T06:15:30.000Z,shanghai,{},",
4195+
"2024-09-24T06:15:31.000Z,shanghai,{\"31000\":2},",
4196+
"2024-09-24T06:15:35.000Z,shanghai,{\"35000\":2},",
4197+
"2024-09-24T06:15:36.000Z,shanghai,{},",
4198+
"2024-09-24T06:15:40.000Z,shanghai,{\"40000\":2},",
4199+
"2024-09-24T06:15:41.000Z,shanghai,{},",
4200+
"2024-09-24T06:15:46.000Z,shanghai,{\"46000\":2},",
4201+
"2024-09-24T06:15:50.000Z,shanghai,{\"50000\":4},",
4202+
"2024-09-24T06:15:51.000Z,shanghai,{},",
4203+
"2024-09-24T06:15:55.000Z,shanghai,{},",
4204+
};
4205+
4206+
tableResultSetEqualTest(
4207+
"SELECT time,province,approx_most_frequent(s2, 1, 10) from table1 group by 1,2 order by 2,1",
4208+
expectedHeader,
4209+
retArray,
4210+
DATABASE_NAME);
4211+
}
4212+
41684213
@Test
41694214
public void exceptionTest() {
41704215
tableAssertTestFail(
@@ -4211,6 +4256,14 @@ public void exceptionTest() {
42114256
"select approx_count_distinct(province, 'test') from table1",
42124257
"701: Second argument of Aggregate functions [approx_count_distinct] should be numberic type and do not use expression",
42134258
DATABASE_NAME);
4259+
tableAssertTestFail(
4260+
"select approx_most_frequent(province, -10, 100) from table1",
4261+
"701: The second and third argument must be greater than 0, but got k=-10, capacity=100",
4262+
DATABASE_NAME);
4263+
tableAssertTestFail(
4264+
"select approx_most_frequent(province, 'test', 100) from table1",
4265+
"701: The second and third argument of 'approx_most_frequent' function must be numeric literal",
4266+
DATABASE_NAME);
42144267
}
42154268

42164269
// ==================================================================

0 commit comments

Comments
 (0)