This is an automated email from the ASF dual-hosted git repository. rong pushed a commit to branch iotdb-1620 in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 9a63cbfc6deb8dde8b0cce6b6211aaf1ee5c6e1d Author: Steve Yurong Su <[email protected]> AuthorDate: Thu Oct 7 17:43:02 2021 +0800 fix IoTDBQuotedPathIT --- .../antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4 | 23 ++++++-------- .../iotdb/db/integration/IoTDBQuotedPathIT.java | 35 ++++++++++------------ 2 files changed, 25 insertions(+), 33 deletions(-) diff --git a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4 b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4 index 3dbf94b..58b7eb8 100644 --- a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4 +++ b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4 @@ -48,7 +48,7 @@ statement | FLUSH prefixPath? (COMMA prefixPath)* (booleanClause)?#flush | FULL MERGE #fullMerge | CLEAR CACHE #clearcache - | CREATE USER userName=ID password= stringLiteral#createUser + | CREATE USER userName=ID password=stringLiteral#createUser | ALTER USER userName=(ROOT|ID) SET PASSWORD password=stringLiteral #alterUser | DROP USER userName=ID #dropUser | CREATE ROLE roleName=ID #createRole @@ -517,6 +517,10 @@ triggerAttribute : key=stringLiteral OPERATOR_EQ value=stringLiteral ; +stringLiteral + : SINGLE_QUOTE_STRING_LITERAL + ; + //============================ // Start of the keywords list //============================ @@ -1376,19 +1380,6 @@ UNDERLINE : '_'; NaN : 'NaN'; -stringLiteral - : SINGLE_QUOTE_STRING_LITERAL - | DOUBLE_QUOTE_STRING_LITERAL - ; - -SINGLE_QUOTE_STRING_LITERAL - : '\'' ('\\' . | ~'\'' )*? '\'' - ; - -DOUBLE_QUOTE_STRING_LITERAL - : '"' ('\\' . | ~'"' )*? '"' - ; - INT : [0-9]+; EXPONENT : INT ('e'|'E') ('+'|'-')? INT ; @@ -1405,6 +1396,10 @@ DATETIME (('+' | '-') INT ':' INT)?)? ; +SINGLE_QUOTE_STRING_LITERAL + : '\'' ('\\' . | ~'\'' )*? '\'' + ; + ID : ID_CHAR+ | '"' (~('"' | '.') | '""')* '"' diff --git a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBQuotedPathIT.java b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBQuotedPathIT.java index 79bd685..d9a20e8 100644 --- a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBQuotedPathIT.java +++ b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBQuotedPathIT.java @@ -63,23 +63,21 @@ public class IoTDBQuotedPathIT { }; statement.execute("SET STORAGE GROUP TO root.ln"); statement.execute( - "CREATE TIMESERIES root.ln.\"wf.01\".wt01.\"status.2.3\" WITH DATATYPE=BOOLEAN, ENCODING=PLAIN"); + "CREATE TIMESERIES root.ln.\"wf+01\".wt01.\"status+2+3\" WITH DATATYPE=BOOLEAN, ENCODING=PLAIN"); statement.execute( - "INSERT INTO root.ln.\"wf.01\".wt01(timestamp,\"status.2.3\") values(1509465600000,true)"); + "INSERT INTO root.ln.\"wf+01\".wt01(timestamp,\"status+2+3\") values(1509465600000,true)"); statement.execute( - "INSERT INTO root.ln.\"wf.01\".wt01(timestamp,\"status.2.3\") values(1509465600001,true)"); + "INSERT INTO root.ln.\"wf+01\".wt01(timestamp,\"status+2+3\") values(1509465600001,true)"); statement.execute( - "INSERT INTO root.ln.\"wf.01\".wt01(timestamp,\"status.2.3\") values(1509465600002,false)"); + "INSERT INTO root.ln.\"wf+01\".wt01(timestamp,\"status+2+3\") values(1509465600002,false)"); statement.execute( - "INSERT INTO root.ln.\"wf.01\".wt01(timestamp,\"status.2.3\") values(1509465600003,false)"); + "INSERT INTO root.ln.\"wf+01\".wt01(timestamp,\"status+2+3\") values(1509465600003,false)"); statement.execute( - "CREATE TIMESERIES root.ln.\"wf.01\".wt02.\"abd\" WITH DATATYPE=BOOLEAN, ENCODING=PLAIN"); + "CREATE TIMESERIES root.ln.\"wf+01\".wt02.\"abd\" WITH DATATYPE=BOOLEAN, ENCODING=PLAIN"); statement.execute( - "CREATE TIMESERIES root.ln.\"wf.01\".wt02.\"asf.asd.sdf\" WITH DATATYPE=BOOLEAN, ENCODING=PLAIN"); - statement.execute( - "CREATE TIMESERIES root.ln.\"wf.01\".wt02.\"asd12\" WITH DATATYPE=BOOLEAN, ENCODING=PLAIN"); + "CREATE TIMESERIES root.ln.\"wf+01\".wt02.\"asd12\" WITH DATATYPE=BOOLEAN, ENCODING=PLAIN"); - boolean hasResultSet = statement.execute("SELECT * FROM root.ln.\"wf.01\".wt01"); + boolean hasResultSet = statement.execute("SELECT * FROM root.ln.\"wf+01\".wt01"); assertTrue(hasResultSet); ResultSet resultSet = statement.getResultSet(); try { @@ -90,7 +88,7 @@ public class IoTDBQuotedPathIT { } hasResultSet = - statement.execute("SELECT * FROM root.ln.\"wf.01\".wt01 WHERE \"status.2.3\" = false"); + statement.execute("SELECT * FROM root.ln.\"wf+01\".wt01 WHERE \"status+2+3\" = false"); assertTrue(hasResultSet); exp = new String[] {"1509465600002,false", "1509465600003,false"}; cnt = 0; @@ -102,14 +100,14 @@ public class IoTDBQuotedPathIT { hasResultSet = statement.execute( - "select \"status.2.3\", 'status.2.3' from root.ln.\"wf.01\".wt01 align by device"); + "select \"status+2+3\", 'status.2.3' from root.ln.\"wf+01\".wt01 align by device"); assertTrue(hasResultSet); exp = new String[] { - "1509465600000,root.ln.\"wf.01\".wt01,true,'status.2.3',", - "1509465600001,root.ln.\"wf.01\".wt01,true,'status.2.3',", - "1509465600002,root.ln.\"wf.01\".wt01,false,'status.2.3',", - "1509465600003,root.ln.\"wf.01\".wt01,false,'status.2.3'," + "1509465600000,root.ln.wf+01.wt01,true,'status.2.3',", + "1509465600001,root.ln.wf+01.wt01,true,'status.2.3',", + "1509465600002,root.ln.wf+01.wt01,false,'status.2.3',", + "1509465600003,root.ln.wf+01.wt01,false,'status.2.3'," }; cnt = 0; resultSet = statement.getResultSet(); @@ -122,8 +120,7 @@ public class IoTDBQuotedPathIT { } statement.execute( - "DELETE FROM root.ln.\"wf.01\".wt01.\"status.2.3\" WHERE time < 1509465600001"); - statement.execute("DELETE TIMESERIES root.ln.\"wf.01\".wt01.\"status.2.3\""); + "DELETE FROM root.ln.\"wf+01\".wt01.\"status+2+3\" WHERE time < 1509465600001"); } finally { resultSet.close(); } @@ -139,7 +136,7 @@ public class IoTDBQuotedPathIT { DriverManager.getConnection( Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root"); Statement statement = connection.createStatement()) { - statement.execute("SET STORAGE GROUP TO root.\"ln\""); + statement.execute("SET STORAGE GROUP TO root.`\"ln\"`"); } catch (IoTDBSQLException e) { Assert.assertEquals( "315: The storage group name can only be characters, numbers and underscores. root.\"ln\" is not a legal path",
