Skip to content

Commit 4771a8d

Browse files
authored
Merge pull request #2 from apache/master
merge master
2 parents e705465 + 78954ea commit 4771a8d

File tree

251 files changed

+7569
-4959
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

251 files changed

+7569
-4959
lines changed

LICENSE-binary

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ commons-lang:commons-lang:2.6
224224
com.nimbusds:content-type:2.0
225225
com.google.code.gson:gson:2.8.6
226226
it.unimi.dsi:fastutil:7.0.6
227-
com.google.guava.guava:21.0
227+
com.google.guava.guava:24.1.1
228228
com.fasterxml.jackson.core:jackson-annotations:2.10.0
229229
com.fasterxml.jackson.core:jackson-core:2.10.0
230230
com.fasterxml.jackson.core:jackson-databind:2.10.0

antlr/src/main/antlr4/org/apache/iotdb/db/qp/strategy/SqlBase.g4

Lines changed: 50 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -19,62 +19,66 @@
1919

2020
grammar SqlBase;
2121

22-
@parser::members {public static boolean hasSingleQuoteString;}
23-
2422
singleStatement
2523
: statement EOF
2624
;
2725

26+
/*
27+
* According to The Definitive ANTLR 4 Reference, 11. Altering the Parse with Semantic Predicates, Altering the Parse with Semantic Predicates.
28+
* "It s a good idea to avoid embedding predicates in the parser when possible for efficiency and clarity reasons."
29+
* So if unnecessary, don't use embedding predicates.
30+
*/
31+
2832
statement
29-
: {hasSingleQuoteString = false;} CREATE TIMESERIES fullPath alias? WITH attributeClauses #createTimeseries
30-
| {hasSingleQuoteString = false;} DELETE TIMESERIES prefixPath (COMMA prefixPath)* #deleteTimeseries
31-
| {hasSingleQuoteString = false;} ALTER TIMESERIES fullPath alterClause #alterTimeseries
32-
| {hasSingleQuoteString = false;} INSERT INTO prefixPath insertColumnSpec VALUES insertValuesSpec #insertStatement
33-
| {hasSingleQuoteString = false;} UPDATE prefixPath setClause whereClause? #updateStatement
34-
| {hasSingleQuoteString = false;} DELETE FROM prefixPath (COMMA prefixPath)* (whereClause)? #deleteStatement
35-
| {hasSingleQuoteString = false;} SET STORAGE GROUP TO prefixPath #setStorageGroup
36-
| {hasSingleQuoteString = false;} DELETE STORAGE GROUP prefixPath (COMMA prefixPath)* #deleteStorageGroup
33+
: CREATE TIMESERIES fullPath alias? WITH attributeClauses #createTimeseries
34+
| DELETE TIMESERIES prefixPath (COMMA prefixPath)* #deleteTimeseries
35+
| ALTER TIMESERIES fullPath alterClause #alterTimeseries
36+
| INSERT INTO prefixPath insertColumnSpec VALUES insertValuesSpec #insertStatement
37+
| UPDATE prefixPath setClause whereClause? #updateStatement
38+
| DELETE FROM prefixPath (COMMA prefixPath)* (whereClause)? #deleteStatement
39+
| SET STORAGE GROUP TO prefixPath #setStorageGroup
40+
| DELETE STORAGE GROUP prefixPath (COMMA prefixPath)* #deleteStorageGroup
3741
| SHOW METADATA #showMetadata // not support yet
3842
| DESCRIBE prefixPath #describePath // not support yet
3943
| CREATE INDEX ON fullPath USING function=ID indexWithClause? whereClause? #createIndex //not support yet
4044
| DROP INDEX function=ID ON fullPath #dropIndex //not support yet
4145
| MERGE #merge
42-
| {hasSingleQuoteString = false;}FLUSH prefixPath? (COMMA prefixPath)* (booleanClause)?#flush
46+
| FLUSH prefixPath? (COMMA prefixPath)* (booleanClause)?#flush
4347
| FULL MERGE #fullMerge
4448
| CLEAR CACHE #clearcache
45-
| {hasSingleQuoteString = true;} CREATE USER userName=ID password= stringLiteral#createUser
46-
| {hasSingleQuoteString = true;} ALTER USER userName=(ROOT|ID) SET PASSWORD password=stringLiteral #alterUser
49+
| CREATE USER userName=ID password= stringLiteral#createUser
50+
| ALTER USER userName=(ROOT|ID) SET PASSWORD password=stringLiteral #alterUser
4751
| DROP USER userName=ID #dropUser
4852
| CREATE ROLE roleName=ID #createRole
4953
| DROP ROLE roleName=ID #dropRole
50-
| GRANT USER userName=ID PRIVILEGES privileges ON {hasSingleQuoteString = false;} prefixPath #grantUser
51-
| GRANT ROLE roleName=ID PRIVILEGES privileges ON {hasSingleQuoteString = false;} prefixPath #grantRole
52-
| REVOKE USER userName=ID PRIVILEGES privileges ON {hasSingleQuoteString = false;} prefixPath #revokeUser
53-
| REVOKE ROLE roleName=ID PRIVILEGES privileges ON {hasSingleQuoteString = false;} prefixPath #revokeRole
54+
| GRANT USER userName=ID PRIVILEGES privileges ON prefixPath #grantUser
55+
| GRANT ROLE roleName=ID PRIVILEGES privileges ON prefixPath #grantRole
56+
| REVOKE USER userName=ID PRIVILEGES privileges ON prefixPath #revokeUser
57+
| REVOKE ROLE roleName=ID PRIVILEGES privileges ON prefixPath #revokeRole
5458
| GRANT roleName=ID TO userName=ID #grantRoleToUser
5559
| REVOKE roleName = ID FROM userName = ID #revokeRoleFromUser
56-
| {hasSingleQuoteString = true;} LOAD TIMESERIES (fileName=stringLiteral) prefixPath#loadStatement
60+
| LOAD TIMESERIES (fileName=stringLiteral) prefixPath#loadStatement
5761
| GRANT WATERMARK_EMBEDDING TO rootOrId (COMMA rootOrId)* #grantWatermarkEmbedding
5862
| REVOKE WATERMARK_EMBEDDING FROM rootOrId (COMMA rootOrId)* #revokeWatermarkEmbedding
5963
| LIST USER #listUser
6064
| LIST ROLE #listRole
61-
| LIST PRIVILEGES USER username=rootOrId ON {hasSingleQuoteString = false;} prefixPath #listPrivilegesUser
62-
| LIST PRIVILEGES ROLE roleName=ID ON {hasSingleQuoteString = false;} prefixPath #listPrivilegesRole
65+
| LIST PRIVILEGES USER username=rootOrId ON prefixPath #listPrivilegesUser
66+
| LIST PRIVILEGES ROLE roleName=ID ON prefixPath #listPrivilegesRole
6367
| LIST USER PRIVILEGES username =rootOrId #listUserPrivileges
6468
| LIST ROLE PRIVILEGES roleName = ID #listRolePrivileges
6569
| LIST ALL ROLE OF USER username = rootOrId #listAllRoleOfUser
6670
| LIST ALL USER OF ROLE roleName = ID #listAllUserOfRole
67-
| {hasSingleQuoteString = false;} SET TTL TO path=prefixPath time=INT #setTTLStatement
68-
| {hasSingleQuoteString = false;} UNSET TTL TO path=prefixPath #unsetTTLStatement
69-
| {hasSingleQuoteString = false;} SHOW TTL ON prefixPath (COMMA prefixPath)* #showTTLStatement
71+
| SET TTL TO path=prefixPath time=INT #setTTLStatement
72+
| UNSET TTL TO path=prefixPath #unsetTTLStatement
73+
| SHOW TTL ON prefixPath (COMMA prefixPath)* #showTTLStatement
7074
| SHOW ALL TTL #showAllTTLStatement
7175
| SHOW FLUSH TASK INFO #showFlushTaskInfo
7276
| SHOW DYNAMIC PARAMETER #showDynamicParameter
7377
| SHOW VERSION #showVersion
74-
| {hasSingleQuoteString = false;} SHOW LATEST? TIMESERIES prefixPath? showWhereClause? limitClause? #showTimeseries
75-
| {hasSingleQuoteString = false;} SHOW STORAGE GROUP prefixPath? #showStorageGroup
76-
| {hasSingleQuoteString = false;} SHOW CHILD PATHS prefixPath? #showChildPaths
77-
| {hasSingleQuoteString = false;} SHOW DEVICES prefixPath? #showDevices
78+
| SHOW LATEST? TIMESERIES prefixPath? showWhereClause? limitClause? #showTimeseries
79+
| SHOW STORAGE GROUP prefixPath? #showStorageGroup
80+
| SHOW CHILD PATHS prefixPath? #showChildPaths
81+
| SHOW DEVICES prefixPath? #showDevices
7882
| SHOW MERGE #showMergeStatus
7983
| TRACING ON #tracingOn
8084
| TRACING OFF #tracingOff
@@ -83,10 +87,10 @@ statement
8387
| COUNT STORAGE GROUP prefixPath? #countStorageGroup
8488
| COUNT NODES prefixPath LEVEL OPERATOR_EQ INT #countNodes
8589
| LOAD CONFIGURATION (MINUS GLOBAL)? #loadConfigurationStatement
86-
| {hasSingleQuoteString = true;} LOAD stringLiteral autoCreateSchema?#loadFiles
87-
| {hasSingleQuoteString = true;} REMOVE stringLiteral #removeFile
88-
| {hasSingleQuoteString = true;} MOVE stringLiteral stringLiteral #moveFile
89-
| {hasSingleQuoteString = false;} DELETE PARTITION prefixPath INT(COMMA INT)* #deletePartition
90+
| LOAD stringLiteral autoCreateSchema?#loadFiles
91+
| REMOVE stringLiteral #removeFile
92+
| MOVE stringLiteral stringLiteral #moveFile
93+
| DELETE PARTITION prefixPath INT(COMMA INT)* #deletePartition
9094
| CREATE SNAPSHOT FOR SCHEMA #createSnapshot
9195
| SELECT INDEX func=ID //not support yet
9296
LR_BRACKET
@@ -96,20 +100,25 @@ statement
96100
fromClause
97101
whereClause?
98102
specialClause? #selectIndexStatement
99-
| {hasSingleQuoteString = true;} SELECT selectElements
103+
| SELECT selectElements
100104
fromClause
101105
whereClause?
102106
specialClause? #selectStatement
103107
;
104108

