Skip to content

Commit

Permalink
solve node name.
Browse files Browse the repository at this point in the history
  • Loading branch information
Genius-pig committed Feb 26, 2020
1 parent 700f9a9 commit acbbd79
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 26 deletions.
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
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

0 comments on commit acbbd79

Please sign in to comment.