Skip to content

Commit 78320ae

Browse files
committed
Merge branch 'alter_column_datatype_draft' of https://github.com/zerolbsony/iotdb into pr/16027
2 parents 3e95af7 + 0e6c555 commit 78320ae

File tree

66 files changed

+2727
-451
lines changed

Some content is hidden

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

66 files changed

+2727
-451
lines changed

integration-test/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@
183183
<dependency>
184184
<groupId>org.bouncycastle</groupId>
185185
<artifactId>bcprov-jdk18on</artifactId>
186-
<scope>test</scope>
187186
</dependency>
188187
<dependency>
189188
<groupId>junit</groupId>

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

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,21 @@
1919

2020
package org.apache.iotdb.db.it;
2121

22+
import org.apache.iotdb.isession.ISession;
23+
import org.apache.iotdb.isession.SessionDataSet;
2224
import org.apache.iotdb.it.env.EnvFactory;
2325
import org.apache.iotdb.it.framework.IoTDBTestRunner;
2426
import org.apache.iotdb.itbase.category.ClusterIT;
2527
import org.apache.iotdb.itbase.category.LocalStandaloneIT;
28+
import org.apache.iotdb.rpc.IoTDBConnectionException;
29+
import org.apache.iotdb.rpc.StatementExecutionException;
2630

31+
import org.apache.tsfile.enums.TSDataType;
32+
import org.apache.tsfile.write.record.Tablet;
33+
import org.apache.tsfile.write.schema.IMeasurementSchema;
34+
import org.apache.tsfile.write.schema.MeasurementSchema;
2735
import org.junit.AfterClass;
36+
import org.junit.Assert;
2837
import org.junit.BeforeClass;
2938
import org.junit.Test;
3039
import org.junit.experimental.categories.Category;
@@ -34,6 +43,8 @@
3443
import java.sql.ResultSet;
3544
import java.sql.SQLException;
3645
import java.sql.Statement;
46+
import java.util.Collections;
47+
import java.util.List;
3748
import java.util.Locale;
3849

