This is an automated email from the ASF dual-hosted git repository.
chaow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new d3acb18 [IOTDB-1407] Filtering time series based on tags query fails
Occasion… (#3292)
d3acb18 is described below
commit d3acb1883353e2b74264691c40c640fb197695d2
Author: wangchao316 <[email protected]>
AuthorDate: Thu Jul 8 09:44:19 2021 +0800
[IOTDB-1407] Filtering time series based on tags query fails Occasion…
(#3292)
---
.../apache/iotdb/cluster/metadata/CMManager.java | 11 ++-
.../iotdb/cluster/common/TestAsyncDataClient.java | 11 +++
.../cluster/query/ClusterPlanExecutorTest.java | 21 ++++++
.../test/java/org/apache/iotdb/db/sql/Cases.java | 83 ++++++++++++++++++++++
4 files changed, 125 insertions(+), 1 deletion(-)
diff --git
a/cluster/src/main/java/org/apache/iotdb/cluster/metadata/CMManager.java
b/cluster/src/main/java/org/apache/iotdb/cluster/metadata/CMManager.java
index e097ac6..f01870c 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/metadata/CMManager.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/metadata/CMManager.java
@@ -1529,7 +1529,16 @@ public class CMManager extends MManager {
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);
+ 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();
diff --git
a/cluster/src/test/java/org/apache/iotdb/cluster/common/TestAsyncDataClient.java
b/cluster/src/test/java/org/apache/iotdb/cluster/common/TestAsyncDataClient.java
index db34e54..c7b473d 100644
---
a/cluster/src/test/java/org/apache/iotdb/cluster/common/TestAsyncDataClient.java
+++
b/cluster/src/test/java/org/apache/iotdb/cluster/common/TestAsyncDataClient.java
@@ -277,4 +277,15 @@ public class TestAsyncDataClient extends AsyncDataClient {
.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();
+ }
}
diff --git
a/cluster/src/test/java/org/apache/iotdb/cluster/query/ClusterPlanExecutorTest.java
b/cluster/src/test/java/org/apache/iotdb/cluster/query/ClusterPlanExecutorTest.java
index 139280b..a0264bb 100644
---
a/cluster/src/test/java/org/apache/iotdb/cluster/query/ClusterPlanExecutorTest.java
+++
b/cluster/src/test/java/org/apache/iotdb/cluster/query/ClusterPlanExecutorTest.java
@@ -25,6 +25,7 @@ import
org.apache.iotdb.db.exception.query.QueryProcessException;
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;
@@ -88,4 +89,24 @@ public class ClusterPlanExecutorTest extends BaseQueryTest {
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());
+ }
+ }
}
diff --git a/testcontainer/src/test/java/org/apache/iotdb/db/sql/Cases.java
b/testcontainer/src/test/java/org/apache/iotdb/db/sql/Cases.java
index e78bebd..dc8f487 100644
--- a/testcontainer/src/test/java/org/apache/iotdb/db/sql/Cases.java
+++ b/testcontainer/src/test/java/org/apache/iotdb/db/sql/Cases.java
@@ -323,4 +323,87 @@ public abstract class Cases {
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) {
+ 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();
+ }
+ }
+ }
+ }
}