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/05/07 16:05:37 UTC
[iotdb] branch rel/1.1 updated: [To rel/1.1] [IOTDB-5774] Fix the syntax that path nodes start or end with a wildcard to fuzzy match is not supported (#9778)
This is an automated email from the ASF dual-hosted git repository.
hui pushed a commit to branch rel/1.1
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/rel/1.1 by this push:
new aafc4e499c9 [To rel/1.1] [IOTDB-5774] Fix the syntax that path nodes start or end with a wildcard to fuzzy match is not supported (#9778)
aafc4e499c9 is described below
commit aafc4e499c9b4567873d55515b5160c6c4d2ee55
Author: liuminghui233 <36...@users.noreply.github.com>
AuthorDate: Mon May 8 00:05:31 2023 +0800
[To rel/1.1] [IOTDB-5774] Fix the syntax that path nodes start or end with a wildcard to fuzzy match is not supported (#9778)
(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 01116c54a1e..bc1e294e5d3 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 546be58b6ee..eaf38e28edc 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 010b4559071..5f9d9e9f5a7 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();
+ }
+ }
}