105109
selectElements
106110
: functionCall (COMMA functionCall)* #functionElement
107-
| suffixPath (COMMA suffixPath)* #selectElement
111+
| suffixPathOrConstant (COMMA suffixPathOrConstant)* #selectElement
108112
| lastClause #lastElement
109113
| asClause (COMMA asClause)* #asElement
110114
| functionAsClause (COMMA functionAsClause)* #functionAsElement
111115
;
112116

117+
suffixPathOrConstant
118+
: suffixPath
119+
| SINGLE_QUOTE_STRING_LITERAL
120+
;
121+
113122
functionCall
114123
: functionName LR_BRACKET suffixPath RR_BRACKET
115124
;
@@ -157,7 +166,7 @@ aliasClause
157166
;
158167

159168
attributeClauses
160-
: DATATYPE OPERATOR_EQ dataType COMMA ENCODING OPERATOR_EQ encoding
169+
: DATATYPE OPERATOR_EQ dataType (COMMA ENCODING OPERATOR_EQ encoding)?
161170
(COMMA (COMPRESSOR | COMPRESSION) OPERATOR_EQ compressor)?
162171
(COMMA property)*
163172
tagClause
@@ -216,7 +225,7 @@ inClause
216225
;
217226

218227
fromClause
219-
: {hasSingleQuoteString = false;} FROM prefixPath (COMMA prefixPath)*
228+
: FROM prefixPath (COMMA prefixPath)*
220229
;
221230