3950
import static org.junit.Assert.assertEquals;
@@ -181,4 +192,75 @@ public void testFlushNotExistGroupNoData() {
181192
fail(e.getMessage());
182193
}
183194
}
195+
196+
@Test
197+
public void testStreamingQueryMemTableWithOverlappedData()
198+
throws IoTDBConnectionException, StatementExecutionException {
199+
String device = "root.stream1.d1";
200+
try (ISession session = EnvFactory.getEnv().getSessionConnection()) {
201+
session.open();
202+
generateTimeRangeWithTimestamp(session, device, 1, 10);
203+
204+
generateTimeRangeWithTimestamp(session, device, 500000, 510000);
205+
session.executeNonQueryStatement("flush");
206+
generateTimeRangeWithTimestamp(session, device, 100000, 350000);
207+
208+
SessionDataSet sessionDataSet =
209+
session.executeQueryStatement("select count(*) from root.stream1.d1");
210+
SessionDataSet.DataIterator iterator = sessionDataSet.iterator();
211+
long count = 0;
212+
while (iterator.next()) {
213+
count = iterator.getLong(1);
214+
}
215+
Assert.assertEquals(10 + 10001 + 250001, count);
216+
}
217+
}
218+
219+
@Test
220+
public void testStreamingQueryMemTableWithOverlappedData2()
221+
throws IoTDBConnectionException, StatementExecutionException {
222+
String device = "root.stream2.d1";
223+
try (ISession session = EnvFactory.getEnv().getSessionConnection()) {
224+
session.open();
225+
generateTimeRangeWithTimestamp(session, device, 1, 10);
226+
227+
generateTimeRangeWithTimestamp(session, device, 500000, 510000);
228+
session.executeNonQueryStatement("flush");
229+
generateTimeRangeWithTimestamp(session, device, 1, 20);
230+
generateTimeRangeWithTimestamp(session, device, 100000, 210000);
231+
session.executeNonQueryStatement("flush");
232+
233+
generateTimeRangeWithTimestamp(session, device, 150000, 450000);
234+
235+
SessionDataSet sessionDataSet =
236+
session.executeQueryStatement("select count(*) from root.stream2.d1");
237+
SessionDataSet.DataIterator iterator = sessionDataSet.iterator();
238+
long count = 0;
239+
while (iterator.next()) {
240+
count = iterator.getLong(1);
241+
}
242+
Assert.assertEquals(20 + 10001 + 350001, count);
243+
}
244+
}
245+
246+
private static void generateTimeRangeWithTimestamp(
247+
ISession session, String device, long start, long end)
248+
throws IoTDBConnectionException, StatementExecutionException {
249+
List<IMeasurementSchema> measurementSchemas =
250+
Collections.singletonList(new MeasurementSchema("s1", TSDataType.INT64));
251+
Tablet tablet = new Tablet(device, measurementSchemas);
252+
for (long currentTime = start; currentTime <= end; currentTime++) {
253+
int rowIndex = tablet.getRowSize();
254+
if (rowIndex == tablet.getMaxRowNumber()) {
255+
session.insertTablet(tablet);
256+
tablet.reset();
257+
rowIndex = 0;
258+
}
259+
tablet.addTimestamp(rowIndex, currentTime);
260+
tablet.addValue(rowIndex, 0, currentTime);
261+
}
262+
if (tablet.getRowSize() > 0) {
263+
session.insertTablet(tablet);
264+
}
265+
}
184266
}

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ public class IoTDBResultSetIT {
5353
"CREATE DATABASE root.t1",
5454
"CREATE TIMESERIES root.t1.wf01.wt01.status WITH DATATYPE=BOOLEAN, ENCODING=PLAIN",
5555
"CREATE TIMESERIES root.t1.wf01.wt01.temperature WITH DATATYPE=FLOAT, ENCODING=RLE",
56-
"CREATE TIMESERIES root.t1.wf01.wt01.type WITH DATATYPE=INT32, ENCODING=RLE",
56+
"CREATE TIMESERIES root.t1.wf01.wt01.`type` WITH DATATYPE=INT32, ENCODING=RLE",
5757
"CREATE TIMESERIES root.t1.wf01.wt01.grade WITH DATATYPE=INT64, ENCODING=RLE",
5858
"CREATE TIMESERIES root.t1.wf01.wt02.status WITH DATATYPE=BOOLEAN, ENCODING=PLAIN",
5959
"CREATE TIMESERIES root.t1.wf01.wt02.temperature WITH DATATYPE=FLOAT, ENCODING=RLE",
60-
"CREATE TIMESERIES root.t1.wf01.wt02.type WITH DATATYPE=INT32, ENCODING=RLE",
60+
"CREATE TIMESERIES root.t1.wf01.wt02.`type` WITH DATATYPE=INT32, ENCODING=RLE",
6161
"CREATE TIMESERIES root.t1.wf01.wt02.grade WITH DATATYPE=INT64, ENCODING=RLE",
6262
"CREATE TIMESERIES root.sg.dev.status WITH DATATYPE=text,ENCODING=PLAIN",
6363
"insert into root.sg.dev(time,status) values(1,3.14)"
@@ -81,9 +81,9 @@ public void intAndLongConversionTest() {
8181
try (Connection connection = EnvFactory.getEnv().getConnection();
8282
Statement statement = connection.createStatement()) {
8383
statement.execute(
84-
"insert into root.t1.wf01.wt01(timestamp, status, type, grade) values (1000, true, 1, 1000)");
84+
"insert into root.t1.wf01.wt01(timestamp, status, `type`, grade) values (1000, true, 1, 1000)");
8585
statement.execute(
86-
"insert into root.t1.wf01.wt01(timestamp, status, type, grade) values (2000, false, 2, 2000)");
86+
"insert into root.t1.wf01.wt01(timestamp, status, `type`, grade) values (2000, false, 2, 2000)");
8787

8888
try (ResultSet resultSet1 =
8989
statement.executeQuery("select count(status) from root.t1.wf01.wt01")) {
@@ -94,7 +94,8 @@ public void intAndLongConversionTest() {
9494
}
9595

9696
try (ResultSet resultSet2 =
97-
statement.executeQuery("select type from root.t1.wf01.wt01 where time = 1000 limit 1")) {
97+
statement.executeQuery(
98+
"select `type` from root.t1.wf01.wt01 where time = 1000 limit 1")) {
9899
resultSet2.next();
99100
// type of r2 is INT32(int), test int convert to long
100101
long type = resultSet2.getLong(2);

0 commit comments

Comments
 (0)