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

haonan 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 181e835  [IOTDB-1844] Query support timeseries suffix matching (#4199)
181e835 is described below

commit 181e83567252252b3c6857459ab6c92fcbd3963b
Author: wangchao316 <[email protected]>
AuthorDate: Fri Oct 22 16:10:11 2021 +0800

    [IOTDB-1844] Query support timeseries suffix matching (#4199)
---
 .../org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4   |  2 +-
 .../iotdb/db/integration/IoTDBSimpleQueryIT.java   | 37 ++++++++++++++++++++++
 2 files changed, 38 insertions(+), 1 deletion(-)

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 fda69f2..b7043c9 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
@@ -660,7 +660,7 @@ suffixPath
     ;
 
 nodeName
-    : ID wildcard?
+    : wildcard? ID wildcard?
     | wildcard
     | (ID | OPERATOR_IN)? LS_BRACKET INTEGER_LITERAL? ID? RS_BRACKET? ID?
     | literalCanBeNodeName
diff --git 
a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBSimpleQueryIT.java 
b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBSimpleQueryIT.java
index e5fd141..04a281d 100644
--- 
a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBSimpleQueryIT.java
+++ 
b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBSimpleQueryIT.java
@@ -1321,4 +1321,41 @@ public class IoTDBSimpleQueryIT {
       }
     }
   }
+
+  @Test
+  public void testFromFuzzyMatching() throws ClassNotFoundException {
+    Class.forName(Config.JDBC_DRIVER_NAME);
+    try (Connection connection =
+            DriverManager.getConnection(
+                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+        Statement statement = connection.createStatement()) {
+      statement.execute("SET STORAGE GROUP TO root.sg1");
+      statement.execute(
+          "CREATE TIMESERIES root.sg1.d1.s1 with datatype=FLOAT, 
encoding=TS_2DIFF, "
+              + "max_point_number=4");
+      statement.execute(
+          "CREATE TIMESERIES root.sg1.d1.s2 with datatype=FLOAT, 
encoding=TS_2DIFF, "
+              + "max_point_number=2.5");
+      statement.execute(
+          "CREATE TIMESERIES root.sg1.d1.s3 with datatype=FLOAT, encoding=RLE, 
"
+              + "max_point_number=q");
+      statement.execute(
+          "CREATE TIMESERIES root.sg1.d1.s4 with datatype=FLOAT, encoding=RLE, 
"
+              + "max_point_number=-1");
+      statement.execute(
+          "insert into root.sg1.da1cb(timestamp,s1,s2,s3,s4) 
values(1,1.1234,1.1234,1.1234,1.1234)");
+      statement.execute(
+          "insert into root.sg1.da1ce(timestamp,s1,s2,s3,s4) 
values(1,1.1234,1.1234,1.1234,1.1234)");
+
+      try (ResultSet r1 = statement.executeQuery("select s1 from 
root.sg1.*a*")) {
+        while (r1.next()) {
+          Assert.assertEquals(1.1234f, r1.getFloat(2), 0);
+        }
+        Assert.assertEquals(3, r1.getMetaData().getColumnCount());
+      }
+
+    } catch (SQLException e) {
+      fail();
+    }
+  }
 }

Reply via email to