222231
specialClause
@@ -352,7 +361,7 @@ setCol
352361
;
353362

354363
privileges
355-
: {hasSingleQuoteString = true;} stringLiteral (COMMA stringLiteral)*
364+
: stringLiteral (COMMA stringLiteral)*
356365
;
357366

358367
rootOrId
@@ -374,7 +383,7 @@ timeValue
374383
propertyValue
375384
: INT
376385
| ID
377-
| {hasSingleQuoteString = true;} stringLiteral
386+
| stringLiteral
378387
| constant
379388
;
380389

@@ -393,7 +402,7 @@ suffixPath
393402
nodeName
394403
: ID
395404
| STAR
396-
| stringLiteral
405+
| DOUBLE_QUOTE_STRING_LITERAL
397406
| ID STAR
398407
| DURATION
399408
| encoding
@@ -504,7 +513,7 @@ nodeName
504513

505514
nodeNameWithoutStar
506515
: ID
507-
| stringLiteral
516+
| DOUBLE_QUOTE_STRING_LITERAL
508517
| DURATION
509518
| encoding
510519
| dataType
@@ -626,7 +635,7 @@ constant
626635
| NaN
627636
| MINUS? realLiteral
628637
| MINUS? INT
629-
| {hasSingleQuoteString = true;} stringLiteral
638+
| stringLiteral
630639
| booleanClause
631640
;
632641

