Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IOTDB-446] Can not create or query time series whose path starts with a digit but has strings #843

Merged
merged 2 commits into from Feb 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 5 additions & 22 deletions server/src/main/antlr4/org/apache/iotdb/db/qp/strategy/SqlBase.g4
Expand Up @@ -293,12 +293,14 @@ nodeName
| INT
| STAR
| STRING_LITERAL
| DURATION
;

nodeNameWithoutStar
: INT
| ID
| STRING_LITERAL
| DURATION
;

dataType
Expand Down Expand Up @@ -814,39 +816,20 @@ DATETIME
(('+' | '-') INT ':' INT)?
;
/** Allow unicode rule/token names */
ID : NameStartChar NameChar*;
ID : NameChar NameChar*;

FILE
: (('a'..'z'| 'A'..'Z')(':')?)* (('\\' | '/')+ PATH_FRAGMENT) +
;

fragment
NameChar
: NameStartChar
: 'A'..'Z'
| 'a'..'z'
| '0'..'9'
| '_'
| '\u00B7'
| '\u0300'..'\u036F'
| '\u203F'..'\u2040'
;

fragment
NameStartChar
: 'A'..'Z'
| 'a'..'z'
| '\u00C0'..'\u00D6'
| '\u00D8'..'\u00F6'
| '\u00F8'..'\u02FF'
| '\u0370'..'\u037D'
| '\u037F'..'\u1FFF'
| '\u200C'..'\u200D'
| '\u2070'..'\u218F'
| '\u2C00'..'\u2FEF'
| '\u3001'..'\uD7FF'
| '\uF900'..'\uFDCF'
| '\uFDF0'..'\uFFFD'
; // ignores | ['\u10000-'\uEFFFF] ;

fragment DOUBLE_QUOTE_STRING_LITERAL
: '"' ('\\' . | ~'"' )*? '"'
;
Expand Down
Expand Up @@ -165,7 +165,7 @@ public void countSumAvgInnerIntervalTestWithValueFilter() {
boolean hasResultSet = statement.execute(
"select count(temperature), sum(temperature), avg(temperature) from "
+ "root.ln.wf01.wt01 where temperature > 3"
+ "GROUP BY ([1, 30), 3ms, 5ms)");
+ " GROUP BY ([1, 30), 3ms, 5ms)");

assertTrue(hasResultSet);
int cnt;
Expand Down Expand Up @@ -205,7 +205,7 @@ public void countSumAvgInnerIntervalTestWithTimeFilter() {
boolean hasResultSet = statement.execute(
"select count(temperature), sum(temperature), avg(temperature) from "
+ "root.ln.wf01.wt01 where time > 3"
+ "GROUP BY ([1, 30), 3ms, 5ms)");
+ " GROUP BY ([1, 30), 3ms, 5ms)");

assertTrue(hasResultSet);
int cnt;
Expand Down
16 changes: 12 additions & 4 deletions server/src/test/java/org/apache/iotdb/db/qp/PlannerTest.java
Expand Up @@ -101,8 +101,8 @@ public void parseSQLToPhysicalPlan() throws Exception {
PhysicalPlan plan1 = processor.parseSQLToPhysicalPlan(createSGStatement);
assertEquals(OperatorType.SET_STORAGE_GROUP, plan1.getOperatorType());

String createTSStatement = "create timeseries root.vehicle.d1.s1 with datatype=INT32,encoding=RLE";
PhysicalPlan plan2 = processor.parseSQLToPhysicalPlan(createTSStatement);
String createTSStatement1 = "create timeseries root.vehicle.d1.s1 with datatype=INT32,encoding=RLE";
PhysicalPlan plan2 = processor.parseSQLToPhysicalPlan(createTSStatement1);
assertEquals(OperatorType.CREATE_TIMESERIES, plan2.getOperatorType());

String deleteTSStatement = "delete timeseries root.vehicle.d1.s1";
Expand All @@ -117,8 +117,8 @@ public void parseSQLToPhysicalPlan() throws Exception {
PhysicalPlan plan6 = processor.parseSQLToPhysicalPlan(deleteStatement);
assertEquals(OperatorType.DELETE, plan6.getOperatorType());

String queryStatement = "select * from root.vehicle where root.vehicle.device1.sensor1 > 50";
PhysicalPlan plan7 = processor.parseSQLToPhysicalPlan(queryStatement);
String queryStatement1 = "select * from root.vehicle where root.vehicle.device1.sensor1 > 50";
PhysicalPlan plan7 = processor.parseSQLToPhysicalPlan(queryStatement1);
assertEquals(OperatorType.QUERY, plan7.getOperatorType());

String aggregationStatement = "select sum(*) from root.vehicle where root.vehicle.device1.sensor1 > 50";
Expand All @@ -136,6 +136,14 @@ public void parseSQLToPhysicalPlan() throws Exception {
String insertTimeStatement = "insert into root.vehicle.d0(time,s0) values(10,100)";
PhysicalPlan plan11 = processor.parseSQLToPhysicalPlan(insertTimeStatement);
assertEquals(OperatorType.INSERT, plan11.getOperatorType());

String createTSStatement2 = "create timeseries root.a.b.d_1.1s with datatype=FLOAT,encoding=RLE";
PhysicalPlan plan12 = processor.parseSQLToPhysicalPlan(createTSStatement2);
assertEquals(OperatorType.CREATE_TIMESERIES, plan12.getOperatorType());

String queryStatement2 = "select windDirection10min from root.national.4.5.585.9_6666.9_333.88_9";
PhysicalPlan plan13 = processor.parseSQLToPhysicalPlan(queryStatement2);
assertEquals(OperatorType.QUERY, plan13.getOperatorType());
}

@Test(expected = ParseCancellationException.class)
Expand Down