You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by hu...@apache.org on 2023/04/24 07:12:04 UTC

[iotdb] branch lmh/FixNodeName1.1 created (now 7d6b36e49c)

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

hui pushed a change to branch lmh/FixNodeName1.1
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at 7d6b36e49c [IOTDB-5774] Fix the syntax that path nodes start or end with a wildcard to fuzzy match is not supported (#9600)

This branch includes the following new commits:

     new 7d6b36e49c [IOTDB-5774] Fix the syntax that path nodes start or end with a wildcard to fuzzy match is not supported (#9600)

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.



[iotdb] 01/01: [IOTDB-5774] Fix the syntax that path nodes start or end with a wildcard to fuzzy match is not supported (#9600)

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

hui pushed a commit to branch lmh/FixNodeName1.1
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 7d6b36e49c536ba680b29e80ca77e04b7dfb8904
Author: liuminghui233 <36...@users.noreply.github.com>
AuthorDate: Fri Apr 21 09:21:47 2023 +0800

    [IOTDB-5774] Fix the syntax that path nodes start or end with a wildcard to fuzzy match is not supported (#9600)
    
    (cherry picked from commit e15a3c770bddb990c6d382e948c23bc22f2755ef)
---
 .../org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4   | 10 ++++--
 .../org/apache/iotdb/db/qp/sql/PathParser.g4       | 14 ++++++--
 .../db/it/IoTDBSyntaxConventionIdentifierIT.java   | 40 ++++++++++++++++++++++
 3 files changed, 60 insertions(+), 4 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 01116c54a1..bc1e294e5d 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
@@ -884,14 +884,20 @@ intoPath
 
 nodeName
     : wildcard
-    | wildcard? identifier wildcard?
-    | identifier
+    | wildcard nodeNameSlice wildcard?
+    | nodeNameSlice wildcard
+    | nodeNameWithoutWildcard
     ;
 
 nodeNameWithoutWildcard
     : identifier
     ;
 
+nodeNameSlice
+    : identifier
+    | INTEGER_LITERAL
+    ;
+
 nodeNameInIntoPath
     : nodeNameWithoutWildcard
     | DOUBLE_COLON
diff --git a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/PathParser.g4 b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/PathParser.g4
index 546be58b6e..eaf38e28ed 100644
--- a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/PathParser.g4
+++ b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/PathParser.g4
@@ -42,8 +42,18 @@ suffixPath
 
 nodeName
     : wildcard
-    | wildcard? identifier wildcard?
-    | identifier
+    | wildcard nodeNameSlice wildcard?
+    | nodeNameSlice wildcard
+    | nodeNameWithoutWildcard
+    ;
+
+nodeNameWithoutWildcard
+    : identifier
+    ;
+
+nodeNameSlice
+    : identifier
+    | INTEGER_LITERAL
     ;
 
 wildcard
diff --git a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBSyntaxConventionIdentifierIT.java b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBSyntaxConventionIdentifierIT.java
index 010b455907..5f9d9e9f5a 100644
--- a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBSyntaxConventionIdentifierIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBSyntaxConventionIdentifierIT.java
@@ -1063,4 +1063,44 @@ public class IoTDBSyntaxConventionIdentifierIT {
       fail();
     }
   }
+
+  @Test
+  public void testNodeNameWithWildcard() {
+    try (Connection connection = EnvFactory.getEnv().getConnection();
+        Statement statement = connection.createStatement()) {
+      statement.execute("CREATE TIMESERIES root.sg.device_123.s1 INT32");
+
+      try (ResultSet resultSet = statement.executeQuery("SHOW DEVICES root.sg.device_123")) {
+        Assert.assertTrue(resultSet.next());
+        Assert.assertFalse(resultSet.next());
+      }
+      try (ResultSet resultSet = statement.executeQuery("SHOW DEVICES root.sg.device_*")) {
+        Assert.assertTrue(resultSet.next());
+        Assert.assertFalse(resultSet.next());
+      }
+      try (ResultSet resultSet = statement.executeQuery("SHOW DEVICES root.sg.*_123")) {
+        Assert.assertTrue(resultSet.next());
+        Assert.assertFalse(resultSet.next());
+      }
+      try (ResultSet resultSet = statement.executeQuery("SHOW DEVICES root.sg.*123")) {
+        Assert.assertTrue(resultSet.next());
+        Assert.assertFalse(resultSet.next());
+      }
+      try (ResultSet resultSet = statement.executeQuery("SHOW DEVICES root.sg.*_12*")) {
+        Assert.assertTrue(resultSet.next());
+        Assert.assertFalse(resultSet.next());
+      }
+      try (ResultSet resultSet = statement.executeQuery("SHOW DEVICES root.sg.*12*")) {
+        Assert.assertTrue(resultSet.next());
+        Assert.assertFalse(resultSet.next());
+      }
+      try (ResultSet resultSet = statement.executeQuery("SHOW DEVICES root.sg.*e*")) {
+        Assert.assertTrue(resultSet.next());
+        Assert.assertFalse(resultSet.next());
+      }
+    } catch (SQLException e) {
+      e.printStackTrace();
+      fail();
+    }
+  }
 }