This is an automated email from the ASF dual-hosted git repository.

zyk 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 f96f3a52322 Schema query supports filtered by DataType  (#9891)
f96f3a52322 is described below

commit f96f3a52322e0346cd2050b3587e15d50828e611
Author: Chen YZ <[email protected]>
AuthorDate: Fri May 19 20:46:23 2023 +0800

    Schema query supports filtered by DataType  (#9891)
---
 .../org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4   |  6 +-
 docs/UserGuide/Operate-Metadata/Timeseries.md      | 28 +++++++++-
 docs/zh/UserGuide/Operate-Metadata/Timeseries.md   | 26 ++++++++-
 .../iotdb/db/it/schema/IoTDBMetadataFetchIT.java   |  6 +-
 .../iotdb/commons/schema/filter/SchemaFilter.java  |  3 +
 .../commons/schema/filter/SchemaFilterType.java    |  5 +-
 .../commons/schema/filter/SchemaFilterVisitor.java |  5 ++
 .../commons/schema/filter/impl/DataTypeFilter.java | 65 ++++++++++++++++++++++
 .../traverser/basic/MeasurementTraverser.java      |  6 ++
 .../iotdb/db/mpp/plan/parser/ASTVisitor.java       | 19 +++++++
 .../schemaRegion/SchemaRegionBasicTest.java        | 49 ++++++++++++++++
 11 files changed, 212 insertions(+), 6 deletions(-)

diff --git a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 
b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
index dfd4034f261..0642cf4c336 100644
--- a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
+++ b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
@@ -224,13 +224,17 @@ deviceContainsExpression
 
 // ---- Timeseries Where Clause
 timeseriesWhereClause
-    : WHERE (timeseriesContainsExpression | tagEqualsExpression | 
tagContainsExpression)
+    : WHERE (timeseriesContainsExpression | columnEqualsExpression | 
tagEqualsExpression | tagContainsExpression)
     ;
 
 timeseriesContainsExpression
     : TIMESERIES OPERATOR_CONTAINS value=STRING_LITERAL
     ;
 
+columnEqualsExpression
+    : attributeKey operator_eq attributeValue
+    ;
+
 tagEqualsExpression
     : TAGS LR_BRACKET key=attributeKey RR_BRACKET operator_eq 
value=attributeValue
     ;
diff --git a/docs/UserGuide/Operate-Metadata/Timeseries.md 
b/docs/UserGuide/Operate-Metadata/Timeseries.md
index 88c9544e444..b52a3b4abe0 100644
--- a/docs/UserGuide/Operate-Metadata/Timeseries.md
+++ b/docs/UserGuide/Operate-Metadata/Timeseries.md
@@ -157,10 +157,32 @@ The result is shown below:
 |  root.ln.wf01.wt01.temperature|    null|      root.ln|   FLOAT|     RLE|     
SNAPPY|                                       null|                             
                       null|    null|               null|
 |       root.ln.wf01.wt01.status|    null|      root.ln| BOOLEAN|   PLAIN|     
SNAPPY|                                       null|                             
                       null|    null|               null|
 
+-------------------------------+--------+-------------+--------+--------+-----------+-------------------------------------------+--------------------------------------------------------+--------+-------------------+
-Total line number = 7
+Total line number = 2
 It costs 0.016s
 ```
 
+* SHOW TIMESERIES WHERE DataType=type
+
+  The query result set is filtered by data type. For example:
+
+```
+show timeseries root.ln.** where dataType=FLOAT
+```
+
+The result is shown below:
+
+```
++-------------------------------+--------+-------------+--------+--------+-----------+-------------------------------------------+--------------------------------------------------------+--------+-------------------+
+|                     timeseries|   alias|     
database|dataType|encoding|compression|                                       
tags|                                              attributes|deadband|deadband 
parameters|
++-------------------------------+--------+-------------+--------+--------+-----------+-------------------------------------------+--------------------------------------------------------+--------+-------------------+
+|root.sgcc.wf03.wt01.temperature|    null|    root.sgcc|   FLOAT|     RLE|     
SNAPPY|                                       null|                             
                       null|    null|               null|
+|             root.turbine.d1.s1|newAlias| root.turbine|   FLOAT|     RLE|     
SNAPPY|{"newTag1":"newV1","tag4":"v4","tag3":"v3"}|{"attr2":"v2","attr1":"newV1","attr4":"v4","attr3":"v3"}|
    null|               null|
+|  root.ln.wf01.wt01.temperature|    null|      root.ln|   FLOAT|     RLE|     
SNAPPY|                                       null|                             
                       null|    null|               null|
++-------------------------------+--------+-------------+--------+--------+-----------+-------------------------------------------+--------------------------------------------------------+--------+-------------------+
+Total line number = 3
+It costs 0.016s
+
+```
 
 
 * SHOW LATEST TIMESERIES
@@ -175,7 +197,8 @@ It is worth noting that when the queried path does not 
exist, the system will re
 
 IoTDB is able to use `COUNT TIMESERIES <Path>` to count the number of 
timeseries matching the path. SQL statements are as follows:
 * `WHERE` condition could be used to fuzzy match a time series name with the 
following syntax: `COUNT TIMESERIES <Path> WHERE TIMESERIES contains 
'containStr'`.
-* `WHERE` condition could be used to filte result by tags with the syntax: 
`COUNT TIMESERIES <Path> WHERE TAGS(key)='value'` or `COUNT TIMESERIES <Path> 
WHERE TAGS(key) contains 'value'`.
+* `WHERE` condition could be used to filter result by data type with the 
syntax: `COUNT TIMESERIES <Path> WHERE DataType=<DataType>'`.
+* `WHERE` condition could be used to filter result by tags with the syntax: 
`COUNT TIMESERIES <Path> WHERE TAGS(key)='value'` or `COUNT TIMESERIES <Path> 
WHERE TAGS(key) contains 'value'`.
 * `LEVEL` could be defined to show count the number of timeseries of each node 
at the given level in current Metadata Tree. This could be used to query the 
number of sensors under each device. The grammar is: `COUNT TIMESERIES <Path> 
GROUP BY LEVEL=<INTEGER>`.
 
 
@@ -185,6 +208,7 @@ IoTDB > COUNT TIMESERIES root.ln.**
 IoTDB > COUNT TIMESERIES root.ln.*.*.status
 IoTDB > COUNT TIMESERIES root.ln.wf01.wt01.status
 IoTDB > COUNT TIMESERIES root.** WHERE TIMESERIES contains 'sgcc' 
+IoTDB > COUNT TIMESERIES root.** WHERE DATATYPE = INT64
 IoTDB > COUNT TIMESERIES root.** WHERE TAGS(unit) contains 'c' 
 IoTDB > COUNT TIMESERIES root.** WHERE TAGS(unit) = 'c' 
 IoTDB > COUNT TIMESERIES root.** WHERE TIMESERIES contains 'sgcc' group by 
level = 1
diff --git a/docs/zh/UserGuide/Operate-Metadata/Timeseries.md 
b/docs/zh/UserGuide/Operate-Metadata/Timeseries.md
index d6e8665ac17..df789e5f91d 100644
--- a/docs/zh/UserGuide/Operate-Metadata/Timeseries.md
+++ b/docs/zh/UserGuide/Operate-Metadata/Timeseries.md
@@ -153,10 +153,32 @@ show timeseries root.ln.** where timeseries contains 
'wf01.wt'
 |  root.ln.wf01.wt01.temperature|    null|      root.ln|   FLOAT|     RLE|     
SNAPPY|                                       null|                             
                       null|    null|               null|
 |       root.ln.wf01.wt01.status|    null|      root.ln| BOOLEAN|   PLAIN|     
SNAPPY|                                       null|                             
                       null|    null|               null|
 
+-------------------------------+--------+-------------+--------+--------+-----------+-------------------------------------------+--------------------------------------------------------+--------+-------------------+
-Total line number = 7
+Total line number = 2
 It costs 0.016s
 ```
 
+* SHOW TIMESERIES WHERE DataType=type
+
+  对查询结果集根据时间序列数据类型进行过滤。例如:
+
+```
+show timeseries root.ln.** where dataType=FLOAT
+```
+
+执行结果为:
+
+```
++-------------------------------+--------+-------------+--------+--------+-----------+-------------------------------------------+--------------------------------------------------------+--------+-------------------+
+|                     timeseries|   alias|     
database|dataType|encoding|compression|                                       
tags|                                              attributes|deadband|deadband 
parameters|
++-------------------------------+--------+-------------+--------+--------+-----------+-------------------------------------------+--------------------------------------------------------+--------+-------------------+
+|root.sgcc.wf03.wt01.temperature|    null|    root.sgcc|   FLOAT|     RLE|     
SNAPPY|                                       null|                             
                       null|    null|               null|
+|             root.turbine.d1.s1|newAlias| root.turbine|   FLOAT|     RLE|     
SNAPPY|{"newTag1":"newV1","tag4":"v4","tag3":"v3"}|{"attr2":"v2","attr1":"newV1","attr4":"v4","attr3":"v3"}|
    null|               null|
+|  root.ln.wf01.wt01.temperature|    null|      root.ln|   FLOAT|     RLE|     
SNAPPY|                                       null|                             
                       null|    null|               null|
++-------------------------------+--------+-------------+--------+--------+-----------+-------------------------------------------+--------------------------------------------------------+--------+-------------------+
+Total line number = 3
+It costs 0.016s
+
+```
 
 
 * SHOW LATEST TIMESERIES
@@ -171,6 +193,7 @@ It costs 0.016s
 IoTDB 支持使用`COUNT TIMESERIES<Path>`来统计一条路径中的时间序列个数。SQL 语句如下所示:
 
 * 可以通过 `WHERE` 条件对时间序列名称进行字符串模糊匹配,语法为: `COUNT TIMESERIES <Path> WHERE 
TIMESERIES contains 'containStr'` 。
+* 可以通过 `WHERE` 条件对时间序列数据类型进行过滤,语法为: `COUNT TIMESERIES <Path> WHERE 
DataType=<DataType>'`。
 * 可以通过 `WHERE` 条件对标签点进行过滤,语法为: `COUNT TIMESERIES <Path> WHERE 
TAGS(key)='value'` 或 `COUNT TIMESERIES <Path> WHERE TAGS(key) contains 'value'`。
 * 可以通过定义`LEVEL`来统计指定层级下的时间序列个数。这条语句可以用来统计每一个设备下的传感器数量,语法为:`COUNT TIMESERIES 
<Path> GROUP BY LEVEL=<INTEGER>`。
 
@@ -180,6 +203,7 @@ IoTDB > COUNT TIMESERIES root.ln.**
 IoTDB > COUNT TIMESERIES root.ln.*.*.status
 IoTDB > COUNT TIMESERIES root.ln.wf01.wt01.status
 IoTDB > COUNT TIMESERIES root.** WHERE TIMESERIES contains 'sgcc' 
+IoTDB > COUNT TIMESERIES root.** WHERE DATATYPE = INT64
 IoTDB > COUNT TIMESERIES root.** WHERE TAGS(unit) contains 'c' 
 IoTDB > COUNT TIMESERIES root.** WHERE TAGS(unit) = 'c' 
 IoTDB > COUNT TIMESERIES root.** WHERE TIMESERIES contains 'sgcc' group by 
level = 1
diff --git 
a/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBMetadataFetchIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBMetadataFetchIT.java
index a8af25771a8..552efcbeff6 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBMetadataFetchIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBMetadataFetchIT.java
@@ -119,7 +119,8 @@ public class IoTDBMetadataFetchIT extends AbstractSchemaIT {
             "show timeseries", // the same as root
             "show timeseries root.a.b", // nonexistent timeseries, thus 
returning ""
             "show timeseries root.** where timeseries contains 'tat'",
-            "show timeseries root.ln.** where timeseries contains 'wf01.wt01'"
+            "show timeseries root.ln.** where timeseries contains 'wf01.wt01'",
+            "show timeseries root.ln.** where dataType=BOOLEAN"
           };
       Set<String>[] standards =
           new Set[] {
@@ -156,6 +157,9 @@ public class IoTDBMetadataFetchIT extends AbstractSchemaIT {
                 Arrays.asList(
                     
"root.ln.wf01.wt01.status,null,root.ln.wf01.wt01,BOOLEAN,PLAIN,SNAPPY,null,null,null,null,,",
                     
"root.ln.wf01.wt01.temperature,null,root.ln.wf01.wt01,FLOAT,RLE,SNAPPY,null,null,null,null,,")),
+            new HashSet<>(
+                Collections.singletonList(
+                    
"root.ln.wf01.wt01.status,null,root.ln.wf01.wt01,BOOLEAN,PLAIN,SNAPPY,null,null,null,null,,"))
           };
       for (int n = 0; n < sqls.length; n++) {
         String sql = sqls[n];
diff --git 
a/node-commons/src/main/java/org/apache/iotdb/commons/schema/filter/SchemaFilter.java
 
b/node-commons/src/main/java/org/apache/iotdb/commons/schema/filter/SchemaFilter.java
index 6f1b04f508a..ccf9708c66b 100644
--- 
a/node-commons/src/main/java/org/apache/iotdb/commons/schema/filter/SchemaFilter.java
+++ 
b/node-commons/src/main/java/org/apache/iotdb/commons/schema/filter/SchemaFilter.java
@@ -18,6 +18,7 @@
  */
 package org.apache.iotdb.commons.schema.filter;
 
+import org.apache.iotdb.commons.schema.filter.impl.DataTypeFilter;
 import org.apache.iotdb.commons.schema.filter.impl.PathContainsFilter;
 import org.apache.iotdb.commons.schema.filter.impl.TagFilter;
 import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
@@ -57,6 +58,8 @@ public abstract class SchemaFilter {
         return new TagFilter(byteBuffer);
       case PATH_CONTAINS:
         return new PathContainsFilter(byteBuffer);
+      case DATA_TYPE:
+        return new DataTypeFilter(byteBuffer);
       default:
         throw new IllegalArgumentException("Unsupported schema filter type: " 
+ type);
     }
diff --git 
a/node-commons/src/main/java/org/apache/iotdb/commons/schema/filter/SchemaFilterType.java
 
b/node-commons/src/main/java/org/apache/iotdb/commons/schema/filter/SchemaFilterType.java
index 298a8381c90..fc02cd99525 100644
--- 
a/node-commons/src/main/java/org/apache/iotdb/commons/schema/filter/SchemaFilterType.java
+++ 
b/node-commons/src/main/java/org/apache/iotdb/commons/schema/filter/SchemaFilterType.java
@@ -21,7 +21,8 @@ package org.apache.iotdb.commons.schema.filter;
 public enum SchemaFilterType {
   NULL((short) -1),
   TAGS_FILTER((short) 1),
-  PATH_CONTAINS((short) 2);
+  PATH_CONTAINS((short) 2),
+  DATA_TYPE((short) 3);
 
   private final short code;
 
@@ -41,6 +42,8 @@ public enum SchemaFilterType {
         return TAGS_FILTER;
       case 2:
         return PATH_CONTAINS;
+      case 3:
+        return DATA_TYPE;
       default:
         throw new IllegalArgumentException("Invalid input: " + code);
     }
diff --git 
a/node-commons/src/main/java/org/apache/iotdb/commons/schema/filter/SchemaFilterVisitor.java
 
b/node-commons/src/main/java/org/apache/iotdb/commons/schema/filter/SchemaFilterVisitor.java
index 6d3374db2ab..2c32e8a7129 100644
--- 
a/node-commons/src/main/java/org/apache/iotdb/commons/schema/filter/SchemaFilterVisitor.java
+++ 
b/node-commons/src/main/java/org/apache/iotdb/commons/schema/filter/SchemaFilterVisitor.java
@@ -18,6 +18,7 @@
  */
 package org.apache.iotdb.commons.schema.filter;
 
+import org.apache.iotdb.commons.schema.filter.impl.DataTypeFilter;
 import org.apache.iotdb.commons.schema.filter.impl.PathContainsFilter;
 import org.apache.iotdb.commons.schema.filter.impl.TagFilter;
 
@@ -51,4 +52,8 @@ public abstract class SchemaFilterVisitor<R, C> {
   public R visitPathContainsFilter(PathContainsFilter pathContainsFilter, C 
context) {
     return visitFilter(pathContainsFilter, context);
   }
+
+  public R visitDataTypeFilter(DataTypeFilter dataTypeFilter, C context) {
+    return visitFilter(dataTypeFilter, context);
+  }
 }
diff --git 
a/node-commons/src/main/java/org/apache/iotdb/commons/schema/filter/impl/DataTypeFilter.java
 
b/node-commons/src/main/java/org/apache/iotdb/commons/schema/filter/impl/DataTypeFilter.java
new file mode 100644
index 00000000000..d48f8893ccb
--- /dev/null
+++ 
b/node-commons/src/main/java/org/apache/iotdb/commons/schema/filter/impl/DataTypeFilter.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iotdb.commons.schema.filter.impl;
+
+import org.apache.iotdb.commons.schema.filter.SchemaFilter;
+import org.apache.iotdb.commons.schema.filter.SchemaFilterType;
+import org.apache.iotdb.commons.schema.filter.SchemaFilterVisitor;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+public class DataTypeFilter extends SchemaFilter {
+
+  private final TSDataType dataType;
+
+  public DataTypeFilter(TSDataType dataType) {
+    this.dataType = dataType;
+  }
+
+  public DataTypeFilter(ByteBuffer byteBuffer) {
+    this.dataType = TSDataType.deserializeFrom(byteBuffer);
+  }
+
+  public TSDataType getDataType() {
+    return dataType;
+  }
+
+  @Override
+  public <R, C> R accept(SchemaFilterVisitor<R, C> visitor, C node) {
+    return visitor.visitDataTypeFilter(this, node);
+  }
+
+  @Override
+  public SchemaFilterType getSchemaFilterType() {
+    return SchemaFilterType.DATA_TYPE;
+  }
+
+  @Override
+  protected void serialize(ByteBuffer byteBuffer) {
+    dataType.serializeTo(byteBuffer);
+  }
+
+  @Override
+  protected void serialize(DataOutputStream stream) throws IOException {
+    dataType.serializeTo(stream);
+  }
+}
diff --git 
a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/traverser/basic/MeasurementTraverser.java
 
b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/traverser/basic/MeasurementTraverser.java
index 560601315c2..882852d052c 100644
--- 
a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/traverser/basic/MeasurementTraverser.java
+++ 
b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/traverser/basic/MeasurementTraverser.java
@@ -23,6 +23,7 @@ import org.apache.iotdb.commons.exception.MetadataException;
 import org.apache.iotdb.commons.path.PartialPath;
 import org.apache.iotdb.commons.schema.filter.SchemaFilter;
 import org.apache.iotdb.commons.schema.filter.SchemaFilterVisitor;
+import org.apache.iotdb.commons.schema.filter.impl.DataTypeFilter;
 import org.apache.iotdb.commons.schema.filter.impl.PathContainsFilter;
 import org.apache.iotdb.commons.schema.node.IMNode;
 import org.apache.iotdb.db.metadata.mtree.store.IMTreeStore;
@@ -90,5 +91,10 @@ public abstract class MeasurementTraverser<R, N extends 
IMNode<N>> extends Trave
           .toLowerCase()
           .contains(pathContainsFilter.getContainString());
     }
+
+    @Override
+    public Boolean visitDataTypeFilter(DataTypeFilter dataTypeFilter, N node) {
+      return node.getAsMeasurementMNode().getSchema().getType() == 
dataTypeFilter.getDataType();
+    }
   }
 }
diff --git 
a/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java 
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java
index 6f4f57a6de7..869add24d41 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java
@@ -29,6 +29,7 @@ import org.apache.iotdb.commons.cq.TimeoutPolicy;
 import org.apache.iotdb.commons.exception.IllegalPathException;
 import org.apache.iotdb.commons.path.PartialPath;
 import org.apache.iotdb.commons.schema.filter.SchemaFilter;
+import org.apache.iotdb.commons.schema.filter.impl.DataTypeFilter;
 import org.apache.iotdb.commons.schema.filter.impl.PathContainsFilter;
 import org.apache.iotdb.commons.schema.filter.impl.TagFilter;
 import org.apache.iotdb.commons.utils.PathUtils;
@@ -607,6 +608,8 @@ public class ASTVisitor extends 
IoTDBSqlParserBaseVisitor<Statement> {
       // path contains filter
       return new PathContainsFilter(
           
parseStringLiteral(ctx.timeseriesContainsExpression().value.getText()));
+    } else if (ctx.columnEqualsExpression() != null) {
+      return parseColumnEqualsExpressionContext(ctx.columnEqualsExpression());
     } else {
       // tag filter
       if (ctx.tagContainsExpression() != null) {
@@ -623,6 +626,22 @@ public class ASTVisitor extends 
IoTDBSqlParserBaseVisitor<Statement> {
     }
   }
 
+  private SchemaFilter parseColumnEqualsExpressionContext(
+      IoTDBSqlParser.ColumnEqualsExpressionContext ctx) {
+    String column = parseAttributeKey(ctx.attributeKey());
+    String value = parseAttributeValue(ctx.attributeValue());
+    if (column.equalsIgnoreCase(IoTDBConstant.COLUMN_TIMESERIES_DATATYPE)) {
+      try {
+        TSDataType dataType = TSDataType.valueOf(value.toUpperCase());
+        return new DataTypeFilter(dataType);
+      } catch (Exception e) {
+        throw new SemanticException(String.format("unsupported datatype: %s", 
value));
+      }
+    } else {
+      throw new SemanticException("unexpected filter key");
+    }
+  }
+
   // SHOW DATABASES
 
   @Override
diff --git 
a/server/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionBasicTest.java
 
b/server/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionBasicTest.java
index 7308c52b8d9..2cf0efb4fee 100644
--- 
a/server/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionBasicTest.java
+++ 
b/server/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionBasicTest.java
@@ -22,6 +22,7 @@ import org.apache.iotdb.commons.exception.MetadataException;
 import org.apache.iotdb.commons.path.MeasurementPath;
 import org.apache.iotdb.commons.path.PartialPath;
 import org.apache.iotdb.commons.path.PathPatternTree;
+import org.apache.iotdb.commons.schema.filter.impl.DataTypeFilter;
 import org.apache.iotdb.commons.schema.filter.impl.PathContainsFilter;
 import org.apache.iotdb.commons.schema.node.MNodeType;
 import org.apache.iotdb.db.exception.metadata.AliasAlreadyExistException;
@@ -876,6 +877,54 @@ public class SchemaRegionBasicTest extends 
AbstractSchemaRegionTest {
       actualPathList.add(result.get(index).getFullPath());
     }
     Assert.assertEquals(expectedPathList, actualPathList);
+
+    // CASE 06: show timeseries where dataType=INT64
+    result =
+        SchemaRegionTestUtil.showTimeseries(
+            schemaRegion,
+            SchemaRegionReadPlanFactory.getShowTimeSeriesPlan(
+                new PartialPath("root.**"),
+                Collections.emptyMap(),
+                0,
+                0,
+                false,
+                new DataTypeFilter(TSDataType.INT64)));
+    expectedPathList =
+        new HashSet<>(
+            Arrays.asList(
+                "root.laptop.d0",
+                "root.laptop.d1.s1",
+                "root.laptop.d1.s2.t1",
+                "root.laptop.d1.s3",
+                "root.laptop.d2.s1",
+                "root.laptop.d2.s2"));
+    expectedSize = expectedPathList.size();
+    Assert.assertEquals(expectedSize, result.size());
+    actualPathList = new HashSet<>();
+    for (int index = 0; index < expectedSize; index++) {
+      actualPathList.add(result.get(index).getFullPath());
+    }
+    Assert.assertEquals(expectedPathList, actualPathList);
+
+    // CASE 07: show timeseries where dataType=BOOLEAN
+    result =
+        SchemaRegionTestUtil.showTimeseries(
+            schemaRegion,
+            SchemaRegionReadPlanFactory.getShowTimeSeriesPlan(
+                new PartialPath("root.**"),
+                Collections.emptyMap(),
+                0,
+                0,
+                false,
+                new DataTypeFilter(TSDataType.BOOLEAN)));
+    expectedPathList = new HashSet<>(Collections.emptyList());
+    expectedSize = expectedPathList.size();
+    Assert.assertEquals(expectedSize, result.size());
+    actualPathList = new HashSet<>();
+    for (int index = 0; index < expectedSize; index++) {
+      actualPathList.add(result.get(index).getFullPath());
+    }
+    Assert.assertEquals(expectedPathList, actualPathList);
   }
 
   @Test

Reply via email to