You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by "MarcosZyk (via GitHub)" <gi...@apache.org> on 2023/12/11 03:01:42 UTC

Re: [PR] Show devices with template [iotdb]

MarcosZyk commented on code in PR #11681:
URL: https://github.com/apache/iotdb/pull/11681#discussion_r1421898074


##########
integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBMetadataFetchIT.java:
##########
@@ -227,17 +227,34 @@ public void showStorageGroupTest() throws SQLException {
   public void showDevicesWithSgTest() throws SQLException {
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
+      statement.execute("CREATE DATABASE root.sg1");
+      statement.execute("CREATE DATABASE root.sg2");
+      statement.execute("CREATE DEVICE TEMPLATE t1 (s1 INT64, s2 DOUBLE)");
+      statement.execute("CREATE DEVICE TEMPLATE t2 aligned (s1 INT64, s2 DOUBLE)");
+      statement.execute("SET DEVICE TEMPLATE t1 TO root.sg1.d1");
+      statement.execute("SET DEVICE TEMPLATE t2 TO root.sg1.d2");
+      statement.execute("SET DEVICE TEMPLATE t1 TO root.sg2.d1");
+      statement.execute("SET DEVICE TEMPLATE t2 TO root.sg2.d2");
+      statement.execute("CREATE TIMESERIES OF DEVICE TEMPLATE ON root.sg1.d2");
+      statement.execute("CREATE TIMESERIES OF DEVICE TEMPLATE ON root.sg2.d1");
+      statement.execute("CREATE TIMESERIES OF DEVICE TEMPLATE ON root.sg2.d2");
+

Review Comment:
   Move these IT logic to a new test method named like "showDevicesWithTemplate".



##########
iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4:
##########
@@ -210,7 +210,11 @@ countNodes
 
 // ---- Timeseries Where Clause
 devicesWhereClause
-    : WHERE deviceContainsExpression
+    : WHERE (deviceContainsExpression | templateEqualExpression)
+    ;
+
+templateEqualExpression
+    : TEMPLATE (operator_eq | OPERATOR_NEQ)  templateName=identifier

Review Comment:
   Why these two operator, "operator_eq" and "OPERATOR_NEQ", is different in character case? Make the code style consistent.



##########
integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBMetadataFetchIT.java:
##########
@@ -292,6 +326,7 @@ public void showDevicesTest() throws SQLException {
               builder.append(resultSet.getString(i)).append(",");
             }
             String string = builder.toString();
+            System.out.println(string);

Review Comment:
   Remove this line of code used for debug.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org