Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -1529,7 +1529,16 @@ public List<ShowTimeSeriesResult> showTimeseries(ShowTimeSeriesPlan plan, QueryC
ExecutorService pool =
new ThreadPoolExecutor(
THREAD_POOL_SIZE, THREAD_POOL_SIZE, 0, TimeUnit.SECONDS, new LinkedBlockingDeque<>());
List<PartitionGroup> globalGroups = metaGroupMember.getPartitionTable().getGlobalGroups();

List<PartitionGroup> globalGroups = new ArrayList<>();
try {
PartitionGroup partitionGroup =
metaGroupMember.getPartitionTable().partitionByPathTime(plan.getPath(), 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

show timeseries root.* is not right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mychaow . this is have a situation, root.a.*
I will alter this.

globalGroups.add(partitionGroup);
} catch (MetadataException e) {
// if the path location is not find, obtain the path location from all groups.
globalGroups = metaGroupMember.getPartitionTable().getGlobalGroups();
}

int limit = plan.getLimit() == 0 ? Integer.MAX_VALUE : plan.getLimit();
int offset = plan.getOffset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,4 +277,15 @@ public void previousFill(
.previousFill(request, resultHandler))
.start();
}

@Override
public void getAllMeasurementSchema(
RaftNode header, ByteBuffer planBinary, AsyncMethodCallback<ByteBuffer> resultHandler) {
new Thread(
() -> {
new DataAsyncService(dataGroupMemberMap.get(header))
.getAllMeasurementSchema(header, planBinary, resultHandler);
})
.start();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.iotdb.db.metadata.PartialPath;
import org.apache.iotdb.db.metadata.mnode.StorageGroupMNode;
import org.apache.iotdb.db.qp.physical.crud.RawDataQueryPlan;
import org.apache.iotdb.db.qp.physical.sys.ShowTimeSeriesPlan;
import org.apache.iotdb.db.query.context.QueryContext;
import org.apache.iotdb.db.query.control.QueryResourceManager;
import org.apache.iotdb.db.service.IoTDB;
Expand Down Expand Up @@ -88,4 +89,24 @@ public void testGetAllStorageGroupNodes() {
allStorageGroupNodes.get(i).getFullPath());
}
}

@Test
public void testShowTimeseries()
throws StorageEngineException, QueryFilterOptimizationException, MetadataException,
IOException, InterruptedException, QueryProcessException {
ShowTimeSeriesPlan showTimeSeriesPlan = new ShowTimeSeriesPlan(pathList.get(0));
QueryContext context =
new RemoteQueryContext(QueryResourceManager.getInstance().assignQueryId(true, 1024, -1));
try {
QueryDataSet dataSet = queryExecutor.processQuery(showTimeSeriesPlan, context);
int count = 0;
while (dataSet.hasNext()) {
dataSet.next();
count++;
}
assertEquals(count, 1);
} finally {
QueryResourceManager.getInstance().endQuery(context.getQueryId());
}
}
}
83 changes: 83 additions & 0 deletions testcontainer/src/test/java/org/apache/iotdb/db/sql/Cases.java
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,87 @@ private void insertRecords() throws IoTDBConnectionException, StatementExecution

session.insertRecords(deviceIds, timestamps, measurementsList, typesList, valuesList);
}

// test https://issues.apache.org/jira/browse/IOTDB-1407
@Test
public void showTimeseriesTagsTest() throws SQLException {
String createTimeSeries1 =
"create timeseries root.ln.wf01.wt1 WITH DATATYPE=DOUBLE, ENCODING=RLE, compression=SNAPPY tags(tag1=v1, tag2=v2)";
String createTimeSeries2 =
"create timeseries root.ln.wf01.wt2 WITH DATATYPE=DOUBLE, ENCODING=RLE, compression=SNAPPY tags(tag1=v1, tag2=v2)";
writeStatement.execute(createTimeSeries1);
writeStatement.execute(createTimeSeries2);
// try to read data on each node. select .*
for (Statement readStatement : readStatements) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about adding some corner cases,such as SHOW TIMESERIES root.ln.wf01.* where tag1=v3, HOW TIMESERIES root.ln.wf01.* where tag3=v1

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done.

ResultSet resultSet =
readStatement.executeQuery("SHOW TIMESERIES root.ln.wf01.* where tag1=v1");
int cnt = 0;
while (resultSet.next()) {
cnt++;
}
Assert.assertEquals(2, cnt);
resultSet.close();
}

// try to read data on each node. select from parent series
for (Statement readStatement : readStatements) {
ResultSet resultSet =
readStatement.executeQuery("SHOW TIMESERIES root.ln.wf01 where tag1=v1");
int cnt = 0;
while (resultSet.next()) {
cnt++;
}
Assert.assertEquals(2, cnt);
resultSet.close();
}

// try to read data on each node. select from one series
for (Statement readStatement : readStatements) {
ResultSet resultSet =
readStatement.executeQuery("SHOW TIMESERIES root.ln.wf01.wt1 where tag1=v1");
int cnt = 0;
while (resultSet.next()) {
cnt++;
}
Assert.assertEquals(1, cnt);
resultSet.close();
}

// try to read data on each node. select from root
for (Statement readStatement : readStatements) {
ResultSet resultSet = readStatement.executeQuery("SHOW TIMESERIES root where tag1=v1");
int cnt = 0;
while (resultSet.next()) {
cnt++;
}
Assert.assertEquals(2, cnt);
resultSet.close();
}

// try to read data on each node. SHOW TIMESERIES root.ln.wf01.* where tag1=v3"
for (Statement readStatement : readStatements) {
ResultSet resultSet =
readStatement.executeQuery("SHOW TIMESERIES root.ln.wf01.* where tag1=v3");
int cnt = 0;
while (resultSet.next()) {
cnt++;
}
Assert.assertEquals(0, cnt);
resultSet.close();
}

// try to read data on each node. SHOW TIMESERIES root.ln.wf01.* where tag3=v1"
for (Statement readStatement : readStatements) {
ResultSet resultSet = null;
try {
resultSet = readStatement.executeQuery("SHOW TIMESERIES root.ln.wf01.* where tag3=v1");
} catch (Exception e) {
Assert.assertTrue(e.getMessage().contains("The key tag3 is not a tag"));
} finally {
if (resultSet != null) {
resultSet.close();
}
}
}
}
}