@@ -1241,7 +1250,7 @@ UNDERLINE : '_';
12411250
NaN : 'NaN';
12421251

12431252
stringLiteral
1244-
: {hasSingleQuoteString}? SINGLE_QUOTE_STRING_LITERAL
1253+
: SINGLE_QUOTE_STRING_LITERAL
12451254
| DOUBLE_QUOTE_STRING_LITERAL
12461255
;
12471256

cli/pom.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@
4040
<artifactId>iotdb-jdbc</artifactId>
4141
<version>${project.version}</version>
4242
</dependency>
43+
<dependency>
44+
<groupId>org.apache.iotdb</groupId>
45+
<artifactId>iotdb-server</artifactId>
46+
<version>${project.version}</version>
47+
<type>test-jar</type>
48+
<scope>test</scope>
49+
</dependency>
4350
<dependency>
4451
<groupId>commons-cli</groupId>
4552
<artifactId>commons-cli</artifactId>
@@ -57,6 +64,12 @@
5764
<groupId>jline</groupId>
5865
<artifactId>jline</artifactId>
5966
</dependency>
67+
<dependency>
68+
<groupId>org.apache.iotdb</groupId>
69+
<artifactId>iotdb-server</artifactId>
70+
<version>0.11.0-SNAPSHOT</version>
71+
<scope>test</scope>
72+
</dependency>
6073
</dependencies>
6174
<build>
6275
<plugins>

cli/src/assembly/resources/sbin/start-cli.bat

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,15 @@ set CLASSPATH="%IOTDB_CLI_HOME%\lib\*"
4242
REM -----------------------------------------------------------------------------
4343
set PARAMETERS=%*
4444

45-
if "%PARAMETERS%" == "" set PARAMETERS=-h 127.0.0.1 -p 6667 -u root -pw root
45+
@REM if "%PARAMETERS%" == "" set PARAMETERS=-h 127.0.0.1 -p 6667 -u root -pw root
46+
47+
@REM Added parameters when default parameters are missing
48+
echo %PARAMETERS% | find "-h ">nul && (set PARAMETERS=%PARAMETERS%) || (set PARAMETERS=%PARAMETERS% -h 127.0.0.1)
49+
echo %PARAMETERS% | find "-p ">nul && (set PARAMETERS=%PARAMETERS%) || (set PARAMETERS=%PARAMETERS% -p 6667)
50+
echo %PARAMETERS% | find "-u ">nul && (set PARAMETERS=%PARAMETERS%) || (set PARAMETERS=%PARAMETERS% -u root)
51+
echo %PARAMETERS% | find "-pw ">nul && (set PARAMETERS=%PARAMETERS%) || (set PARAMETERS=%PARAMETERS% -pw root)
52+
53+
@REM echo %PARAMETERS%
4654

