You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ge...@apache.org on 2020/05/16 04:32:48 UTC

[incubator-iotdb] branch change_count_timeseries created (now 15dc68c)

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

geniuspig pushed a change to branch change_count_timeseries
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git.


      at 15dc68c  count_timeseries

This branch includes the following new commits:

     new 15dc68c  count_timeseries

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[incubator-iotdb] 01/01: count_timeseries

Posted by ge...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

geniuspig pushed a commit to branch change_count_timeseries
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git

commit 15dc68ce0d75db6a5a36e6670dc7a8ef75c1cef3
Author: zhutianci <zh...@gmail.com>
AuthorDate: Sat May 16 12:32:30 2020 +0800

    count_timeseries
---
 .../src/main/antlr4/org/apache/iotdb/db/qp/strategy/SqlBase.g4   | 2 +-
 .../java/org/apache/iotdb/db/qp/strategy/LogicalGenerator.java   | 9 +++++++--
 .../org/apache/iotdb/db/integration/IoTDBMetadataFetchIT.java    | 6 +++---
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/server/src/main/antlr4/org/apache/iotdb/db/qp/strategy/SqlBase.g4 b/server/src/main/antlr4/org/apache/iotdb/db/qp/strategy/SqlBase.g4
index e75f4d1..1c878bd 100644
--- a/server/src/main/antlr4/org/apache/iotdb/db/qp/strategy/SqlBase.g4
+++ b/server/src/main/antlr4/org/apache/iotdb/db/qp/strategy/SqlBase.g4
@@ -72,7 +72,7 @@ statement
     | SHOW STORAGE GROUP #showStorageGroup
     | SHOW CHILD PATHS prefixPath? #showChildPaths
     | SHOW DEVICES prefixPath? #showDevices
-    | COUNT TIMESERIES prefixPath (GROUP BY LEVEL OPERATOR_EQ INT)? #countTimeseries
+    | COUNT TIMESERIES prefixPath? (GROUP BY LEVEL OPERATOR_EQ INT)? #countTimeseries
     | COUNT NODES prefixPath LEVEL OPERATOR_EQ INT #countNodes
     | LOAD CONFIGURATION #loadConfigurationStatement
     | LOAD FILE autoCreateSchema? #loadFiles
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalGenerator.java b/server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalGenerator.java
index e3a7cee..c07c13e 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalGenerator.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalGenerator.java
@@ -76,8 +76,13 @@ public class LogicalGenerator extends SqlBaseBaseListener {
       initializedOperator = new CountOperator(SQLConstant.TOK_COUNT_NODE_TIMESERIES,
           parsePrefixPath(ctx.prefixPath()), Integer.parseInt(ctx.INT().getText()));
     } else {
-      initializedOperator = new CountOperator(SQLConstant.TOK_COUNT_TIMESERIES,
-          parsePrefixPath(ctx.prefixPath()));
+      if(ctx.prefixPath() != null) {
+        initializedOperator = new CountOperator(SQLConstant.TOK_COUNT_TIMESERIES,
+            parsePrefixPath(ctx.prefixPath()));
+      } else {
+        initializedOperator = new CountOperator(SQLConstant.TOK_COUNT_TIMESERIES,
+            new Path(SQLConstant.ROOT));
+      }
     }
   }
 
diff --git a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBMetadataFetchIT.java b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBMetadataFetchIT.java
index e07ed69..8ebc43b 100644
--- a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBMetadataFetchIT.java
+++ b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBMetadataFetchIT.java
@@ -274,8 +274,8 @@ public class IoTDBMetadataFetchIT {
     try (Connection connection = DriverManager
         .getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
         Statement statement = connection.createStatement()) {
-      String[] sqls = new String[]{"COUNT TIMESERIES root.ln"};
-      String[] standards = new String[]{"2,\n"};
+      String[] sqls = new String[]{"COUNT TIMESERIES root.ln", "COUNT TIMESERIES"};
+      String[] standards = new String[]{"2,\n", "2,\n"};
       for (int n = 0; n < sqls.length; n++) {
         String sql = sqls[n];
         String standard = standards[n];
@@ -293,7 +293,7 @@ public class IoTDBMetadataFetchIT {
               }
             }
           }
-          Assert.assertEquals(builder.toString(), standard);
+          Assert.assertEquals(standard, builder.toString());
         } catch (SQLException e) {
           e.printStackTrace();
           fail(e.getMessage());