4755
"%JAVA_HOME%\bin\java" %JAVA_OPTS% -cp %CLASSPATH% %MAIN_CLASS% %PARAMETERS%
4856

cli/src/assembly/resources/sbin/start-cli.sh

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fi
2929
MAIN_CLASS=org.apache.iotdb.cli.Cli
3030

3131

32-
CLASSPATH="."
32+
CLASSPATH=""
3333
for f in ${IOTDB_CLI_HOME}/lib/*.jar; do
3434
CLASSPATH=${CLASSPATH}":"$f
3535
done
@@ -48,10 +48,39 @@ fi
4848

4949
PARAMETERS="$@"
5050

51-
if [ $# -eq 0 ]
51+
# if [ $# -eq 0 ]
52+
# then
53+
# PARAMETERS="-h 127.0.0.1 -p 6667 -u root -pw root"
54+
# fi
55+
56+
# Added parameters when default parameters are missing
57+
if [[ $PARAMETERS =~ "-h " ]]
5258
then
53-
PARAMETERS="-h 127.0.0.1 -p 6667 -u root -pw root"
59+
PARAMETERS=$PARAMETERS
60+
else
61+
PARAMETERS="$PARAMETERS -h 127.0.0.1"
5462
fi
63+
if [[ $PARAMETERS =~ "-p " ]]
64+
then
65+
PARAMETERS=$PARAMETERS
66+
else
67+
PARAMETERS="$PARAMETERS -p 6667"
68+
fi
69+
if [[ $PARAMETERS =~ "-u " ]]
70+
then
71+
PARAMETERS=$PARAMETERS
72+
else
73+
PARAMETERS="$PARAMETERS -u root"
74+
fi
75+
if [[ $PARAMETERS =~ "-pw " ]]
76+
then
77+
PARAMETERS=$PARAMETERS
78+
else
79+
PARAMETERS="$PARAMETERS -pw root"
80+
fi
81+
82+
# echo $PARAMETERS
83+
5584
exec "$JAVA" -cp "$CLASSPATH" "$MAIN_CLASS" $PARAMETERS
5685

5786

cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,12 @@ static String[] processExecuteArgs(String[] args) {
344344
return args;
345345
} else {
346346
StringBuilder executeCommand = new StringBuilder();
347-
for (int j = index + 1; j < args.length; j++) {
347+
/*for (int j = index + 1; j < args.length; j++) {
348348
executeCommand.append(args[j]).append(" ");
349-
}
349+
}*/
350+
executeCommand.append(args[index + 1]);
350351
// remove last space
351-
executeCommand.deleteCharAt(executeCommand.length() - 1);
352+
//executeCommand.deleteCharAt(executeCommand.length() - 1);
352353
// some bashes may not remove quotes of parameters automatically, remove them in that case
353354
if (executeCommand.charAt(0) == '\'' || executeCommand.charAt(0) == '\"') {
354355
executeCommand.deleteCharAt(0);
@@ -360,8 +361,11 @@ static String[] processExecuteArgs(String[] args) {
360361

361362
execute = executeCommand.toString();
362363
hasExecuteSQL = true;
363-
args = Arrays.copyOfRange(args, 0, index);
364-
return args;
364+
//args = Arrays.copyOfRange(args, 0, index);
365+
// remove "-e" and it's parameter
366+
String[] newArgs = ArrayUtils.remove(args, index);
367+
newArgs = ArrayUtils.remove(newArgs, index);
368+
return newArgs;
365369
}
366370
}
367371

0 commit comments

Comments
 (0)