update new parser
This commit is contained in:
0
src/jison/autocomplete_footer.jison
Executable file → Normal file
0
src/jison/autocomplete_footer.jison
Executable file → Normal file
0
src/jison/autocomplete_header.jison
Executable file → Normal file
0
src/jison/autocomplete_header.jison
Executable file → Normal file
@ -1,10 +0,0 @@
|
||||
ColumnIdentifier
|
||||
UnsignedValueSpecification #各种非负数字和普通字符串常量bool值
|
||||
UnsignedLiteral #各种非负数字和普通字符串常量bool值
|
||||
ExactNumericLiteral #非负数字和小数
|
||||
ApproximateNumericLiteral #带有E的非负数字
|
||||
GeneralLiteral #普通字符串常量/bool值
|
||||
RegularIdentifier #常规标识符
|
||||
RegularOrBacktickedIdentifier #标识符
|
||||
NonReservedKeyword #非保留关键字
|
||||
ColumnIdentifier #标识符和各种对象数组写法
|
0
src/jison/globalSearchParser.jison
Executable file → Normal file
0
src/jison/globalSearchParser.jison
Executable file → Normal file
0
src/jison/solrFormulaParser.jison
Executable file → Normal file
0
src/jison/solrFormulaParser.jison
Executable file → Normal file
0
src/jison/solrQueryParser.jison
Executable file → Normal file
0
src/jison/solrQueryParser.jison
Executable file → Normal file
@ -1,36 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Licensed to Cloudera, Inc. under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
echo "Make sure you install jison first (npm install jison -g)"
|
||||
echo ""
|
||||
echo "Generating parser..."
|
||||
|
||||
pushd jison
|
||||
|
||||
# For quick version of just SELECT statements without value expressions
|
||||
# cat autocomplete_header.jison sql_main.jison autocomplete_footer.jison > sqlAutocompleteParser.jison
|
||||
cat autocomplete_header.jison sql_main.jison sql_valueExpression.jison sql_error.jison sql_alter.jison sql_analyze.jison sql_create.jison sql_drop.jison sql_grant.jison sql_insert.jison sql_load.jison sql_set.jison sql_show.jison sql_update.jison sql_use.jison autocomplete_footer.jison > sqlAutocompleteParser.jison
|
||||
|
||||
echo "Creating SQL autocomplete parser..."
|
||||
jison sqlAutocompleteParser.jison sql.jisonlex
|
||||
# grunt uglify:sqlAutocompleteParser
|
||||
cat sqlParseSupport.js sqlAutocompleteParser.js > ../core/sqlAutoCompleteParser.js
|
||||
rm sqlAutocompleteParser.jison
|
||||
rm sqlAutocompleteParser.js
|
||||
|
||||
popd
|
||||
echo "Done!"
|
@ -1,37 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Licensed to Cloudera, Inc. under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
echo "Make sure you install jison first (npm install jison -g)"
|
||||
echo ""
|
||||
echo "Generating parser..."
|
||||
|
||||
pushd jison
|
||||
# === Syntax parser ===
|
||||
cat syntax_header.jison sql_main.jison sql_valueExpression.jison sql_alter.jison sql_analyze.jison sql_create.jison sql_drop.jison sql_grant.jison sql_insert.jison sql_load.jison sql_set.jison sql_show.jison sql_update.jison sql_use.jison syntax_footer.jison > sqlSyntaxParser.jison
|
||||
|
||||
echo "Creating SQL syntax parser..."
|
||||
jison sqlSyntaxParser.jison sql.jisonlex
|
||||
# Workaround for a parser bug where it reports the location of the previous token on error (pull-request submitted for jison)
|
||||
# We're also adding a ruleId to the parser error composed of the last two stack ID's and used for suppressing errors in the UI
|
||||
sed -i '' 's/loc: yyloc,/loc: lexer.yylloc, ruleId: stack.slice(stack.length - 2, stack.length).join(''),/' sqlSyntaxParser.js
|
||||
# grunt uglify:sqlSyntaxParser
|
||||
cat sqlParseSupport.js sqlSyntaxParser.js > ../core/sqlSyntaxParser.js
|
||||
rm sqlSyntaxParser.jison
|
||||
rm sqlSyntaxParser.js
|
||||
|
||||
popd
|
||||
echo "Done!"
|
244
src/jison/sql.jisonlex
Executable file → Normal file
244
src/jison/sql.jisonlex
Executable file → Normal file
@ -62,8 +62,10 @@
|
||||
<hive>'REFERENCES' { return '<hive>REFERENCES'; }
|
||||
<hive>'REVOKE' { return '<hive>REVOKE'; }
|
||||
<hive>'ROLLUP' { return '<hive>ROLLUP'; }
|
||||
<hive>'SYNC' { return '<hive>SYNC'; }
|
||||
<hive>'TABLE' { return '<hive>TABLE'; }
|
||||
<hive>'TIMESTAMP' { return '<hive>TIMESTAMP'; }
|
||||
<hive>'UTC_TIMESTAMP' { return '<hive>UTC_TIMESTAMP'; }
|
||||
<hive>'USER' { return '<hive>USER'; }
|
||||
<hive>'USING' { return '<hive>USING'; }
|
||||
<hive>'VIEWS' { return '<hive>VIEWS'; }
|
||||
@ -125,6 +127,7 @@
|
||||
<hive>'INPUTFORMAT' { return '<hive>INPUTFORMAT'; }
|
||||
<hive>'ITEMS' { return '<hive>ITEMS'; }
|
||||
<hive>'JAR' { return '<hive>JAR'; }
|
||||
<hive>'JSONFILE' { return '<hive>JSONFILE'; }
|
||||
<hive>'KEY' { return '<hive>KEY'; }
|
||||
<hive>'KEYS' { return '<hive>KEYS'; }
|
||||
<hive>'LINES' { return '<hive>LINES'; }
|
||||
@ -193,6 +196,7 @@
|
||||
<hive>'TEXTFILE' { return '<hive>TEXTFILE'; }
|
||||
<hive>'TINYINT' { return '<hive>TINYINT'; }
|
||||
<hive>'TOUCH' { return '<hive>TOUCH'; }
|
||||
<hive>'TRANSACTIONAL' { return '<hive>TRANSACTIONAL'; }
|
||||
<hive>'TRANSACTIONS' { return '<hive>TRANSACTIONS'; }
|
||||
<hive>'UNARCHIVE' { return '<hive>UNARCHIVE'; }
|
||||
<hive>'UNIONTYPE' { return '<hive>UNIONTYPE'; }
|
||||
@ -201,6 +205,7 @@
|
||||
<hive>'WAIT' { return '<hive>WAIT'; }
|
||||
<hive>'WEEK' { return '<hive>WEEK'; }
|
||||
<hive>'WINDOW' { return '<hive>WINDOW'; }
|
||||
<hive>'WITH' { parser.determineCase(yytext); parser.addStatementTypeLocation('WITH', yylloc); return '<hive>WITH'; }
|
||||
<hive>'YEAR' { return '<hive>YEAR'; }
|
||||
|
||||
<hive>'.' { return '<hive>.'; }
|
||||
@ -210,68 +215,228 @@
|
||||
// Reserved Keywords
|
||||
<impala>'ADD' { return '<impala>ADD'; }
|
||||
<impala>'AGGREGATE' { return '<impala>AGGREGATE'; }
|
||||
<impala>'ALLOCATE' { return '<impala>ALLOCATE'; }
|
||||
<impala>'ANALYTIC' { return '<impala>ANALYTIC'; }
|
||||
<impala>'ANTI' { return '<impala>ANTI'; }
|
||||
<impala>'ANY' { return '<impala>ANY'; }
|
||||
<impala>'ARE' { return '<impala>ARE'; }
|
||||
<impala>'ARRAY_AGG' { return '<impala>ARRAY_AGG'; }
|
||||
<impala>'ARRAY_MAX_CARDINALITY' { return '<impala>ARRAY_MAX_CARDINALITY'; }
|
||||
<impala>'ASENSITIVE' { return '<impala>ASENSITIVE'; }
|
||||
<impala>'ASYMMETRIC' { return '<impala>ASYMMETRIC'; }
|
||||
<impala>'AT' { return '<impala>AT'; }
|
||||
<impala>'ATOMIC' { return '<impala>ATOMIC'; }
|
||||
<impala>'AUTHORIZATION' { return '<impala>AUTHORIZATION'; }
|
||||
<impala>'AVRO' { return '<impala>AVRO'; }
|
||||
<impala>'BEGIN_FRAME' { return '<impala>BEGIN_FRAME'; }
|
||||
<impala>'BEGIN_PARTITION' { return '<impala>BEGIN_PARTITION'; }
|
||||
<impala>'BLOB' { return '<impala>BLOB'; }
|
||||
<impala>'BLOCK_SIZE' { return '<impala>BLOCK_SIZE'; }
|
||||
<impala>'BOTH' { return '<impala>BOTH'; }
|
||||
<impala>'CACHED' { return '<impala>CACHED'; }
|
||||
<impala>'CALLED' { return '<impala>CALLED'; }
|
||||
<impala>'CARDINALITY' { return '<impala>CARDINALITY'; }
|
||||
<impala>'CASCADE' { return '<impala>CASCADE'; }
|
||||
<impala>'CASCADED' { return '<impala>CASCADED'; }
|
||||
<impala>'CHANGE' { return '<impala>CHANGE'; }
|
||||
<impala>'CHARACTER' { return '<impala>CHARACTER'; }
|
||||
<impala>'CLOB' { return '<impala>CLOB'; }
|
||||
<impala>'CLOSE_FN' { return '<impala>CLOSE_FN'; }
|
||||
<impala>'COLLATE' { return '<impala>COLLATE'; }
|
||||
<impala>'COLLECT' { return '<impala>COLLECT'; }
|
||||
<impala>'COLUMN' { return '<impala>COLUMN'; }
|
||||
<impala>'COLUMNS' { return '<impala>COLUMNS'; }
|
||||
<impala>'COMMENT' { parser.determineCase(yytext); return '<impala>COMMENT'; }
|
||||
<impala>'COMMIT' { return '<impala>COMMIT'; }
|
||||
<impala>'COMPRESSION' { return '<impala>COMPRESSION'; }
|
||||
<impala>'COMPUTE' { parser.determineCase(yytext); return '<impala>COMPUTE'; }
|
||||
<impala>'CONDITION' { return '<impala>CONDITION'; }
|
||||
<impala>'CONNECT' { return '<impala>CONNECT'; }
|
||||
<impala>'CONSTRAINT' { return '<impala>CONSTRAINT'; }
|
||||
<impala>'CONTAINS' { return '<impala>CONTAINS'; }
|
||||
<impala>'CONVERT' { return '<impala>CONVERT'; }
|
||||
<impala>'COPY' { return '<impala>COPY'; }
|
||||
<impala>'CORR' { return '<impala>CORR'; }
|
||||
<impala>'CORRESPONDING' { return '<impala>CORRESPONDING'; }
|
||||
<impala>'COVAR_POP' { return '<impala>COVAR_POP'; }
|
||||
<impala>'COVAR_SAMP' { return '<impala>COVAR_SAMP'; }
|
||||
<impala>'CREATE' { parser.determineCase(yytext); parser.addStatementTypeLocation('CREATE', yylloc, yy.lexer.upcomingInput()); return '<impala>CREATE'; }
|
||||
<impala>'CUBE' { return '<impala>CUBE'; }
|
||||
<impala>'CURRENT' { return '<impala>CURRENT'; }
|
||||
<impala>'CURRENT_DATE' { return '<impala>CURRENT_DATE'; }
|
||||
<impala>'CURRENT_DEFAULT_TRANSFORM_GROUP' { return '<impala>CURRENT_DEFAULT_TRANSFORM_GROUP'; }
|
||||
<impala>'CURRENT_PATH' { return '<impala>CURRENT_PATH'; }
|
||||
<impala>'CURRENT_ROLE' { return '<impala>CURRENT_ROLE'; }
|
||||
<impala>'CURRENT_ROW' { return '<impala>CURRENT_ROW'; }
|
||||
<impala>'CURRENT_SCHEMA' { return '<impala>CURRENT_SCHEMA'; }
|
||||
<impala>'CURRENT_TIME' { return '<impala>CURRENT_TIME'; }
|
||||
<impala>'CURRENT_TRANSFORM_GROUP_FOR_TYPE' { return '<impala>CURRENT_TRANSFORM_GROUP_FOR_TYPE'; }
|
||||
<impala>'CURSOR' { return '<impala>CURSOR'; }
|
||||
<impala>'CYCLE' { return '<impala>CYCLE'; }
|
||||
<impala>'DATA' { return '<impala>DATA'; }
|
||||
<impala>'DATABASES' { return '<impala>DATABASES'; }
|
||||
<impala>'DEALLOCATE' { return '<impala>DEALLOCATE'; }
|
||||
<impala>'DEC' { return '<impala>DEC'; }
|
||||
<impala>'DECFLOAT' { return '<impala>DECFLOAT'; }
|
||||
<impala>'DECLARE' { return '<impala>DECLARE'; }
|
||||
<impala>'DEFINE' { return '<impala>DEFINE'; }
|
||||
<impala>'DELETE' { return '<impala>DELETE'; }
|
||||
<impala>'DELIMITED' { return '<impala>DELIMITED'; }
|
||||
<impala>'DEREF' { return '<impala>DEREF'; }
|
||||
<impala>'DESCRIBE' { parser.determineCase(yytext); parser.addStatementTypeLocation('DESCRIBE', yylloc); return '<impala>DESCRIBE'; }
|
||||
<impala>'DETERMINISTIC' { return '<impala>DETERMINISTIC'; }
|
||||
<impala>'DISCONNECT' { return '<impala>DISCONNECT'; }
|
||||
<impala>'DYNAMIC' { return '<impala>DYNAMIC'; }
|
||||
<impala>'EACH' { return '<impala>EACH'; }
|
||||
<impala>'ELEMENT' { return '<impala>ELEMENT'; }
|
||||
<impala>'EMPTY' { return '<impala>EMPTY'; }
|
||||
<impala>'ENCODING' { return '<impala>ENCODING'; }
|
||||
<impala>'END_FRAME' { return '<impala>END_FRAME'; }
|
||||
<impala>'END_PARTITION' { return '<impala>END_PARTITION'; }
|
||||
<impala>'EQUALS' { return '<impala>EQUALS'; }
|
||||
<impala>'ESCAPE' { return '<impala>ESCAPE'; }
|
||||
<impala>'ESCAPED' { return '<impala>ESCAPED'; }
|
||||
<impala>'EVERY' { return '<impala>EVERY'; }
|
||||
<impala>'EXCEPT' { return '<impala>EXCEPT'; }
|
||||
<impala>'EXEC' { return '<impala>EXEC'; }
|
||||
<impala>'EXECUTE' { return '<impala>EXECUTE'; }
|
||||
<impala>'EXPLAIN' { parser.determineCase(yytext); parser.addStatementTypeLocation('EXPLAIN', yylloc); return '<impala>EXPLAIN'; }
|
||||
<impala>'EXTERNAL' { return '<impala>EXTERNAL'; }
|
||||
<impala>'EXTENDED' { return '<impala>EXTENDED'; }
|
||||
<impala>'EXTERNAL' { return '<impala>EXTERNAL'; }
|
||||
<impala>'FETCH' { return '<impala>FETCH'; }
|
||||
<impala>'FIELDS' { return '<impala>FIELDS'; }
|
||||
<impala>'FILEFORMAT' { return '<impala>FILEFORMAT'; }
|
||||
<impala>'FILES' { return '<impala>FILES'; }
|
||||
<impala>'FILTER' { return '<impala>FILTER'; }
|
||||
<impala>'FINALIZE_FN' { return '<impala>FINALIZE_FN'; }
|
||||
<impala>'FIRST' { return '<impala>FIRST'; }
|
||||
<impala>'FOR' { return '<impala>FOR'; }
|
||||
<impala>'FOREIGN' { return '<impala>FOREIGN'; }
|
||||
<impala>'FORMAT' { return '<impala>FORMAT'; }
|
||||
<impala>'FORMATTED' { return '<impala>FORMATTED'; }
|
||||
<impala>'FRAME_ROW' { return '<impala>FRAME_ROW'; }
|
||||
<impala>'FREE' { return '<impala>FREE'; }
|
||||
<impala>'FUNCTION' { return '<impala>FUNCTION'; }
|
||||
<impala>'FUNCTIONS' { return '<impala>FUNCTIONS'; }
|
||||
<impala>'FUSION' { return '<impala>FUSION'; }
|
||||
<impala>'GET' { return '<impala>GET'; }
|
||||
<impala>'GLOBAL' { return '<impala>GLOBAL'; }
|
||||
<impala>'GRANT' { parser.determineCase(yytext); parser.addStatementTypeLocation('GRANT', yylloc); return '<impala>GRANT'; }
|
||||
<impala>'GROUP' { return '<impala>GROUP'; }
|
||||
<impala>'GROUPING' { return '<impala>GROUPING'; }
|
||||
<impala>'GROUPS' { return '<impala>GROUPS'; }
|
||||
<impala>'HASH' { return '<impala>HASH'; }
|
||||
<impala>'HOLD' { return '<impala>HOLD'; }
|
||||
<impala>'IGNORE' { return '<impala>IGNORE'; }
|
||||
<impala>'ILIKE' { return '<impala>ILIKE'; }
|
||||
<impala>'INCREMENTAL' { return '<impala>INCREMENTAL'; }
|
||||
<impala>'INSERT' { parser.determineCase(yytext); parser.addStatementTypeLocation('INSERT', yylloc); return '<impala>INSERT'; }
|
||||
<impala>'INTERVAL' { return '<impala>INTERVAL'; }
|
||||
<impala>'INTERMEDIATE' { return '<impala>INTERMEDIATE'; }
|
||||
<impala>'INDICATOR' { return '<impala>INDICATOR'; }
|
||||
<impala>'INIT_FN' { return '<impala>INIT_FN'; }
|
||||
<impala>'INVALIDATE' { parser.determineCase(yytext); parser.addStatementTypeLocation('INVALIDATE', yylloc, yy.lexer.upcomingInput()); return '<impala>INVALIDATE'; }
|
||||
<impala>'INITIAL' { return '<impala>INITIAL'; }
|
||||
<impala>'INOUT' { return '<impala>INOUT'; }
|
||||
<impala>'INPATH' { this.begin('hdfs'); return '<impala>INPATH'; }
|
||||
<impala>'INSENSITIVE' { return '<impala>INSENSITIVE'; }
|
||||
<impala>'INSERT' { parser.determineCase(yytext); parser.addStatementTypeLocation('INSERT', yylloc); return '<impala>INSERT'; }
|
||||
<impala>'INTERMEDIATE' { return '<impala>INTERMEDIATE'; }
|
||||
<impala>'INTERSECT' { return '<impala>INTERSECT'; }
|
||||
<impala>'INTERSECTION' { return '<impala>INTERSECTION'; }
|
||||
<impala>'INTERVAL' { return '<impala>INTERVAL'; }
|
||||
<impala>'INVALIDATE' { parser.determineCase(yytext); parser.addStatementTypeLocation('INVALIDATE', yylloc, yy.lexer.upcomingInput()); return '<impala>INVALIDATE'; }
|
||||
<impala>'IREGEXP' { return '<impala>IREGEXP'; }
|
||||
<impala>'JSON_ARRAY' { return '<impala>JSON_ARRAY'; }
|
||||
<impala>'JSON_ARRAYAGG' { return '<impala>JSON_ARRAYAGG'; }
|
||||
<impala>'JSON_EXISTS' { return '<impala>JSON_EXISTS'; }
|
||||
<impala>'JSON_OBJECT' { return '<impala>JSON_OBJECT'; }
|
||||
<impala>'JSON_OBJECTAGG' { return '<impala>JSON_OBJECTAGG'; }
|
||||
<impala>'JSON_QUERY' { return '<impala>JSON_QUERY'; }
|
||||
<impala>'JSON_TABLE' { return '<impala>JSON_TABLE'; }
|
||||
<impala>'JSON_TABLE_PRIMITIVE' { return '<impala>JSON_TABLE_PRIMITIVE'; }
|
||||
<impala>'JSON_VALUE' { return '<impala>JSON_VALUE'; }
|
||||
<impala>'KEY' { return '<impala>KEY'; }
|
||||
<impala>'KUDU' { return '<impala>KUDU'; }
|
||||
<impala>'LARGE' { return '<impala>LARGE'; }
|
||||
<impala>'LAST' { return '<impala>LAST'; }
|
||||
<impala>'LATERAL' { return '<impala>LATERAL'; }
|
||||
<impala>'LEADING' { return '<impala>LEADING'; }
|
||||
<impala>LIKE\s+PARQUET { this.begin('hdfs'); return '<impala>LIKE_PARQUET'; }
|
||||
<impala>'LIKE_REGEX' { return '<impala>LIKE_REGEX'; }
|
||||
<impala>'LIMIT' { return '<impala>LIMIT'; }
|
||||
<impala>'LINES' { return '<impala>LINES'; }
|
||||
<impala>'LISTAGG' { return '<impala>LISTAGG'; }
|
||||
<impala>'LOAD' { parser.determineCase(yytext); parser.addStatementTypeLocation('LOAD', yylloc, yy.lexer.upcomingInput()); return '<impala>LOAD'; }
|
||||
<impala>'LOCAL' { return '<impala>LOCAL'; }
|
||||
<impala>'LOCALTIMESTAMP' { return '<impala>LOCALTIMESTAMP'; }
|
||||
<impala>'LOCATION' { this.begin('hdfs'); return '<impala>LOCATION'; }
|
||||
<impala>'MATCH' { return '<impala>MATCH'; }
|
||||
<impala>'MATCH_NUMBER' { return '<impala>MATCH_NUMBER'; }
|
||||
<impala>'MATCH_RECOGNIZE' { return '<impala>MATCH_RECOGNIZE'; }
|
||||
<impala>'MATCHES' { return '<impala>MATCHES'; }
|
||||
<impala>'MERGE' { return '<impala>MERGE'; }
|
||||
<impala>'MERGE_FN' { return '<impala>MERGE_FN'; }
|
||||
<impala>'METADATA' { return '<impala>METADATA'; }
|
||||
<impala>'METHOD' { return '<impala>METHOD'; }
|
||||
<impala>'MODIFIES' { return '<impala>MODIFIES'; }
|
||||
<impala>'MULTISET' { return '<impala>MULTISET'; }
|
||||
<impala>'NATIONAL' { return '<impala>NATIONAL'; }
|
||||
<impala>'NATURAL' { return '<impala>NATURAL'; }
|
||||
<impala>'NCHAR' { return '<impala>NCHAR'; }
|
||||
<impala>'NCLOB' { return '<impala>NCLOB'; }
|
||||
<impala>'NO' { return '<impala>NO'; }
|
||||
<impala>'NONE' { return '<impala>NONE'; }
|
||||
<impala>'NORMALIZE' { return '<impala>NORMALIZE'; }
|
||||
<impala>'NTH_VALUE' { return '<impala>NTH_VALUE'; }
|
||||
<impala>'NULLS' { return '<impala>NULLS'; }
|
||||
<impala>'NUMERIC' { return '<impala>NUMERIC'; }
|
||||
<impala>'OCCURRENCES_REGEX' { return '<impala>OCCURRENCES_REGEX'; }
|
||||
<impala>'OCTET_LENGTH' { return '<impala>OCTET_LENGTH'; }
|
||||
<impala>'OF' { return '<impala>OF'; }
|
||||
<impala>'OFFSET' { return '<impala>OFFSET'; }
|
||||
<impala>'OMIT' { return '<impala>OMIT'; }
|
||||
<impala>'ONE' { return '<impala>ONE'; }
|
||||
<impala>'ONLY' { return '<impala>ONLY'; }
|
||||
<impala>'ORC' { return '<impala>ORC'; }
|
||||
<impala>'OUT' { return '<impala>OUT'; }
|
||||
<impala>'OVER' { return '<impala>OVER'; }
|
||||
<impala>'OVERLAPS' { return '<impala>OVERLAPS'; }
|
||||
<impala>'OVERLAY' { return '<impala>OVERLAY'; }
|
||||
<impala>'OVERWRITE' { return '<impala>OVERWRITE'; }
|
||||
<impala>'PARQUET' { return '<impala>PARQUET'; }
|
||||
<impala>PARTITION\s+VALUE\s { return '<impala>PARTITION_VALUE'; }
|
||||
<impala>'PARTITIONED' { return '<impala>PARTITIONED'; }
|
||||
<impala>'PARTITIONS' { return '<impala>PARTITIONS'; }
|
||||
<impala>'PATTERN' { return '<impala>PATTERN'; }
|
||||
<impala>'PER' { return '<impala>PER'; }
|
||||
<impala>'PERCENT' { return '<impala>PERCENT'; }
|
||||
<impala>'PERCENTILE_CONT' { return '<impala>PERCENTILE_CONT'; }
|
||||
<impala>'PERCENTILE_DISC' { return '<impala>PERCENTILE_DISC'; }
|
||||
<impala>'PORTION' { return '<impala>PORTION'; }
|
||||
<impala>'POSITION' { return '<impala>POSITION'; }
|
||||
<impala>'POSITION_REGEX' { return '<impala>POSITION_REGEX'; }
|
||||
<impala>'PRECEDES' { return '<impala>PRECEDES'; }
|
||||
<impala>'PREPARE' { return '<impala>PREPARE'; }
|
||||
<impala>'PREPARE_FN' { return '<impala>PREPARE_FN'; }
|
||||
<impala>'PRIMARY' { return '<impala>PRIMARY'; }
|
||||
<impala>'RCFILE' { return '<impala>RCFILE'; }
|
||||
<impala>'PROCEDURE' { return '<impala>PROCEDURE'; }
|
||||
<impala>'PTF' { return '<impala>PTF'; }
|
||||
<impala>'RANGE' { return '<impala>RANGE'; }
|
||||
<impala>'RCFILE' { return '<impala>RCFILE'; }
|
||||
<impala>'READS' { return '<impala>READS'; }
|
||||
<impala>'REAL' { return '<impala>REAL'; }
|
||||
<impala>'RECOVER' { return '<impala>RECOVER'; }
|
||||
<impala>'RECURSIVE' { return '<impala>RECURSIVE'; }
|
||||
<impala>'REF' { return '<impala>REF'; }
|
||||
<impala>'REFERENCES' { return '<impala>REFERENCES'; }
|
||||
<impala>'REFERENCING' { return '<impala>REFERENCING'; }
|
||||
<impala>'REFRESH' { parser.determineCase(yytext); parser.addStatementTypeLocation('REFRESH', yylloc); return '<impala>REFRESH'; }
|
||||
<impala>'REGR_AVGX' { return '<impala>REGR_AVGX'; }
|
||||
<impala>'REGR_AVGY' { return '<impala>REGR_AVGY'; }
|
||||
<impala>'REGR_COUNT' { return '<impala>REGR_COUNT'; }
|
||||
<impala>'REGR_INTERCEPT' { return '<impala>REGR_INTERCEPT'; }
|
||||
<impala>'REGR_R2REGR_SLOPE' { return '<impala>REGR_R2REGR_SLOPE'; }
|
||||
<impala>'REGR_SXX' { return '<impala>REGR_SXX'; }
|
||||
<impala>'REGR_SXY' { return '<impala>REGR_SXY'; }
|
||||
<impala>'REGR_SYY' { return '<impala>REGR_SYY'; }
|
||||
<impala>'RELEASE' { return '<impala>RELEASE'; }
|
||||
<impala>'RENAME' { return '<impala>RENAME'; }
|
||||
<impala>'REPEATABLE' { return '<impala>REPEATABLE'; }
|
||||
<impala>'REPLACE' { return '<impala>REPLACE'; }
|
||||
@ -279,45 +444,85 @@
|
||||
<impala>'RESTRICT' { return '<impala>RESTRICT'; }
|
||||
<impala>'RETURNS' { return '<impala>RETURNS'; }
|
||||
<impala>'REVOKE' { parser.determineCase(yytext); parser.addStatementTypeLocation('REVOKE', yylloc); return '<impala>REVOKE'; }
|
||||
<impala>'ROLE' { return '<impala>ROLE'; }
|
||||
<impala>'ROLES' { return '<impala>ROLES'; }
|
||||
<impala>'ROLLBACK' { return '<impala>ROLLBACK'; }
|
||||
<impala>'ROLLUP' { return '<impala>ROLLUP'; }
|
||||
<impala>'RUNNING' { return '<impala>RUNNING'; }
|
||||
<impala>'SAVEPOINT' { return '<impala>SAVEPOINT'; }
|
||||
<impala>'SCHEMAS' { return '<impala>SCHEMAS'; }
|
||||
<impala>'SCOPE' { return '<impala>SCOPE'; }
|
||||
<impala>'SCROLL' { return '<impala>SCROLL'; }
|
||||
<impala>'SEARCH' { return '<impala>SEARCH'; }
|
||||
<impala>'SEEK' { return '<impala>SEEK'; }
|
||||
<impala>'SENSITIVE' { return '<impala>SENSITIVE'; }
|
||||
<impala>'SEQUENCEFILE' { return '<impala>SEQUENCEFILE'; }
|
||||
<impala>'SERDEPROPERTIES' { return '<impala>SERDEPROPERTIES'; }
|
||||
<impala>'SCHEMAS' { return '<impala>SCHEMAS'; }
|
||||
<impala>'SERIALIZE_FN' { return '<impala>SERIALIZE_FN'; }
|
||||
<impala>'SERVER' { return '<impala>SERVER'; }
|
||||
<impala>'SIMILAR' { return '<impala>SIMILAR'; }
|
||||
<impala>'SKIP' { return '<impala>SKIP'; }
|
||||
<impala>'SOME' { return '<impala>SOME'; }
|
||||
<impala>'SORT' { return '<impala>SORT'; }
|
||||
<impala>'SPECIFIC' { return '<impala>SPECIFIC'; }
|
||||
<impala>'SPECIFICTYPE' { return '<impala>SPECIFICTYPE'; }
|
||||
<impala>'SQLEXCEPTION' { return '<impala>SQLEXCEPTION'; }
|
||||
<impala>'SQLSTATE' { return '<impala>SQLSTATE'; }
|
||||
<impala>'SQLWARNING' { return '<impala>SQLWARNING'; }
|
||||
<impala>'STATIC' { return '<impala>STATIC'; }
|
||||
<impala>'STATS' { return '<impala>STATS'; }
|
||||
<impala>'STORED' { return '<impala>STORED'; }
|
||||
<impala>'STRAIGHT_JOIN' { return '<impala>STRAIGHT_JOIN'; }
|
||||
<impala>'SUBMULTISET' { return '<impala>SUBMULTISET'; }
|
||||
<impala>'SUBSET' { return '<impala>SUBSET'; }
|
||||
<impala>'SUBSTRING_REGEX' { return '<impala>SUBSTRING_REGEX'; }
|
||||
<impala>'SUCCEEDS' { return '<impala>SUCCEEDS'; }
|
||||
<impala>'SYMBOL' { return '<impala>SYMBOL'; }
|
||||
<impala>'SYMMETRIC' { return '<impala>SYMMETRIC'; }
|
||||
<impala>'SYSTEM_TIME' { return '<impala>SYSTEM_TIME'; }
|
||||
<impala>'SYSTEM_USER' { return '<impala>SYSTEM_USER'; }
|
||||
<impala>'TABLE' { return '<impala>TABLE'; }
|
||||
<impala>'TABLES' { return '<impala>TABLES'; }
|
||||
<impala>'TABLESAMPLE' { return '<impala>TABLESAMPLE'; }
|
||||
<impala>'TBLPROPERTIES' { return '<impala>TBLPROPERTIES'; }
|
||||
<impala>'TERMINATED' { return '<impala>TERMINATED'; }
|
||||
<impala>'TEXTFILE' { return '<impala>TEXTFILE'; }
|
||||
<impala>'TIMEZONE_HOUR' { return '<impala>TIMEZONE_HOUR'; }
|
||||
<impala>'TIMEZONE_MINUTE' { return '<impala>TIMEZONE_MINUTE'; }
|
||||
<impala>'TRAILING' { return '<impala>TRAILING'; }
|
||||
<impala>'TRANSLATE_REGEX' { return '<impala>TRANSLATE_REGEX'; }
|
||||
<impala>'TRANSLATION' { return '<impala>TRANSLATION'; }
|
||||
<impala>'TREAT' { return '<impala>TREAT'; }
|
||||
<impala>'TRIGGER' { return '<impala>TRIGGER'; }
|
||||
<impala>'TRIM_ARRAY' { return '<impala>TRIM_ARRAY'; }
|
||||
<impala>'UESCAPE' { return '<impala>UESCAPE'; }
|
||||
<impala>'UNCACHED' { return '<impala>UNCACHED'; }
|
||||
<impala>'UNIQUE' { return '<impala>UNIQUE'; }
|
||||
<impala>'UNKNOWN' { return '<impala>UNKNOWN'; }
|
||||
<impala>'UNNEST' { return '<impala>UNNEST'; }
|
||||
<impala>'UPDATE_FN' { return '<impala>UPDATE_FN'; }
|
||||
<impala>'UPSERT' { parser.determineCase(yytext); parser.addStatementTypeLocation('UPSERT', yylloc); return '<impala>UPSERT'; }
|
||||
<impala>'URI' { return '<impala>URI'; }
|
||||
<impala>'USER' { return '<impala>USER'; }
|
||||
<impala>'USING' { return '<impala>USING'; }
|
||||
<impala>PARTITION\s+VALUE\s { return '<impala>PARTITION_VALUE'; }
|
||||
<impala>'VALUE_OF' { return '<impala>VALUE_OF'; }
|
||||
<impala>'VARBINARY' { return '<impala>VARBINARY'; }
|
||||
<impala>'VARCHAR' { return '<impala>VARCHAR'; }
|
||||
<impala>'VARYING' { return '<impala>VARYING'; }
|
||||
<impala>'VERSIONING' { return '<impala>VERSIONING'; }
|
||||
<impala>'WHENEVER' { return '<impala>WHENEVER'; }
|
||||
<impala>'WIDTH_BUCKET' { return '<impala>WIDTH_BUCKET'; }
|
||||
<impala>'WINDOW' { return '<impala>WINDOW'; }
|
||||
<impala>'WITH' { parser.determineCase(yytext); parser.addStatementTypeLocation('WITH', yylloc); return '<impala>WITH'; }
|
||||
<impala>'WITHIN' { return '<impala>WITHIN'; }
|
||||
<impala>'WITHOUT' { return '<impala>WITHOUT'; }
|
||||
|
||||
// Non-reserved Keywords
|
||||
<impala>'ANALYTIC' { return '<impala>ANALYTIC'; }
|
||||
<impala>'ANTI' { return '<impala>ANTI'; }
|
||||
<impala>'ARRAY' { return 'ARRAY'; }
|
||||
<impala>'BLOCK_SIZE' { return '<impala>BLOCK_SIZE'; }
|
||||
<impala>'COMPRESSION' { return '<impala>COMPRESSION'; }
|
||||
<impala>'CURRENT' { return '<impala>CURRENT'; }
|
||||
<impala>'DEFAULT' { return '<impala>DEFAULT'; }
|
||||
<impala>'ENCODING' { return '<impala>ENCODING'; }
|
||||
<impala>'GRANT' { return '<impala>GRANT'; }
|
||||
<impala>'MAP' { return 'MAP'; }
|
||||
<impala>'RECOVER' { return '<impala>RECOVER'; }
|
||||
<impala>'ROLE' { return '<impala>ROLE'; }
|
||||
<impala>'ROLES' { return '<impala>ROLES'; }
|
||||
<impala>'OWNER' { return '<impala>OWNER'; }
|
||||
<impala>'STRUCT' { return 'STRUCT'; }
|
||||
<impala>'UNKNOWN' { return '<impala>UNKNOWN'; }
|
||||
<impala>\[BROADCAST\] { return '<impala>BROADCAST'; }
|
||||
<impala>\[NOSHUFFLE\] { return '<impala>NOSHUFFLE'; }
|
||||
<impala>\[SHUFFLE\] { return '<impala>SHUFFLE'; }
|
||||
@ -330,7 +535,6 @@
|
||||
<between>'AND' { this.popState(); return 'BETWEEN_AND'; }
|
||||
|
||||
// Reserved Keywords
|
||||
'LIFECYCLE' { return 'LIFECYCLE'; }
|
||||
'ALL' { return 'ALL'; }
|
||||
'ALTER' { parser.determineCase(yytext); parser.addStatementTypeLocation('ALTER', yylloc, yy.lexer.upcomingInput()); return 'ALTER'; }
|
||||
'AND' { return 'AND'; }
|
||||
|
4
src/jison/license.txt → src/jison/sql/calcite/autocomplete_footer.jison
Executable file → Normal file
4
src/jison/license.txt → src/jison/sql/calcite/autocomplete_footer.jison
Executable file → Normal file
@ -13,3 +13,7 @@
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%%
|
||||
|
||||
SqlParseSupport.initSqlParser(parser);
|
29
src/jison/sql/calcite/autocomplete_header.jison
Normal file
29
src/jison/sql/calcite/autocomplete_header.jison
Normal file
@ -0,0 +1,29 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%left 'AND' 'OR'
|
||||
%left 'BETWEEN'
|
||||
%left 'NOT' '!' '~'
|
||||
%left '=' '<' '>' 'COMPARISON_OPERATOR'
|
||||
%left '-' '*' 'ARITHMETIC_OPERATOR'
|
||||
|
||||
%left ';' ','
|
||||
%nonassoc 'CURSOR' 'PARTIAL_CURSOR'
|
||||
%nonassoc 'IN' 'IS' 'LIKE' 'RLIKE' 'REGEXP' 'EXISTS' NEGATION
|
||||
|
||||
%start SqlAutocomplete
|
||||
|
||||
%%
|
226
src/jison/sql/calcite/sql.jisonlex
Normal file
226
src/jison/sql/calcite/sql.jisonlex
Normal file
@ -0,0 +1,226 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%options case-insensitive flex
|
||||
%s between
|
||||
%x hdfs doubleQuotedValue singleQuotedValue backtickedValue
|
||||
%%
|
||||
|
||||
\s { /* skip whitespace */ }
|
||||
'--'.* { /* skip comments */ }
|
||||
[/][*][^*]*[*]+([^/*][^*]*[*]+)*[/] { /* skip comments */ }
|
||||
|
||||
'\u2020' { parser.yy.partialCursor = false; parser.yy.cursorFound = yylloc; return 'CURSOR'; }
|
||||
'\u2021' { parser.yy.partialCursor = true; parser.yy.cursorFound = yylloc; return 'PARTIAL_CURSOR'; }
|
||||
|
||||
<between>'AND' { this.popState(); return 'BETWEEN_AND'; }
|
||||
|
||||
// Reserved Keywords
|
||||
'ALL' { return 'ALL'; }
|
||||
'ALTER' { parser.determineCase(yytext); parser.addStatementTypeLocation('ALTER', yylloc, yy.lexer.upcomingInput()); return 'ALTER'; }
|
||||
'AND' { return 'AND'; }
|
||||
'AS' { return 'AS'; }
|
||||
'ASC' { return 'ASC'; }
|
||||
'BETWEEN' { this.begin('between'); return 'BETWEEN'; }
|
||||
'BIGINT' { return 'BIGINT'; }
|
||||
'BOOLEAN' { return 'BOOLEAN'; }
|
||||
'BY' { return 'BY'; }
|
||||
'CASCADE' { return 'CASCADE'; }
|
||||
'CASE' { return 'CASE'; }
|
||||
'CHAR' { return 'CHAR'; }
|
||||
'COMMENT' { return 'COMMENT'; }
|
||||
'CREATE' { parser.determineCase(yytext); return 'CREATE'; }
|
||||
'CROSS' { return 'CROSS'; }
|
||||
'CURRENT' { return 'CURRENT'; }
|
||||
'DATABASE' { return 'DATABASE'; }
|
||||
'DECIMAL' { return 'DECIMAL'; }
|
||||
'DESC' { return 'DESC'; }
|
||||
'DISTINCT' { return 'DISTINCT'; }
|
||||
'DIV' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'DOUBLE' { return 'DOUBLE'; }
|
||||
'DROP' { parser.determineCase(yytext); parser.addStatementTypeLocation('DROP', yylloc, yy.lexer.upcomingInput()); return 'DROP'; }
|
||||
'ELSE' { return 'ELSE'; }
|
||||
'END' { return 'END'; }
|
||||
'EXISTS' { parser.yy.correlatedSubQuery = true; return 'EXISTS'; }
|
||||
'FALSE' { return 'FALSE'; }
|
||||
'FLOAT' { return 'FLOAT'; }
|
||||
'FOLLOWING' { return 'FOLLOWING'; }
|
||||
'FROM' { parser.determineCase(yytext); return 'FROM'; }
|
||||
'FULL' { return 'FULL'; }
|
||||
'GROUP' { return 'GROUP'; }
|
||||
'HAVING' { return 'HAVING'; }
|
||||
'IF' { return 'IF'; }
|
||||
'IN' { return 'IN'; }
|
||||
'INNER' { return 'INNER'; }
|
||||
'INSERT' { return 'INSERT'; }
|
||||
'INT' { return 'INT'; }
|
||||
'INTO' { return 'INTO'; }
|
||||
'IS' { return 'IS'; }
|
||||
'JOIN' { return 'JOIN'; }
|
||||
'LEFT' { return 'LEFT'; }
|
||||
'LIKE' { return 'LIKE'; }
|
||||
'LIMIT' { return 'LIMIT'; }
|
||||
'NOT' { return 'NOT'; }
|
||||
'NULL' { return 'NULL'; }
|
||||
'ON' { return 'ON'; }
|
||||
'OPTION' { return 'OPTION'; }
|
||||
'OR' { return 'OR'; }
|
||||
'ORDER' { return 'ORDER'; }
|
||||
'OUTER' { return 'OUTER'; }
|
||||
'PARTITION' { return 'PARTITION'; }
|
||||
'PRECEDING' { return 'PRECEDING'; }
|
||||
'PURGE' { return 'PURGE'; }
|
||||
'RANGE' { return 'RANGE'; }
|
||||
'REGEXP' { return 'REGEXP'; }
|
||||
'RIGHT' { return 'RIGHT'; }
|
||||
'RLIKE' { return 'RLIKE'; }
|
||||
'ROW' { return 'ROW'; }
|
||||
'ROLE' { return 'ROLE'; }
|
||||
'ROWS' { return 'ROWS'; }
|
||||
'SCHEMA' { return 'SCHEMA'; }
|
||||
'SELECT' { parser.determineCase(yytext); parser.addStatementTypeLocation('SELECT', yylloc); return 'SELECT'; }
|
||||
'SEMI' { return 'SEMI'; }
|
||||
'SET' { parser.determineCase(yytext); parser.addStatementTypeLocation('SET', yylloc); return 'SET'; }
|
||||
'SHOW' { parser.determineCase(yytext); parser.addStatementTypeLocation('SHOW', yylloc); return 'SHOW'; }
|
||||
'SMALLINT' { return 'SMALLINT'; }
|
||||
'STRING' { return 'STRING'; }
|
||||
'TABLE' { return 'TABLE'; }
|
||||
'THEN' { return 'THEN'; }
|
||||
'TIMESTAMP' { return 'TIMESTAMP'; }
|
||||
'TINYINT' { return 'TINYINT'; }
|
||||
'TO' { return 'TO'; }
|
||||
'TRUE' { return 'TRUE'; }
|
||||
'TRUNCATE' { parser.determineCase(yytext); parser.addStatementTypeLocation('TRUNCATE', yylloc, yy.lexer.upcomingInput()); return 'TRUNCATE'; }
|
||||
'UNBOUNDED' { return 'UNBOUNDED'; }
|
||||
'UNION' { return 'UNION'; }
|
||||
'UPDATE' { parser.determineCase(yytext); return 'UPDATE'; }
|
||||
'USE' { parser.determineCase(yytext); parser.addStatementTypeLocation('USE', yylloc); return 'USE'; }
|
||||
'VALUES' { return 'VALUES'; }
|
||||
'VARCHAR' { return 'VARCHAR'; }
|
||||
'VIEW' { return 'VIEW'; }
|
||||
'WHEN' { return 'WHEN'; }
|
||||
'WHERE' { return 'WHERE'; }
|
||||
'WITH' { parser.determineCase(yytext); parser.addStatementTypeLocation('WITH', yylloc); return 'WITH'; }
|
||||
|
||||
// Non-reserved Keywords
|
||||
'OVER' { return 'OVER'; }
|
||||
'ROLE' { return 'ROLE'; }
|
||||
|
||||
// --- UDFs ---
|
||||
AVG\s*\( { yy.lexer.unput('('); yytext = 'avg'; parser.addFunctionLocation(yylloc, yytext); return 'AVG'; }
|
||||
CAST\s*\( { yy.lexer.unput('('); yytext = 'cast'; parser.addFunctionLocation(yylloc, yytext); return 'CAST'; }
|
||||
COUNT\s*\( { yy.lexer.unput('('); yytext = 'count'; parser.addFunctionLocation(yylloc, yytext); return 'COUNT'; }
|
||||
MAX\s*\( { yy.lexer.unput('('); yytext = 'max'; parser.addFunctionLocation(yylloc, yytext); return 'MAX'; }
|
||||
MIN\s*\( { yy.lexer.unput('('); yytext = 'min'; parser.addFunctionLocation(yylloc, yytext); return 'MIN'; }
|
||||
STDDEV_POP\s*\( { yy.lexer.unput('('); yytext = 'stddev_pop'; parser.addFunctionLocation(yylloc, yytext); return 'STDDEV_POP'; }
|
||||
STDDEV_SAMP\s*\( { yy.lexer.unput('('); yytext = 'stddev_samp'; parser.addFunctionLocation(yylloc, yytext); return 'STDDEV_SAMP'; }
|
||||
SUM\s*\( { yy.lexer.unput('('); yytext = 'sum'; parser.addFunctionLocation(yylloc, yytext); return 'SUM'; }
|
||||
VAR_POP\s*\( { yy.lexer.unput('('); yytext = 'var_pop'; parser.addFunctionLocation(yylloc, yytext); return 'VAR_POP'; }
|
||||
VAR_SAMP\s*\( { yy.lexer.unput('('); yytext = 'var_samp'; parser.addFunctionLocation(yylloc, yytext); return 'VAR_SAMP'; }
|
||||
VARIANCE\s*\( { yy.lexer.unput('('); yytext = 'variance'; parser.addFunctionLocation(yylloc, yytext); return 'VARIANCE'; }
|
||||
|
||||
// Analytical functions
|
||||
CUME_DIST\s*\( { yy.lexer.unput('('); yytext = 'cume_dist'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
DENSE_RANK\s*\( { yy.lexer.unput('('); yytext = 'dense_rank'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
FIRST_VALUE\s*\( { yy.lexer.unput('('); yytext = 'first_value'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
LAG\s*\( { yy.lexer.unput('('); yytext = 'lag'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
LAST_VALUE\s*\( { yy.lexer.unput('('); yytext = 'last_value'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
LEAD\s*\( { yy.lexer.unput('('); yytext = 'lead'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
RANK\s*\( { yy.lexer.unput('('); yytext = 'rank'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
ROW_NUMBER\s*\( { yy.lexer.unput('('); yytext = 'row_number'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
|
||||
[0-9]+ { return 'UNSIGNED_INTEGER'; }
|
||||
[0-9]+(?:[YSL]|BD)? { return 'UNSIGNED_INTEGER'; }
|
||||
[0-9]+E { return 'UNSIGNED_INTEGER_E'; }
|
||||
[A-Za-z0-9_]+ { return 'REGULAR_IDENTIFIER'; }
|
||||
|
||||
<hdfs>'\u2020' { parser.yy.cursorFound = true; return 'CURSOR'; }
|
||||
<hdfs>'\u2021' { parser.yy.cursorFound = true; return 'PARTIAL_CURSOR'; }
|
||||
<hdfs>\s+['"] { return 'HDFS_START_QUOTE'; }
|
||||
<hdfs>[^'"\u2020\u2021]+ { parser.addFileLocation(yylloc, yytext); return 'HDFS_PATH'; }
|
||||
<hdfs>['"] { this.popState(); return 'HDFS_END_QUOTE'; }
|
||||
<hdfs><<EOF>> { return 'EOF'; }
|
||||
|
||||
'&&' { return 'AND'; }
|
||||
'||' { return 'OR'; }
|
||||
|
||||
'=' { return '='; }
|
||||
'<' { return '<'; }
|
||||
'>' { return '>'; }
|
||||
'!=' { return 'COMPARISON_OPERATOR'; }
|
||||
'<=' { return 'COMPARISON_OPERATOR'; }
|
||||
'>=' { return 'COMPARISON_OPERATOR'; }
|
||||
'<>' { return 'COMPARISON_OPERATOR'; }
|
||||
'<=>' { return 'COMPARISON_OPERATOR'; }
|
||||
|
||||
'-' { return '-'; }
|
||||
'*' { return '*'; }
|
||||
'+' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'/' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'%' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'|' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'^' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'&' { return 'ARITHMETIC_OPERATOR'; }
|
||||
|
||||
',' { return ','; }
|
||||
'.' { return '.'; }
|
||||
':' { return ':'; }
|
||||
';' { return ';'; }
|
||||
'~' { return '~'; }
|
||||
'!' { return '!'; }
|
||||
|
||||
'(' { return '('; }
|
||||
')' { return ')'; }
|
||||
'[' { return '['; }
|
||||
']' { return ']'; }
|
||||
|
||||
\$\{[^}]*\} { return 'VARIABLE_REFERENCE'; }
|
||||
|
||||
\` { this.begin('backtickedValue'); return 'BACKTICK'; }
|
||||
<backtickedValue>[^`]+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '`')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<backtickedValue>\` { this.popState(); return 'BACKTICK'; }
|
||||
|
||||
\' { this.begin('singleQuotedValue'); return 'SINGLE_QUOTE'; }
|
||||
<singleQuotedValue>(?:\\\\|\\[']|[^'])+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '\'')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<singleQuotedValue>\' { this.popState(); return 'SINGLE_QUOTE'; }
|
||||
|
||||
\" { this.begin('doubleQuotedValue'); return 'DOUBLE_QUOTE'; }
|
||||
<doubleQuotedValue>(?:\\\\|\\["]|[^"])+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '"')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<doubleQuotedValue>\" { this.popState(); return 'DOUBLE_QUOTE'; }
|
||||
|
||||
<<EOF>> { return 'EOF'; }
|
||||
|
||||
. { /* To prevent console logging of unknown chars */ }
|
||||
<between>. { }
|
||||
<hdfs>. { }
|
||||
<backtickedValue>. { }
|
||||
<singleQuotedValue>. { }
|
||||
<doubleQuotedValue>. { }
|
109
src/jison/sql/calcite/sql_alter.jison
Normal file
109
src/jison/sql/calcite/sql_alter.jison
Normal file
@ -0,0 +1,109 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: AlterStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: AlterStatement_EDIT
|
||||
;
|
||||
|
||||
AlterStatement
|
||||
: AlterTable
|
||||
| AlterView
|
||||
;
|
||||
|
||||
AlterStatement_EDIT
|
||||
: AlterTable_EDIT
|
||||
| AlterView_EDIT
|
||||
| 'ALTER' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['TABLE', 'VIEW']);
|
||||
}
|
||||
;
|
||||
|
||||
AlterTable
|
||||
: AlterTableLeftSide PartitionSpec
|
||||
;
|
||||
|
||||
AlterTable_EDIT
|
||||
: AlterTableLeftSide_EDIT
|
||||
| AlterTableLeftSide_EDIT PartitionSpec
|
||||
| AlterTableLeftSide 'CURSOR'
|
||||
| AlterTableLeftSide PartitionSpec 'CURSOR'
|
||||
;
|
||||
|
||||
AlterTableLeftSide
|
||||
: 'ALTER' 'TABLE' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
;
|
||||
|
||||
AlterTableLeftSide_EDIT
|
||||
: 'ALTER' 'TABLE' SchemaQualifiedTableIdentifier_EDIT
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyTables = true;
|
||||
}
|
||||
}
|
||||
| 'ALTER' 'TABLE' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables({ onlyTables: true });
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
;
|
||||
|
||||
AlterView
|
||||
: AlterViewLeftSide 'AS' QuerySpecification
|
||||
;
|
||||
|
||||
AlterView_EDIT
|
||||
: AlterViewLeftSide_EDIT
|
||||
| AlterViewLeftSide 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['AS']);
|
||||
}
|
||||
| AlterViewLeftSide 'SET' 'CURSOR'
|
||||
| AlterViewLeftSide 'AS' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
| AlterViewLeftSide 'AS' QuerySpecification_EDIT
|
||||
;
|
||||
|
||||
|
||||
AlterViewLeftSide
|
||||
: 'ALTER' 'VIEW' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
;
|
||||
|
||||
AlterViewLeftSide_EDIT
|
||||
: 'ALTER' 'VIEW' SchemaQualifiedTableIdentifier_EDIT
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyViews = true;
|
||||
}
|
||||
}
|
||||
| 'ALTER' 'VIEW' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables({ onlyViews: true });
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
;
|
615
src/jison/sql/calcite/sql_create.jison
Normal file
615
src/jison/sql/calcite/sql_create.jison
Normal file
@ -0,0 +1,615 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: CreateStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: CreateStatement_EDIT
|
||||
;
|
||||
|
||||
CreateStatement
|
||||
: DatabaseDefinition
|
||||
| TableDefinition
|
||||
| ViewDefinition
|
||||
| RoleDefinition
|
||||
;
|
||||
|
||||
CreateStatement_EDIT
|
||||
: DatabaseDefinition_EDIT
|
||||
| TableDefinition_EDIT
|
||||
| ViewDefinition_EDIT
|
||||
| 'CREATE' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['DATABASE', 'ROLE', 'SCHEMA', 'TABLE', 'VIEW']);
|
||||
}
|
||||
;
|
||||
|
||||
DatabaseDefinition
|
||||
: 'CREATE' DatabaseOrSchema OptionalIfNotExists
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals
|
||||
{
|
||||
parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
|
||||
}
|
||||
;
|
||||
|
||||
DatabaseDefinition_EDIT
|
||||
: 'CREATE' DatabaseOrSchema OptionalIfNotExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists_EDIT
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists 'CURSOR' RegularIdentifier
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
parser.addNewDatabaseLocation(@5, [{ name: $5 }]);
|
||||
}
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists_EDIT RegularIdentifier
|
||||
{
|
||||
parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
|
||||
}
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals 'CURSOR'
|
||||
{
|
||||
parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
|
||||
}
|
||||
;
|
||||
|
||||
DatabaseDefinitionOptionals
|
||||
: OptionalComment
|
||||
{
|
||||
if (!$1) {
|
||||
parser.suggestKeywords(['COMMENT']);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
DatabaseDefinitionOptionals_EDIT
|
||||
: OptionalComment_INVALID
|
||||
;
|
||||
|
||||
OptionalComment
|
||||
:
|
||||
| Comment
|
||||
;
|
||||
|
||||
Comment
|
||||
: 'COMMENT' QuotedValue
|
||||
;
|
||||
|
||||
OptionalComment_INVALID
|
||||
: Comment_INVALID
|
||||
;
|
||||
|
||||
Comment_INVALID
|
||||
: 'COMMENT' SINGLE_QUOTE
|
||||
| 'COMMENT' DOUBLE_QUOTE
|
||||
| 'COMMENT' SINGLE_QUOTE VALUE
|
||||
| 'COMMENT' DOUBLE_QUOTE VALUE
|
||||
;
|
||||
|
||||
TableDefinition
|
||||
: 'CREATE' 'TABLE' OptionalIfNotExists TableDefinitionRightPart
|
||||
;
|
||||
|
||||
TableDefinition_EDIT
|
||||
: 'CREATE' 'TABLE' OptionalIfNotExists TableDefinitionRightPart_EDIT
|
||||
| 'CREATE' 'TABLE' OptionalIfNotExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'CREATE' 'TABLE' OptionalIfNotExists_EDIT
|
||||
;
|
||||
|
||||
TableDefinitionRightPart
|
||||
: TableIdentifierAndOptionalColumnSpecification OptionalPartitionedBy OptionalAsSelectStatement
|
||||
;
|
||||
|
||||
TableDefinitionRightPart_EDIT
|
||||
: TableIdentifierAndOptionalColumnSpecification_EDIT OptionalPartitionedBy OptionalAsSelectStatement
|
||||
| TableIdentifierAndOptionalColumnSpecification PartitionedBy_EDIT OptionalAsSelectStatement
|
||||
| TableIdentifierAndOptionalColumnSpecification OptionalPartitionedBy OptionalAsSelectStatement_EDIT
|
||||
| TableIdentifierAndOptionalColumnSpecification OptionalPartitionedBy 'CURSOR'
|
||||
{
|
||||
var keywords = [];
|
||||
if (!$1 && !$2) {
|
||||
keywords.push({ value: 'LIKE', weight: 1 });
|
||||
} else {
|
||||
if (!$2) {
|
||||
keywords.push({ value: 'PARTITIONED BY', weight: 12 });
|
||||
}
|
||||
keywords.push({ value: 'AS', weight: 1 });
|
||||
}
|
||||
|
||||
if (keywords.length > 0) {
|
||||
parser.suggestKeywords(keywords);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
TableIdentifierAndOptionalColumnSpecification
|
||||
: SchemaQualifiedIdentifier OptionalColumnSpecificationsOrLike
|
||||
{
|
||||
parser.addNewTableLocation(@1, $1, $2);
|
||||
$$ = $2;
|
||||
}
|
||||
;
|
||||
|
||||
TableIdentifierAndOptionalColumnSpecification_EDIT
|
||||
: SchemaQualifiedIdentifier OptionalColumnSpecificationsOrLike_EDIT
|
||||
| SchemaQualifiedIdentifier_EDIT OptionalColumnSpecificationsOrLike
|
||||
;
|
||||
|
||||
OptionalColumnSpecificationsOrLike
|
||||
:
|
||||
| ParenthesizedColumnSpecificationList
|
||||
| 'LIKE' SchemaQualifiedTableIdentifier -> []
|
||||
;
|
||||
|
||||
OptionalColumnSpecificationsOrLike_EDIT
|
||||
: ParenthesizedColumnSpecificationList_EDIT
|
||||
| 'LIKE' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'LIKE' SchemaQualifiedTableIdentifier_EDIT
|
||||
;
|
||||
|
||||
ParenthesizedColumnSpecificationList
|
||||
: '(' ColumnSpecificationList ')' -> $2
|
||||
;
|
||||
|
||||
ParenthesizedColumnSpecificationList_EDIT
|
||||
: '(' ColumnSpecificationList_EDIT RightParenthesisOrError
|
||||
;
|
||||
|
||||
ColumnSpecificationList
|
||||
: ColumnSpecification -> [$1]
|
||||
| ColumnSpecificationList ',' ColumnSpecification -> $1.concat($3)
|
||||
;
|
||||
|
||||
ColumnSpecificationList_EDIT
|
||||
: ColumnSpecification_EDIT
|
||||
| ColumnSpecification_EDIT ',' ColumnSpecificationList
|
||||
| ColumnSpecificationList ',' ColumnSpecification_EDIT
|
||||
| ColumnSpecificationList ',' ColumnSpecification_EDIT ',' ColumnSpecificationList
|
||||
| ColumnSpecification 'CURSOR'
|
||||
{
|
||||
parser.checkForKeywords($1);
|
||||
}
|
||||
| ColumnSpecification 'CURSOR' ',' ColumnSpecificationList
|
||||
{
|
||||
parser.checkForKeywords($1);
|
||||
}
|
||||
| ColumnSpecificationList ',' ColumnSpecification 'CURSOR'
|
||||
{
|
||||
parser.checkForKeywords($3);
|
||||
}
|
||||
| ColumnSpecificationList ',' ColumnSpecification 'CURSOR' ',' ColumnSpecificationList
|
||||
{
|
||||
parser.checkForKeywords($3);
|
||||
}
|
||||
;
|
||||
|
||||
ColumnSpecification
|
||||
: ColumnIdentifier ColumnDataType OptionalColumnOptions
|
||||
{
|
||||
$$ = $1;
|
||||
$$.type = $2;
|
||||
var keywords = [];
|
||||
if (!$3['comment']) {
|
||||
keywords.push('COMMENT');
|
||||
}
|
||||
if (keywords.length > 0) {
|
||||
$$.suggestKeywords = keywords;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
ColumnSpecification_EDIT
|
||||
: ColumnIdentifier 'CURSOR' OptionalColumnOptions
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| ColumnIdentifier ColumnDataType_EDIT OptionalColumnOptions
|
||||
| ColumnIdentifier ColumnDataType ColumnOptions_EDIT
|
||||
;
|
||||
|
||||
OptionalColumnOptions
|
||||
: -> {}
|
||||
| ColumnOptions
|
||||
;
|
||||
|
||||
ColumnOptions
|
||||
: ColumnOption
|
||||
{
|
||||
$$ = {};
|
||||
$$[$1] = true;
|
||||
}
|
||||
| ColumnOptions ColumnOption
|
||||
{
|
||||
$1[$2] = true;
|
||||
}
|
||||
;
|
||||
|
||||
ColumnOptions_EDIT
|
||||
: ColumnOption_EDIT
|
||||
| ColumnOption_EDIT ColumnOptions
|
||||
| ColumnOptions ColumnOption_EDIT
|
||||
| ColumnOptions ColumnOption_EDIT ColumnOptions
|
||||
;
|
||||
|
||||
ColumnOption
|
||||
: 'NOT' 'NULL' -> 'null'
|
||||
| 'NULL' -> 'null'
|
||||
| Comment -> 'comment'
|
||||
;
|
||||
|
||||
ColumnOption_EDIT
|
||||
: 'NOT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['NULL']);
|
||||
}
|
||||
;
|
||||
|
||||
ColumnDataType
|
||||
: PrimitiveType
|
||||
| ArrayType
|
||||
| MapType
|
||||
| StructType
|
||||
| ArrayType_INVALID
|
||||
| MapType_INVALID
|
||||
| StructType_INVALID
|
||||
;
|
||||
|
||||
ColumnDataType_EDIT
|
||||
: ArrayType_EDIT
|
||||
| MapType_EDIT
|
||||
| StructType_EDIT
|
||||
;
|
||||
|
||||
ArrayType
|
||||
: 'ARRAY' '<' ColumnDataType '>'
|
||||
;
|
||||
|
||||
ArrayType_INVALID
|
||||
: 'ARRAY' '<' '>'
|
||||
;
|
||||
|
||||
ArrayType_EDIT
|
||||
: 'ARRAY' '<' AnyCursor GreaterThanOrError
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| 'ARRAY' '<' ColumnDataType_EDIT GreaterThanOrError
|
||||
;
|
||||
|
||||
MapType
|
||||
: 'MAP' '<' PrimitiveType ',' ColumnDataType '>'
|
||||
;
|
||||
|
||||
MapType_INVALID
|
||||
: 'MAP' '<' '>'
|
||||
;
|
||||
|
||||
MapType_EDIT
|
||||
: 'MAP' '<' PrimitiveType ',' ColumnDataType_EDIT GreaterThanOrError
|
||||
| 'MAP' '<' AnyCursor GreaterThanOrError
|
||||
{
|
||||
parser.suggestKeywords(parser.getTypeKeywords());
|
||||
}
|
||||
| 'MAP' '<' PrimitiveType ',' AnyCursor GreaterThanOrError
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| 'MAP' '<' ',' AnyCursor GreaterThanOrError
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
;
|
||||
|
||||
StructType
|
||||
: 'STRUCT' '<' StructDefinitionList '>'
|
||||
;
|
||||
|
||||
StructType_INVALID
|
||||
: 'STRUCT' '<' '>'
|
||||
;
|
||||
|
||||
StructType_EDIT
|
||||
: 'STRUCT' '<' StructDefinitionList_EDIT GreaterThanOrError
|
||||
;
|
||||
|
||||
StructDefinitionList
|
||||
: StructDefinition
|
||||
| StructDefinitionList ',' StructDefinition
|
||||
;
|
||||
|
||||
StructDefinitionList_EDIT
|
||||
: StructDefinition_EDIT
|
||||
| StructDefinition_EDIT Commas
|
||||
| StructDefinition_EDIT Commas StructDefinitionList
|
||||
| StructDefinitionList ',' StructDefinition_EDIT
|
||||
| StructDefinitionList ',' StructDefinition_EDIT Commas StructDefinitionList
|
||||
;
|
||||
|
||||
StructDefinition
|
||||
: RegularOrBacktickedIdentifier ':' ColumnDataType OptionalComment
|
||||
;
|
||||
|
||||
StructDefinition_EDIT
|
||||
: Commas RegularOrBacktickedIdentifier ':' ColumnDataType 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['COMMENT']);
|
||||
}
|
||||
| Commas RegularOrBacktickedIdentifier ':' AnyCursor
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| Commas RegularOrBacktickedIdentifier ':' ColumnDataType_EDIT
|
||||
| RegularOrBacktickedIdentifier ':' ColumnDataType 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['COMMENT']);
|
||||
}
|
||||
| RegularOrBacktickedIdentifier ':' AnyCursor
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| RegularOrBacktickedIdentifier ':' ColumnDataType_EDIT
|
||||
;
|
||||
|
||||
ColumnDataTypeList
|
||||
: ColumnDataType
|
||||
| ColumnDataTypeList ',' ColumnDataType
|
||||
;
|
||||
|
||||
ColumnDataTypeList_EDIT
|
||||
: ColumnDataTypeListInner_EDIT
|
||||
| ColumnDataTypeListInner_EDIT Commas
|
||||
| ColumnDataTypeList ',' ColumnDataTypeListInner_EDIT
|
||||
| ColumnDataTypeListInner_EDIT Commas ColumnDataTypeList
|
||||
| ColumnDataTypeList ',' ColumnDataTypeListInner_EDIT Commas ColumnDataTypeList
|
||||
;
|
||||
|
||||
ColumnDataTypeListInner_EDIT
|
||||
: Commas AnyCursor
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| Commas ColumnDataType_EDIT
|
||||
| AnyCursor
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| ColumnDataType_EDIT
|
||||
;
|
||||
|
||||
GreaterThanOrError
|
||||
: '>'
|
||||
| error
|
||||
;
|
||||
|
||||
OptionalPartitionedBy
|
||||
:
|
||||
| PartitionedBy
|
||||
;
|
||||
|
||||
PartitionedBy
|
||||
: 'PARTITION' 'BY' RangeClause
|
||||
;
|
||||
|
||||
PartitionedBy_EDIT
|
||||
: 'PARTITION' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['BY']);
|
||||
}
|
||||
| 'PARTITION' 'BY' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['RANGE']);
|
||||
}
|
||||
| 'PARTITION' 'BY' RangeClause_EDIT
|
||||
;
|
||||
|
||||
RangeClause
|
||||
: 'RANGE' ParenthesizedColumnList ParenthesizedPartitionValuesList
|
||||
;
|
||||
|
||||
RangeClause_EDIT
|
||||
: 'RANGE' 'CURSOR'
|
||||
| 'RANGE' ParenthesizedColumnList_EDIT
|
||||
| 'RANGE' ParenthesizedColumnList 'CURSOR'
|
||||
| 'RANGE' ParenthesizedColumnList ParenthesizedPartitionValuesList_EDIT
|
||||
| 'RANGE' ParenthesizedColumnList_EDIT ParenthesizedPartitionValuesList
|
||||
;
|
||||
|
||||
ParenthesizedPartitionValuesList
|
||||
: '(' PartitionValueList ')'
|
||||
;
|
||||
|
||||
ParenthesizedPartitionValuesList_EDIT
|
||||
: '(' 'CURSOR' RightParenthesisOrError
|
||||
{
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
|'(' PartitionValueList_EDIT RightParenthesisOrError
|
||||
;
|
||||
|
||||
PartitionValueList
|
||||
: PartitionValue
|
||||
| PartitionValueList ',' PartitionValue
|
||||
;
|
||||
|
||||
PartitionValueList_EDIT
|
||||
: PartitionValue_EDIT
|
||||
| PartitionValueList ',' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
| PartitionValueList ',' 'CURSOR' ',' PartitionValueList
|
||||
{
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
| PartitionValueList ',' PartitionValue_EDIT
|
||||
| PartitionValueList ',' PartitionValue_EDIT ',' PartitionValueList
|
||||
;
|
||||
|
||||
PartitionValue
|
||||
: 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' LessThanOrEqualTo ValueExpression
|
||||
| 'PARTITION' 'VALUES' LessThanOrEqualTo ValueExpression
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES'
|
||||
;
|
||||
|
||||
PartitionValue_EDIT
|
||||
: 'PARTITION' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['VALUE', 'VALUES']);
|
||||
}
|
||||
| 'PARTITION' ValueExpression_EDIT
|
||||
{
|
||||
if ($2.endsWithLessThanOrEqual) {
|
||||
parser.suggestKeywords(['VALUES']);
|
||||
}
|
||||
}
|
||||
| 'PARTITION' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['<', '<=']);
|
||||
}
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['VALUES']);
|
||||
}
|
||||
| 'PARTITION' ValueExpression_EDIT LessThanOrEqualTo 'VALUES'
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['<', '<=']);
|
||||
}
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' LessThanOrEqualTo 'CURSOR'
|
||||
{
|
||||
parser.suggestFunctions();
|
||||
}
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' LessThanOrEqualTo ValueExpression_EDIT
|
||||
| 'PARTITION' 'VALUES' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['<', '<=']);
|
||||
}
|
||||
| 'PARTITION' 'VALUES' LessThanOrEqualTo 'CURSOR'
|
||||
{
|
||||
parser.suggestFunctions();
|
||||
}
|
||||
| 'PARTITION' 'VALUES' LessThanOrEqualTo ValueExpression_EDIT
|
||||
;
|
||||
|
||||
LessThanOrEqualTo
|
||||
: '<'
|
||||
| 'COMPARISON_OPERATOR' // This is fine for autocompletion
|
||||
;
|
||||
|
||||
OptionalAsSelectStatement
|
||||
:
|
||||
| 'AS' CommitLocations QuerySpecification
|
||||
;
|
||||
|
||||
OptionalAsSelectStatement_EDIT
|
||||
: 'AS' CommitLocations 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
| 'AS' CommitLocations QuerySpecification_EDIT
|
||||
;
|
||||
|
||||
CommitLocations
|
||||
: /* empty */
|
||||
{
|
||||
parser.commitLocations();
|
||||
}
|
||||
;
|
||||
|
||||
ViewDefinition
|
||||
: 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'AS' QuerySpecification
|
||||
;
|
||||
|
||||
ViewDefinition_EDIT
|
||||
: 'CREATE' 'VIEW' OptionalIfNotExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists 'CURSOR' SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'AS' QuerySpecification
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists_EDIT
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedViewColumnList_EDIT OptionalComment
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'CURSOR'
|
||||
{
|
||||
var keywords = [{value: 'AS', weight: 1 }];
|
||||
if (!$6) {
|
||||
keywords.push({ value: 'COMMENT', weight: 3 });
|
||||
}
|
||||
parser.suggestKeywords(keywords);
|
||||
}
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'AS' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'AS' QuerySpecification_EDIT
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier_EDIT OptionalParenthesizedViewColumnList OptionalComment 'AS' QuerySpecification
|
||||
;
|
||||
|
||||
OptionalParenthesizedViewColumnList
|
||||
:
|
||||
| ParenthesizedViewColumnList
|
||||
;
|
||||
|
||||
ParenthesizedViewColumnList
|
||||
: '(' ViewColumnList ')'
|
||||
;
|
||||
|
||||
ParenthesizedViewColumnList_EDIT
|
||||
: '(' ViewColumnList_EDIT RightParenthesisOrError
|
||||
{
|
||||
if (!$2) {
|
||||
parser.suggestKeywords(['COMMENT']);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
ViewColumnList
|
||||
: ColumnReference OptionalComment
|
||||
| ViewColumnList ',' ColumnReference OptionalComment
|
||||
;
|
||||
|
||||
ViewColumnList_EDIT
|
||||
: ColumnReference OptionalComment 'CURSOR' -> $2
|
||||
| ColumnReference OptionalComment 'CURSOR' ',' ViewColumnList -> $2
|
||||
| ViewColumnList ',' ColumnReference OptionalComment 'CURSOR' -> $4
|
||||
| ViewColumnList ',' ColumnReference OptionalComment 'CURSOR' ',' ViewColumnList -> $4
|
||||
;
|
||||
|
||||
RoleDefinition
|
||||
: 'CREATE' 'ROLE' RegularIdentifier
|
||||
;
|
184
src/jison/sql/calcite/sql_drop.jison
Normal file
184
src/jison/sql/calcite/sql_drop.jison
Normal file
@ -0,0 +1,184 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: DropStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: DropStatement_EDIT
|
||||
;
|
||||
|
||||
DropStatement
|
||||
: DropDatabaseStatement
|
||||
| DropRoleStatement
|
||||
| DropTableStatement
|
||||
| DropViewStatement
|
||||
| TruncateTableStatement
|
||||
;
|
||||
|
||||
DropStatement_EDIT
|
||||
: DropDatabaseStatement_EDIT
|
||||
| DropTableStatement_EDIT
|
||||
| DropViewStatement_EDIT
|
||||
| TruncateTableStatement_EDIT
|
||||
| 'DROP' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['DATABASE', 'ROLE', 'SCHEMA', 'TABLE', 'VIEW']);
|
||||
}
|
||||
;
|
||||
|
||||
DropDatabaseStatement
|
||||
: 'DROP' DatabaseOrSchema OptionalIfExists RegularOrBacktickedIdentifier OptionalCascade
|
||||
;
|
||||
|
||||
DropDatabaseStatement_EDIT
|
||||
: 'DROP' DatabaseOrSchema OptionalIfExists
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists_EDIT
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
parser.suggestDatabases();
|
||||
}
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists RegularOrBacktickedIdentifier 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['CASCADE']);
|
||||
}
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists_EDIT RegularOrBacktickedIdentifier OptionalCascade
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists 'CURSOR' RegularOrBacktickedIdentifier OptionalCascade
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
;
|
||||
DropRoleStatement
|
||||
: 'DROP' 'ROLE' RegularIdentifier
|
||||
;
|
||||
|
||||
DropTableStatement
|
||||
: 'DROP' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier OptionalPurge
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
DropTableStatement_EDIT
|
||||
: 'DROP' 'TABLE' OptionalIfExists_EDIT
|
||||
| 'DROP' 'TABLE' OptionalIfExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
parser.suggestTables({ onlyTables: true });
|
||||
parser.suggestDatabases({
|
||||
appendDot: true
|
||||
});
|
||||
}
|
||||
| 'DROP' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier_EDIT OptionalPurge
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyTables = true;
|
||||
}
|
||||
}
|
||||
| 'DROP' 'TABLE' OptionalIfExists_EDIT SchemaQualifiedTableIdentifier OptionalPurge
|
||||
| 'DROP' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier OptionalPurge 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
if (!$5) {
|
||||
parser.suggestKeywords(['PURGE']);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
OptionalPurge
|
||||
:
|
||||
| 'PURGE'
|
||||
;
|
||||
|
||||
DropViewStatement
|
||||
: 'DROP' 'VIEW' OptionalIfExists SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
DropViewStatement_EDIT
|
||||
: 'DROP' 'VIEW' OptionalIfExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
parser.suggestTables({ onlyViews: true });
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'DROP' 'VIEW' OptionalIfExists 'CURSOR' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($5);
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'DROP' 'VIEW' OptionalIfExists_EDIT
|
||||
| 'DROP' 'VIEW' OptionalIfExists_EDIT SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
| 'DROP' 'VIEW' OptionalIfExists SchemaQualifiedTableIdentifier_EDIT
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyViews = true;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
TruncateTableStatement
|
||||
: 'TRUNCATE' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
TruncateTableStatement_EDIT
|
||||
: 'TRUNCATE' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['TABLE']);
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists_EDIT
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier_EDIT
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists 'CURSOR' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists_EDIT SchemaQualifiedTableIdentifier OptionalPartitionSpec
|
||||
;
|
132
src/jison/sql/calcite/sql_error.jison
Normal file
132
src/jison/sql/calcite/sql_error.jison
Normal file
@ -0,0 +1,132 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
SqlStatements
|
||||
: error
|
||||
| NonStartingToken error // Having just ': error' does not work for some reason, jison bug?
|
||||
;
|
||||
|
||||
SqlStatement_EDIT
|
||||
: AnyCursor error
|
||||
{
|
||||
parser.suggestDdlAndDmlKeywords();
|
||||
}
|
||||
;
|
||||
|
||||
SelectStatement
|
||||
: 'SELECT' OptionalAllOrDistinct SelectList_ERROR TableExpression
|
||||
| 'SELECT' OptionalAllOrDistinct SelectList TableExpression_ERROR
|
||||
;
|
||||
|
||||
SelectStatement_EDIT
|
||||
: 'SELECT' OptionalAllOrDistinct SelectList_ERROR_EDIT TableExpression
|
||||
{
|
||||
parser.selectListNoTableSuggest($3, $2);
|
||||
}
|
||||
| 'SELECT' OptionalAllOrDistinct SelectList_ERROR TableExpression_EDIT
|
||||
;
|
||||
|
||||
SelectList_ERROR
|
||||
: ErrorList
|
||||
| SelectList ',' ErrorList
|
||||
| ErrorList ',' SelectList ',' ErrorList
|
||||
| ErrorList ',' SelectList
|
||||
| SelectList ',' ErrorList ',' SelectList
|
||||
;
|
||||
|
||||
SelectList_ERROR_EDIT
|
||||
: ErrorList ',' SelectList_EDIT -> $3
|
||||
| SelectList ',' ErrorList ',' SelectList_EDIT -> $5
|
||||
| ErrorList ',' SelectList ',' ErrorList ',' SelectList_EDIT -> $7
|
||||
| ErrorList ',' AnyCursor
|
||||
{
|
||||
$$ = { cursorAtStart : false, suggestFunctions: true, suggestColumns: true, suggestAggregateFunctions: true };
|
||||
}
|
||||
| SelectList ',' ErrorList ',' AnyCursor
|
||||
{
|
||||
$$ = { cursorAtStart : false, suggestFunctions: true, suggestColumns: true, suggestAggregateFunctions: true };
|
||||
}
|
||||
| ErrorList ',' SelectList ',' Errors ',' AnyCursor
|
||||
{
|
||||
$$ = { cursorAtStart : true, suggestFunctions: true, suggestColumns: true, suggestAggregateFunctions: true };
|
||||
}
|
||||
;
|
||||
|
||||
SetSpecification
|
||||
: 'SET' SetOption '=' error
|
||||
;
|
||||
|
||||
ErrorList
|
||||
: error
|
||||
| Errors ',' error
|
||||
;
|
||||
|
||||
JoinType_EDIT
|
||||
: 'FULL' 'CURSOR' error
|
||||
{
|
||||
parser.suggestKeywords(['JOIN', 'OUTER JOIN']);
|
||||
}
|
||||
| 'LEFT' 'CURSOR' error
|
||||
{
|
||||
parser.suggestKeywords(['JOIN', 'OUTER JOIN']);
|
||||
}
|
||||
| 'RIGHT' 'CURSOR' error
|
||||
{
|
||||
parser.suggestKeywords(['JOIN', 'OUTER JOIN']);
|
||||
}
|
||||
;
|
||||
|
||||
OptionalSelectConditions_EDIT
|
||||
: WhereClause error 'CURSOR' OptionalGroupByClause OptionalHavingClause OptionalOrderByClause OptionalLimitClause
|
||||
{
|
||||
$$ = {
|
||||
suggestKeywords: parser.getKeywordsForOptionalsLR([$4, $5, $6, $7], [{ value: 'GROUP BY', weight: 8 }, { value: 'HAVING', weight: 7 }, { value: 'ORDER BY', weight: 5 }, { value: 'LIMIT', weight: 3 }], [true, true, true, true]),
|
||||
cursorAtEnd: !$4 && !$5 && !$6 && !$7
|
||||
};
|
||||
}
|
||||
| OptionalWhereClause OptionalGroupByClause HavingClause error 'CURSOR' OptionalOrderByClause OptionalLimitClause
|
||||
{
|
||||
$$ = {
|
||||
suggestKeywords: parser.getKeywordsForOptionalsLR([$6, $7], [{ value: 'ORDER BY', weight: 5 }, { value: 'LIMIT', weight: 3 }], [true, true]),
|
||||
cursorAtEnd: !$6 && !$7
|
||||
}
|
||||
}
|
||||
| OptionalWhereClause OptionalGroupByClause OptionalHavingClause OrderByClause error 'CURSOR' OptionalLimitClause
|
||||
{
|
||||
$$ = {
|
||||
suggestKeywords: parser.getKeywordsForOptionalsLR([$7], [{ value: 'LIMIT', weight: 3 }], [true]),
|
||||
cursorAtEnd: !$7
|
||||
}
|
||||
}
|
||||
| OptionalWhereClause OptionalGroupByClause OptionalHavingClause OptionalOrderByClause LimitClause error 'CURSOR'
|
||||
;
|
||||
|
||||
OptionalSelectConditions_EDIT
|
||||
: WhereClause error GroupByClause_EDIT OptionalHavingClause OptionalOrderByClause OptionalLimitClause
|
||||
| WhereClause error OptionalGroupByClause HavingClause_EDIT OptionalOrderByClause OptionalLimitClause
|
||||
| WhereClause error OptionalGroupByClause OptionalHavingClause OrderByClause_EDIT OptionalLimitClause
|
||||
| WhereClause error OptionalGroupByClause OptionalHavingClause OptionalOrderByClause LimitClause_EDIT
|
||||
| OptionalWhereClause GroupByClause error HavingClause_EDIT OptionalOrderByClause OptionalLimitClause
|
||||
| OptionalWhereClause GroupByClause error OptionalHavingClause OrderByClause_EDIT OptionalLimitClause
|
||||
| OptionalWhereClause GroupByClause error OptionalHavingClause OptionalOrderByClause LimitClause_EDIT
|
||||
| OptionalWhereClause OptionalGroupByClause HavingClause error OrderByClause_EDIT OptionalLimitClause
|
||||
| OptionalWhereClause OptionalGroupByClause HavingClause error OptionalOrderByClause LimitClause_EDIT
|
||||
| OptionalWhereClause OptionalGroupByClause OptionalHavingClause OrderByClause error LimitClause_EDIT
|
||||
;
|
||||
|
||||
DatabaseDefinition_EDIT
|
||||
: 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals_EDIT error
|
||||
;
|
72
src/jison/sql/calcite/sql_insert.jison
Normal file
72
src/jison/sql/calcite/sql_insert.jison
Normal file
@ -0,0 +1,72 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataManipulation
|
||||
: InsertStatement
|
||||
;
|
||||
|
||||
InsertStatement
|
||||
: InsertValuesStatement
|
||||
;
|
||||
|
||||
DataManipulation_EDIT
|
||||
: InsertValuesStatement_EDIT
|
||||
;
|
||||
|
||||
InsertValuesStatement
|
||||
: 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier 'VALUES' InsertValuesList
|
||||
{
|
||||
$4.owner = 'insert';
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
InsertValuesStatement_EDIT
|
||||
: 'INSERT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['INTO']);
|
||||
}
|
||||
| 'INSERT' 'INTO' OptionalTable 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['TABLE']);
|
||||
}
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier_EDIT
|
||||
| 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier 'CURSOR'
|
||||
{
|
||||
$4.owner = 'insert';
|
||||
parser.addTablePrimary($4);
|
||||
parser.suggestKeywords(['VALUES']);
|
||||
}
|
||||
| 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier_EDIT 'VALUES' InsertValuesList
|
||||
;
|
||||
|
||||
InsertValuesList
|
||||
: ParenthesizedRowValuesList
|
||||
| RowValuesList ',' ParenthesizedRowValuesList
|
||||
;
|
||||
|
||||
ParenthesizedRowValuesList
|
||||
: '(' InValueList ')'
|
||||
;
|
||||
|
||||
OptionalTable
|
||||
:
|
||||
| 'TABLE'
|
||||
;
|
2762
src/jison/sql/calcite/sql_main.jison
Normal file
2762
src/jison/sql/calcite/sql_main.jison
Normal file
File diff suppressed because it is too large
Load Diff
46
src/jison/sql/calcite/sql_set.jison
Normal file
46
src/jison/sql/calcite/sql_set.jison
Normal file
@ -0,0 +1,46 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: SetSpecification
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: 'SET' 'CURSOR'
|
||||
{
|
||||
parser.suggestSetOptions();
|
||||
}
|
||||
;
|
||||
|
||||
SetSpecification
|
||||
: 'SET' SetOption '=' SetValue
|
||||
| 'SET' 'ALL'
|
||||
;
|
||||
|
||||
SetOption
|
||||
: RegularIdentifier
|
||||
| SetOption '.' RegularIdentifier
|
||||
;
|
||||
|
||||
SetValue
|
||||
: RegularIdentifier
|
||||
| SignedInteger
|
||||
| SignedInteger RegularIdentifier
|
||||
| QuotedValue
|
||||
| 'TRUE'
|
||||
| 'FALSE'
|
||||
| 'NULL'
|
||||
;
|
122
src/jison/sql/calcite/sql_update.jison
Normal file
122
src/jison/sql/calcite/sql_update.jison
Normal file
@ -0,0 +1,122 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataManipulation
|
||||
: UpdateStatement
|
||||
;
|
||||
|
||||
DataManipulation_EDIT
|
||||
: UpdateStatement_EDIT
|
||||
;
|
||||
|
||||
UpdateStatement
|
||||
: 'UPDATE' TargetTable 'SET' SetClauseList OptionalFromJoinedTable OptionalWhereClause
|
||||
;
|
||||
|
||||
UpdateStatement_EDIT
|
||||
: 'UPDATE' TargetTable_EDIT 'SET' SetClauseList OptionalFromJoinedTable OptionalWhereClause
|
||||
| 'UPDATE' TargetTable 'SET' SetClauseList_EDIT OptionalFromJoinedTable OptionalWhereClause
|
||||
| 'UPDATE' TargetTable 'SET' SetClauseList FromJoinedTable_EDIT OptionalWhereClause
|
||||
| 'UPDATE' TargetTable 'SET' SetClauseList OptionalFromJoinedTable WhereClause_EDIT
|
||||
| 'UPDATE' TargetTable 'SET' SetClauseList OptionalFromJoinedTable OptionalWhereClause 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords([ 'WHERE' ]);
|
||||
}
|
||||
| 'UPDATE' TargetTable 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords([ 'SET' ]);
|
||||
}
|
||||
| 'UPDATE' TargetTable_EDIT
|
||||
| 'UPDATE' TargetTable
|
||||
| 'UPDATE' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
;
|
||||
|
||||
TargetTable
|
||||
: TableName
|
||||
;
|
||||
|
||||
TargetTable_EDIT
|
||||
: TableName_EDIT
|
||||
;
|
||||
|
||||
TableName
|
||||
: LocalOrSchemaQualifiedName
|
||||
{
|
||||
parser.addTablePrimary($1);
|
||||
}
|
||||
;
|
||||
|
||||
TableName_EDIT
|
||||
: LocalOrSchemaQualifiedName_EDIT
|
||||
;
|
||||
|
||||
SetClauseList
|
||||
: SetClause
|
||||
| SetClauseList ',' SetClause
|
||||
;
|
||||
|
||||
SetClauseList_EDIT
|
||||
: SetClause_EDIT
|
||||
| SetClauseList ',' SetClause_EDIT
|
||||
| SetClause_EDIT ',' SetClauseList
|
||||
| SetClauseList ',' SetClause_EDIT ',' SetClauseList
|
||||
;
|
||||
|
||||
SetClause
|
||||
: SetTarget '=' UpdateSource
|
||||
;
|
||||
|
||||
SetClause_EDIT
|
||||
: SetTarget '=' UpdateSource_EDIT
|
||||
| SetTarget 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords([ '=' ]);
|
||||
}
|
||||
| 'CURSOR'
|
||||
{
|
||||
parser.suggestColumns();
|
||||
}
|
||||
;
|
||||
|
||||
SetTarget
|
||||
: ColumnReference
|
||||
;
|
||||
|
||||
UpdateSource
|
||||
: ValueExpression
|
||||
;
|
||||
|
||||
UpdateSource_EDIT
|
||||
: ValueExpression_EDIT
|
||||
;
|
||||
|
||||
OptionalFromJoinedTable
|
||||
:
|
||||
| 'FROM' TableReference -> $2
|
||||
;
|
||||
|
||||
FromJoinedTable_EDIT
|
||||
: 'FROM' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'FROM' TableReference_EDIT
|
||||
;
|
39
src/jison/sql/calcite/sql_use.jison
Normal file
39
src/jison/sql/calcite/sql_use.jison
Normal file
@ -0,0 +1,39 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: UseStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: UseStatement_EDIT
|
||||
;
|
||||
|
||||
UseStatement
|
||||
: 'USE' RegularIdentifier
|
||||
{
|
||||
if (! parser.yy.cursorFound) {
|
||||
parser.yy.result.useDatabase = $2;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
UseStatement_EDIT
|
||||
: 'USE' 'CURSOR'
|
||||
{
|
||||
parser.suggestDatabases();
|
||||
}
|
||||
;
|
839
src/jison/sql/calcite/sql_valueExpression.jison
Normal file
839
src/jison/sql/calcite/sql_valueExpression.jison
Normal file
@ -0,0 +1,839 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
ValueExpression
|
||||
: 'NOT' ValueExpression
|
||||
{
|
||||
// verifyType($2, 'BOOLEAN');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| '!' ValueExpression
|
||||
{
|
||||
// verifyType($2, 'BOOLEAN');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| '~' ValueExpression -> $2
|
||||
| '-' ValueExpression %prec NEGATION
|
||||
{
|
||||
// verifyType($2, 'NUMBER');
|
||||
$$ = $2;
|
||||
$2.types = ['NUMBER'];
|
||||
}
|
||||
| ValueExpression 'IS' OptionalNot 'NULL' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IS' OptionalNot 'TRUE' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IS' OptionalNot 'FALSE' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IS' OptionalNot 'DISTINCT' 'FROM' ValueExpression -> { types: [ 'BOOLEAN' ] }
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'NOT' ValueExpression_EDIT -> { types: [ 'BOOLEAN' ], suggestFilters: $2.suggestFilters }
|
||||
| 'NOT' 'CURSOR'
|
||||
{
|
||||
parser.suggestFunctions();
|
||||
parser.suggestColumns();
|
||||
parser.suggestKeywords(['EXISTS']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| '!' ValueExpression_EDIT -> { types: [ 'BOOLEAN' ], suggestFilters: $2.suggestFilters }
|
||||
| '!' AnyCursor
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'BOOLEAN' ] });
|
||||
parser.suggestColumns({ types: [ 'BOOLEAN' ] });
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| '~' ValueExpression_EDIT -> { types: [ 'T' ], suggestFilters: $2.suggestFilters }
|
||||
| '~' 'PARTIAL_CURSOR'
|
||||
{
|
||||
parser.suggestFunctions();
|
||||
parser.suggestColumns();
|
||||
$$ = { types: [ 'T' ] };
|
||||
}
|
||||
| '-' ValueExpression_EDIT %prec NEGATION
|
||||
{
|
||||
if (!$2.typeSet) {
|
||||
parser.applyTypeToSuggestions('NUMBER');
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $2.suggestFilters };
|
||||
}
|
||||
| '-' 'PARTIAL_CURSOR' %prec NEGATION
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'NUMBER' ] });
|
||||
parser.suggestColumns({ types: [ 'NUMBER' ] });
|
||||
$$ = { types: [ 'NUMBER' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['FALSE', 'NOT NULL', 'NOT TRUE', 'NOT FALSE', 'NULL', 'TRUE']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'NOT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['FALSE', 'NULL', 'TRUE']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' OptionalNot 'DISTINCT' 'CURSOR'
|
||||
{
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'CURSOR' 'NULL'
|
||||
{
|
||||
parser.suggestKeywords(['NOT']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'CURSOR' 'FALSE'
|
||||
{
|
||||
parser.suggestKeywords(['NOT']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'CURSOR' 'TRUE'
|
||||
{
|
||||
parser.suggestKeywords(['NOT']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' OptionalNot 'DISTINCT' 'FROM' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $3 ? 'IS NOT DISTINCT FROM' : 'IS DISTINCT FROM');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' OptionalNot 'DISTINCT' 'FROM' ValueExpression_EDIT
|
||||
{
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $6.suggestFilters }
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ EXISTS and parenthesized ------------------
|
||||
ValueExpression
|
||||
: 'EXISTS' TableSubQuery
|
||||
{
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
// clear correlated flag after completed sub-query (set by lexer)
|
||||
parser.yy.correlatedSubQuery = false;
|
||||
}
|
||||
| '(' ValueExpression ')' -> $2
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'EXISTS' TableSubQuery_EDIT -> { types: [ 'BOOLEAN' ] }
|
||||
| '(' ValueExpression_EDIT RightParenthesisOrError
|
||||
{
|
||||
$$ = $2;
|
||||
}
|
||||
| '(' 'CURSOR' RightParenthesisOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { types: ['T'], typeSet: true };
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ COMPARISON ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression '=' ValueExpression
|
||||
{
|
||||
parser.addColRefToVariableIfExists($1, $3);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression '<' ValueExpression
|
||||
{
|
||||
parser.addColRefToVariableIfExists($1, $3);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression '>' ValueExpression
|
||||
{
|
||||
parser.addColRefToVariableIfExists($1, $3);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'COMPARISON_OPERATOR' ValueExpression
|
||||
{
|
||||
parser.addColRefToVariableIfExists($1, $3);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'CURSOR' '=' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest($3, $2);
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' '<' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest($3, $2);
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' '>' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest($3, $2);
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' 'COMPARISON_OPERATOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest($3, $2);
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression_EDIT '=' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT '<' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT '>' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT 'COMPARISON_OPERATOR' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression '=' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression '<' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ] , typeSet: true, endsWithLessThanOrEqual: true };
|
||||
}
|
||||
| ValueExpression '>' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'COMPARISON_OPERATOR' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, endsWithLessThanOrEqual: $2 === '<=' };
|
||||
}
|
||||
| ValueExpression '=' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
| ValueExpression '<' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
| ValueExpression '>' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
| ValueExpression 'COMPARISON_OPERATOR' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
// ------------------ IN ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression 'NOT' 'IN' '(' TableSubQueryInner ')' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'NOT' 'IN' '(' ValueExpressionList ')' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IN' '(' TableSubQueryInner ')' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IN' '(' ValueExpressionList ')' -> { types: [ 'BOOLEAN' ] }
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: ValueExpression 'NOT' 'IN' ValueExpressionInSecondPart_EDIT
|
||||
{
|
||||
if ($4.inValueEdit) {
|
||||
parser.valueExpressionSuggest($1, $2 + ' ' + $3);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
}
|
||||
if ($4.cursorAtStart) {
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'IN' ValueExpressionInSecondPart_EDIT
|
||||
{
|
||||
if ($3.inValueEdit) {
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
}
|
||||
if ($3.cursorAtStart) {
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression_EDIT 'NOT' 'IN' '(' ValueExpressionList RightParenthesisOrError -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression_EDIT 'NOT' 'IN' '(' TableSubQueryInner RightParenthesisOrError -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression_EDIT 'IN' '(' ValueExpressionList RightParenthesisOrError -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression_EDIT 'IN' '(' TableSubQueryInner RightParenthesisOrError -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
;
|
||||
|
||||
ValueExpressionInSecondPart_EDIT
|
||||
: '(' TableSubQueryInner_EDIT RightParenthesisOrError
|
||||
| '(' ValueExpressionList_EDIT RightParenthesisOrError -> { inValueEdit: true }
|
||||
| '(' AnyCursor RightParenthesisOrError -> { inValueEdit: true, cursorAtStart: true }
|
||||
;
|
||||
|
||||
// ------------------ BETWEEN ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression 'NOT' 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression -> { types: [ 'BOOLEAN' ] }
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: ValueExpression_EDIT 'NOT' 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression
|
||||
{
|
||||
if ($4.types[0] === $6.types[0] && !$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($4.types);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' ValueExpression_EDIT 'BETWEEN_AND' ValueExpression
|
||||
{
|
||||
if ($1.types[0] === $6.types[0] && !$4.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $4.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression_EDIT
|
||||
{
|
||||
if ($1.types[0] === $4.types[0] && !$6.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $6.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' ValueExpression 'BETWEEN_AND' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $5);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($4, ['AND']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2 + ' ' + $3);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression_EDIT 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression
|
||||
{
|
||||
if ($1.types[0] === $3.types[0] && !$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types)
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' ValueExpression_EDIT 'BETWEEN_AND' ValueExpression
|
||||
{
|
||||
if ($1.types[0] === $3.types[0] && !$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types)
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression_EDIT
|
||||
{
|
||||
if ($1.types[0] === $3.types[0] && !$5.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types)
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $5.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' ValueExpression 'BETWEEN_AND' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $4);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($3, ['AND']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ BOOLEAN ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression 'OR' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'BOOLEAN');
|
||||
// verifyType($3, 'BOOLEAN');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'AND' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'BOOLEAN');
|
||||
// verifyType($3, 'BOOLEAN');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'CURSOR' 'OR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, suggestFilters: true };
|
||||
}
|
||||
| ValueExpression_EDIT 'OR' ValueExpression
|
||||
{
|
||||
parser.addColRefIfExists($3);
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression 'OR' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, suggestFilters: true };
|
||||
}
|
||||
| ValueExpression 'OR' ValueExpression_EDIT
|
||||
{
|
||||
parser.addColRefIfExists($1);
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
| 'CURSOR' 'AND' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, suggestFilters: true };
|
||||
}
|
||||
| ValueExpression_EDIT 'AND' ValueExpression
|
||||
{
|
||||
parser.addColRefIfExists($3);
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression 'AND' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, suggestFilters: true };
|
||||
}
|
||||
| ValueExpression 'AND' ValueExpression_EDIT
|
||||
{
|
||||
parser.addColRefIfExists($1);
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ ARITHMETIC ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression '-' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'NUMBER');
|
||||
// verifyType($3, 'NUMBER');
|
||||
$$ = { types: [ 'NUMBER' ] };
|
||||
}
|
||||
| ValueExpression '*' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'NUMBER');
|
||||
// verifyType($3, 'NUMBER');
|
||||
$$ = { types: [ 'NUMBER' ] };
|
||||
}
|
||||
| ValueExpression 'ARITHMETIC_OPERATOR' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'NUMBER');
|
||||
// verifyType($3, 'NUMBER');
|
||||
$$ = { types: [ 'NUMBER' ] };
|
||||
}
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'CURSOR' '*' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions([ 'NUMBER' ]);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' 'ARITHMETIC_OPERATOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions([ 'NUMBER' ]);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression_EDIT '-' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT '*' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT 'ARITHMETIC_OPERATOR' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression '-' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression '*' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'ARITHMETIC_OPERATOR' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression '-' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $3.suggestFilters };
|
||||
}
|
||||
| ValueExpression '*' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $3.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'ARITHMETIC_OPERATOR' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $3.suggestFilters };
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ LIKE, RLIKE and REGEXP ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression LikeRightPart -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'NOT' LikeRightPart -> { types: [ 'BOOLEAN' ] }
|
||||
;
|
||||
|
||||
LikeRightPart
|
||||
: 'LIKE' ValueExpression -> { suggestKeywords: ['NOT'] }
|
||||
| 'RLIKE' ValueExpression -> { suggestKeywords: ['NOT'] }
|
||||
| 'REGEXP' ValueExpression -> { suggestKeywords: ['NOT'] }
|
||||
;
|
||||
|
||||
LikeRightPart_EDIT
|
||||
: 'LIKE' ValueExpression_EDIT
|
||||
| 'RLIKE' ValueExpression_EDIT
|
||||
| 'REGEXP' ValueExpression_EDIT
|
||||
| 'LIKE' PartialBacktickedOrCursor
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'STRING' ] });
|
||||
parser.suggestColumns({ types: [ 'STRING' ] });
|
||||
$$ = { types: ['BOOLEAN'] }
|
||||
}
|
||||
| 'RLIKE' PartialBacktickedOrCursor
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'STRING' ] });
|
||||
parser.suggestColumns({ types: [ 'STRING' ] });
|
||||
$$ = { types: ['BOOLEAN'] }
|
||||
}
|
||||
| 'REGEXP' PartialBacktickedOrCursor
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'STRING' ] });
|
||||
parser.suggestColumns({ types: [ 'STRING' ] });
|
||||
$$ = { types: ['BOOLEAN'] }
|
||||
}
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: ValueExpression_EDIT LikeRightPart -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression_EDIT 'NOT' LikeRightPart -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression LikeRightPart_EDIT -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'NOT' LikeRightPart_EDIT -> { types: [ 'BOOLEAN' ] }
|
||||
| 'CURSOR' LikeRightPart
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions([ 'STRING' ]);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' 'NOT' LikeRightPart
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2 + ' ' + $3);
|
||||
parser.applyTypeToSuggestions([ 'STRING' ]);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ CASE, WHEN, THEN ------------------
|
||||
|
||||
ValueExpression
|
||||
: 'CASE' CaseRightPart -> $2
|
||||
| 'CASE' ValueExpression CaseRightPart -> $3
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'CASE' CaseRightPart_EDIT -> $2
|
||||
| 'CASE' 'CURSOR' EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { types: [ 'T' ], typeSet: true };
|
||||
}
|
||||
| 'CASE' ValueExpression CaseRightPart_EDIT -> $3
|
||||
| 'CASE' ValueExpression 'CURSOR' EndOrError
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($2, ['WHEN']);
|
||||
$$ = { types: [ 'T' ], typeSet: true };
|
||||
}
|
||||
| 'CASE' ValueExpression_EDIT CaseRightPart
|
||||
{
|
||||
$$ = $3;
|
||||
$$.suggestFilters = $2.suggestFilters;
|
||||
}
|
||||
| 'CASE' ValueExpression_EDIT EndOrError -> { types: [ 'T' ], suggestFilters: $2.suggestFilters }
|
||||
| 'CASE' 'CURSOR' CaseRightPart -> { types: [ 'T' ] }
|
||||
;
|
||||
|
||||
CaseRightPart
|
||||
: CaseWhenThenList 'END' -> parser.findCaseType($1)
|
||||
| CaseWhenThenList 'ELSE' ValueExpression 'END'
|
||||
{
|
||||
$1.caseTypes.push($3);
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
;
|
||||
|
||||
CaseRightPart_EDIT
|
||||
: CaseWhenThenList_EDIT EndOrError -> parser.findCaseType($1)
|
||||
| CaseWhenThenList 'ELSE' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($3, ['END']);
|
||||
$1.caseTypes.push($3);
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| CaseWhenThenList_EDIT 'ELSE' ValueExpression EndOrError
|
||||
{
|
||||
$1.caseTypes.push($3);
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| CaseWhenThenList_EDIT 'ELSE' EndOrError -> parser.findCaseType($1)
|
||||
| CaseWhenThenList 'CURSOR' ValueExpression EndOrError
|
||||
{
|
||||
if ($4.toLowerCase() !== 'end') {
|
||||
parser.suggestValueExpressionKeywords($1, [{ value: 'END', weight: 3 }, { value: 'ELSE', weight: 2 }, { value: 'WHEN', weight: 1 }]);
|
||||
} else {
|
||||
parser.suggestValueExpressionKeywords($1, [{ value: 'ELSE', weight: 2 }, { value: 'WHEN', weight: 1 }]);
|
||||
}
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| CaseWhenThenList 'CURSOR' EndOrError
|
||||
{
|
||||
if ($3.toLowerCase() !== 'end') {
|
||||
parser.suggestValueExpressionKeywords($1, [{ value: 'END', weight: 3 }, { value: 'ELSE', weight: 2 }, { value: 'WHEN', weight: 1 }]);
|
||||
} else {
|
||||
parser.suggestValueExpressionKeywords($1, [{ value: 'ELSE', weight: 2 }, { value: 'WHEN', weight: 1 }]);
|
||||
}
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| CaseWhenThenList 'ELSE' ValueExpression_EDIT EndOrError
|
||||
{
|
||||
$1.caseTypes.push($3);
|
||||
$$ = parser.findCaseType($1);
|
||||
$$.suggestFilters = $3.suggestFilters
|
||||
}
|
||||
| CaseWhenThenList 'ELSE' 'CURSOR' EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| 'ELSE' 'CURSOR' EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { types: [ 'T' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' 'ELSE' ValueExpression EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = $3;
|
||||
}
|
||||
| 'CURSOR' 'ELSE' EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { types: [ 'T' ] };
|
||||
}
|
||||
;
|
||||
|
||||
EndOrError
|
||||
: 'END'
|
||||
| error
|
||||
;
|
||||
|
||||
CaseWhenThenList
|
||||
: CaseWhenThenListPartTwo -> { caseTypes: [ $1 ], lastType: $1 }
|
||||
| CaseWhenThenList CaseWhenThenListPartTwo
|
||||
{
|
||||
$1.caseTypes.push($2);
|
||||
$$ = { caseTypes: $1.caseTypes, lastType: $2 };
|
||||
}
|
||||
;
|
||||
|
||||
CaseWhenThenList_EDIT
|
||||
: CaseWhenThenListPartTwo_EDIT
|
||||
| CaseWhenThenList CaseWhenThenListPartTwo_EDIT
|
||||
| CaseWhenThenList CaseWhenThenListPartTwo_EDIT CaseWhenThenList
|
||||
| CaseWhenThenList 'CURSOR' CaseWhenThenList
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($1, ['WHEN']);
|
||||
}
|
||||
| CaseWhenThenListPartTwo_EDIT CaseWhenThenList -> $2
|
||||
;
|
||||
|
||||
CaseWhenThenListPartTwo
|
||||
: 'WHEN' ValueExpression 'THEN' ValueExpression -> $4
|
||||
;
|
||||
|
||||
CaseWhenThenListPartTwo_EDIT
|
||||
: 'WHEN' ValueExpression_EDIT -> { caseTypes: [{ types: ['T'] }], suggestFilters: $2.suggestFilters }
|
||||
| 'WHEN' ValueExpression_EDIT 'THEN' -> { caseTypes: [{ types: ['T'] }], suggestFilters: $2.suggestFilters }
|
||||
| 'WHEN' ValueExpression_EDIT 'THEN' ValueExpression -> { caseTypes: [$4], suggestFilters: $2.suggestFilters }
|
||||
| 'WHEN' ValueExpression 'THEN' ValueExpression_EDIT -> { caseTypes: [$4], suggestFilters: $4.suggestFilters }
|
||||
| 'WHEN' 'THEN' ValueExpression_EDIT -> { caseTypes: [$3], suggestFilters: $3.suggestFilters }
|
||||
| 'CURSOR' ValueExpression 'THEN'
|
||||
{
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'CURSOR' ValueExpression 'THEN' ValueExpression
|
||||
{
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { caseTypes: [$4] };
|
||||
}
|
||||
| 'CURSOR' 'THEN'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'CURSOR' 'THEN' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }], suggestFilters: true };
|
||||
}
|
||||
| 'WHEN' 'CURSOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['THEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }], suggestFilters: true };
|
||||
}
|
||||
| 'WHEN' 'CURSOR' 'THEN'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }], suggestFilters: true };
|
||||
}
|
||||
| 'WHEN' 'CURSOR' 'THEN' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [$4], suggestFilters: true };
|
||||
}
|
||||
| 'WHEN' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($2, ['THEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' ValueExpression 'CURSOR' ValueExpression
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($2, ['THEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' ValueExpression 'THEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' ValueExpression 'THEN' 'CURSOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' 'THEN' 'CURSOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' 'THEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
;
|
19
src/jison/sql/calcite/syntax_footer.jison
Normal file
19
src/jison/sql/calcite/syntax_footer.jison
Normal file
@ -0,0 +1,19 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%%
|
||||
|
||||
SqlParseSupport.initSyntaxParser(parser);
|
28
src/jison/sql/calcite/syntax_header.jison
Normal file
28
src/jison/sql/calcite/syntax_header.jison
Normal file
@ -0,0 +1,28 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%left 'AND' 'OR'
|
||||
%left 'BETWEEN'
|
||||
%left 'NOT' '!' '~'
|
||||
%left '=' '<' '>' 'COMPARISON_OPERATOR'
|
||||
%left '-' '*' 'ARITHMETIC_OPERATOR'
|
||||
|
||||
%left ';' ','
|
||||
%nonassoc 'IN' 'IS' 'LIKE' 'RLIKE' 'REGEXP' 'EXISTS' NEGATION
|
||||
|
||||
%start SqlSyntax
|
||||
|
||||
%%
|
19
src/jison/sql/druid/autocomplete_footer.jison
Normal file
19
src/jison/sql/druid/autocomplete_footer.jison
Normal file
@ -0,0 +1,19 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%%
|
||||
|
||||
SqlParseSupport.initSqlParser(parser);
|
29
src/jison/sql/druid/autocomplete_header.jison
Normal file
29
src/jison/sql/druid/autocomplete_header.jison
Normal file
@ -0,0 +1,29 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%left 'AND' 'OR'
|
||||
%left 'BETWEEN'
|
||||
%left 'NOT' '!' '~'
|
||||
%left '=' '<' '>' 'COMPARISON_OPERATOR'
|
||||
%left '-' '*' 'ARITHMETIC_OPERATOR'
|
||||
|
||||
%left ';' ','
|
||||
%nonassoc 'CURSOR' 'PARTIAL_CURSOR'
|
||||
%nonassoc 'IN' 'IS' 'LIKE' 'RLIKE' 'REGEXP' 'EXISTS' NEGATION
|
||||
|
||||
%start SqlAutocomplete
|
||||
|
||||
%%
|
226
src/jison/sql/druid/sql.jisonlex
Normal file
226
src/jison/sql/druid/sql.jisonlex
Normal file
@ -0,0 +1,226 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%options case-insensitive flex
|
||||
%s between
|
||||
%x hdfs doubleQuotedValue singleQuotedValue backtickedValue
|
||||
%%
|
||||
|
||||
\s { /* skip whitespace */ }
|
||||
'--'.* { /* skip comments */ }
|
||||
[/][*][^*]*[*]+([^/*][^*]*[*]+)*[/] { /* skip comments */ }
|
||||
|
||||
'\u2020' { parser.yy.partialCursor = false; parser.yy.cursorFound = yylloc; return 'CURSOR'; }
|
||||
'\u2021' { parser.yy.partialCursor = true; parser.yy.cursorFound = yylloc; return 'PARTIAL_CURSOR'; }
|
||||
|
||||
<between>'AND' { this.popState(); return 'BETWEEN_AND'; }
|
||||
|
||||
// Reserved Keywords
|
||||
'ALL' { return 'ALL'; }
|
||||
'ALTER' { parser.determineCase(yytext); parser.addStatementTypeLocation('ALTER', yylloc, yy.lexer.upcomingInput()); return 'ALTER'; }
|
||||
'AND' { return 'AND'; }
|
||||
'AS' { return 'AS'; }
|
||||
'ASC' { return 'ASC'; }
|
||||
'BETWEEN' { this.begin('between'); return 'BETWEEN'; }
|
||||
'BIGINT' { return 'BIGINT'; }
|
||||
'BOOLEAN' { return 'BOOLEAN'; }
|
||||
'BY' { return 'BY'; }
|
||||
'CASCADE' { return 'CASCADE'; }
|
||||
'CASE' { return 'CASE'; }
|
||||
'CHAR' { return 'CHAR'; }
|
||||
'COMMENT' { return 'COMMENT'; }
|
||||
'CREATE' { parser.determineCase(yytext); return 'CREATE'; }
|
||||
'CROSS' { return 'CROSS'; }
|
||||
'CURRENT' { return 'CURRENT'; }
|
||||
'DATABASE' { return 'DATABASE'; }
|
||||
'DECIMAL' { return 'DECIMAL'; }
|
||||
'DESC' { return 'DESC'; }
|
||||
'DISTINCT' { return 'DISTINCT'; }
|
||||
'DIV' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'DOUBLE' { return 'DOUBLE'; }
|
||||
'DROP' { parser.determineCase(yytext); parser.addStatementTypeLocation('DROP', yylloc, yy.lexer.upcomingInput()); return 'DROP'; }
|
||||
'ELSE' { return 'ELSE'; }
|
||||
'END' { return 'END'; }
|
||||
'EXISTS' { parser.yy.correlatedSubQuery = true; return 'EXISTS'; }
|
||||
'FALSE' { return 'FALSE'; }
|
||||
'FLOAT' { return 'FLOAT'; }
|
||||
'FOLLOWING' { return 'FOLLOWING'; }
|
||||
'FROM' { parser.determineCase(yytext); return 'FROM'; }
|
||||
'FULL' { return 'FULL'; }
|
||||
'GROUP' { return 'GROUP'; }
|
||||
'HAVING' { return 'HAVING'; }
|
||||
'IF' { return 'IF'; }
|
||||
'IN' { return 'IN'; }
|
||||
'INNER' { return 'INNER'; }
|
||||
'INSERT' { return 'INSERT'; }
|
||||
'INT' { return 'INT'; }
|
||||
'INTO' { return 'INTO'; }
|
||||
'IS' { return 'IS'; }
|
||||
'JOIN' { return 'JOIN'; }
|
||||
'LEFT' { return 'LEFT'; }
|
||||
'LIKE' { return 'LIKE'; }
|
||||
'LIMIT' { return 'LIMIT'; }
|
||||
'NOT' { return 'NOT'; }
|
||||
'NULL' { return 'NULL'; }
|
||||
'ON' { return 'ON'; }
|
||||
'OPTION' { return 'OPTION'; }
|
||||
'OR' { return 'OR'; }
|
||||
'ORDER' { return 'ORDER'; }
|
||||
'OUTER' { return 'OUTER'; }
|
||||
'PARTITION' { return 'PARTITION'; }
|
||||
'PRECEDING' { return 'PRECEDING'; }
|
||||
'PURGE' { return 'PURGE'; }
|
||||
'RANGE' { return 'RANGE'; }
|
||||
'REGEXP' { return 'REGEXP'; }
|
||||
'RIGHT' { return 'RIGHT'; }
|
||||
'RLIKE' { return 'RLIKE'; }
|
||||
'ROW' { return 'ROW'; }
|
||||
'ROLE' { return 'ROLE'; }
|
||||
'ROWS' { return 'ROWS'; }
|
||||
'SCHEMA' { return 'SCHEMA'; }
|
||||
'SELECT' { parser.determineCase(yytext); parser.addStatementTypeLocation('SELECT', yylloc); return 'SELECT'; }
|
||||
'SEMI' { return 'SEMI'; }
|
||||
'SET' { parser.determineCase(yytext); parser.addStatementTypeLocation('SET', yylloc); return 'SET'; }
|
||||
'SHOW' { parser.determineCase(yytext); parser.addStatementTypeLocation('SHOW', yylloc); return 'SHOW'; }
|
||||
'SMALLINT' { return 'SMALLINT'; }
|
||||
'STRING' { return 'STRING'; }
|
||||
'TABLE' { return 'TABLE'; }
|
||||
'THEN' { return 'THEN'; }
|
||||
'TIMESTAMP' { return 'TIMESTAMP'; }
|
||||
'TINYINT' { return 'TINYINT'; }
|
||||
'TO' { return 'TO'; }
|
||||
'TRUE' { return 'TRUE'; }
|
||||
'TRUNCATE' { parser.determineCase(yytext); parser.addStatementTypeLocation('TRUNCATE', yylloc, yy.lexer.upcomingInput()); return 'TRUNCATE'; }
|
||||
'UNBOUNDED' { return 'UNBOUNDED'; }
|
||||
'UNION' { return 'UNION'; }
|
||||
'UPDATE' { parser.determineCase(yytext); return 'UPDATE'; }
|
||||
'USE' { parser.determineCase(yytext); parser.addStatementTypeLocation('USE', yylloc); return 'USE'; }
|
||||
'VALUES' { return 'VALUES'; }
|
||||
'VARCHAR' { return 'VARCHAR'; }
|
||||
'VIEW' { return 'VIEW'; }
|
||||
'WHEN' { return 'WHEN'; }
|
||||
'WHERE' { return 'WHERE'; }
|
||||
'WITH' { parser.determineCase(yytext); parser.addStatementTypeLocation('WITH', yylloc); return 'WITH'; }
|
||||
|
||||
// Non-reserved Keywords
|
||||
'OVER' { return 'OVER'; }
|
||||
'ROLE' { return 'ROLE'; }
|
||||
|
||||
// --- UDFs ---
|
||||
AVG\s*\( { yy.lexer.unput('('); yytext = 'avg'; parser.addFunctionLocation(yylloc, yytext); return 'AVG'; }
|
||||
CAST\s*\( { yy.lexer.unput('('); yytext = 'cast'; parser.addFunctionLocation(yylloc, yytext); return 'CAST'; }
|
||||
COUNT\s*\( { yy.lexer.unput('('); yytext = 'count'; parser.addFunctionLocation(yylloc, yytext); return 'COUNT'; }
|
||||
MAX\s*\( { yy.lexer.unput('('); yytext = 'max'; parser.addFunctionLocation(yylloc, yytext); return 'MAX'; }
|
||||
MIN\s*\( { yy.lexer.unput('('); yytext = 'min'; parser.addFunctionLocation(yylloc, yytext); return 'MIN'; }
|
||||
STDDEV_POP\s*\( { yy.lexer.unput('('); yytext = 'stddev_pop'; parser.addFunctionLocation(yylloc, yytext); return 'STDDEV_POP'; }
|
||||
STDDEV_SAMP\s*\( { yy.lexer.unput('('); yytext = 'stddev_samp'; parser.addFunctionLocation(yylloc, yytext); return 'STDDEV_SAMP'; }
|
||||
SUM\s*\( { yy.lexer.unput('('); yytext = 'sum'; parser.addFunctionLocation(yylloc, yytext); return 'SUM'; }
|
||||
VAR_POP\s*\( { yy.lexer.unput('('); yytext = 'var_pop'; parser.addFunctionLocation(yylloc, yytext); return 'VAR_POP'; }
|
||||
VAR_SAMP\s*\( { yy.lexer.unput('('); yytext = 'var_samp'; parser.addFunctionLocation(yylloc, yytext); return 'VAR_SAMP'; }
|
||||
VARIANCE\s*\( { yy.lexer.unput('('); yytext = 'variance'; parser.addFunctionLocation(yylloc, yytext); return 'VARIANCE'; }
|
||||
|
||||
// Analytical functions
|
||||
CUME_DIST\s*\( { yy.lexer.unput('('); yytext = 'cume_dist'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
DENSE_RANK\s*\( { yy.lexer.unput('('); yytext = 'dense_rank'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
FIRST_VALUE\s*\( { yy.lexer.unput('('); yytext = 'first_value'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
LAG\s*\( { yy.lexer.unput('('); yytext = 'lag'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
LAST_VALUE\s*\( { yy.lexer.unput('('); yytext = 'last_value'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
LEAD\s*\( { yy.lexer.unput('('); yytext = 'lead'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
RANK\s*\( { yy.lexer.unput('('); yytext = 'rank'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
ROW_NUMBER\s*\( { yy.lexer.unput('('); yytext = 'row_number'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
|
||||
[0-9]+ { return 'UNSIGNED_INTEGER'; }
|
||||
[0-9]+(?:[YSL]|BD)? { return 'UNSIGNED_INTEGER'; }
|
||||
[0-9]+E { return 'UNSIGNED_INTEGER_E'; }
|
||||
[A-Za-z0-9_]+ { return 'REGULAR_IDENTIFIER'; }
|
||||
|
||||
<hdfs>'\u2020' { parser.yy.cursorFound = true; return 'CURSOR'; }
|
||||
<hdfs>'\u2021' { parser.yy.cursorFound = true; return 'PARTIAL_CURSOR'; }
|
||||
<hdfs>\s+['"] { return 'HDFS_START_QUOTE'; }
|
||||
<hdfs>[^'"\u2020\u2021]+ { parser.addFileLocation(yylloc, yytext); return 'HDFS_PATH'; }
|
||||
<hdfs>['"] { this.popState(); return 'HDFS_END_QUOTE'; }
|
||||
<hdfs><<EOF>> { return 'EOF'; }
|
||||
|
||||
'&&' { return 'AND'; }
|
||||
'||' { return 'OR'; }
|
||||
|
||||
'=' { return '='; }
|
||||
'<' { return '<'; }
|
||||
'>' { return '>'; }
|
||||
'!=' { return 'COMPARISON_OPERATOR'; }
|
||||
'<=' { return 'COMPARISON_OPERATOR'; }
|
||||
'>=' { return 'COMPARISON_OPERATOR'; }
|
||||
'<>' { return 'COMPARISON_OPERATOR'; }
|
||||
'<=>' { return 'COMPARISON_OPERATOR'; }
|
||||
|
||||
'-' { return '-'; }
|
||||
'*' { return '*'; }
|
||||
'+' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'/' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'%' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'|' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'^' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'&' { return 'ARITHMETIC_OPERATOR'; }
|
||||
|
||||
',' { return ','; }
|
||||
'.' { return '.'; }
|
||||
':' { return ':'; }
|
||||
';' { return ';'; }
|
||||
'~' { return '~'; }
|
||||
'!' { return '!'; }
|
||||
|
||||
'(' { return '('; }
|
||||
')' { return ')'; }
|
||||
'[' { return '['; }
|
||||
']' { return ']'; }
|
||||
|
||||
\$\{[^}]*\} { return 'VARIABLE_REFERENCE'; }
|
||||
|
||||
\` { this.begin('backtickedValue'); return 'BACKTICK'; }
|
||||
<backtickedValue>[^`]+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '`')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<backtickedValue>\` { this.popState(); return 'BACKTICK'; }
|
||||
|
||||
\' { this.begin('singleQuotedValue'); return 'SINGLE_QUOTE'; }
|
||||
<singleQuotedValue>(?:\\\\|\\[']|[^'])+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '\'')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<singleQuotedValue>\' { this.popState(); return 'SINGLE_QUOTE'; }
|
||||
|
||||
\" { this.begin('doubleQuotedValue'); return 'DOUBLE_QUOTE'; }
|
||||
<doubleQuotedValue>(?:\\\\|\\["]|[^"])+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '"')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<doubleQuotedValue>\" { this.popState(); return 'DOUBLE_QUOTE'; }
|
||||
|
||||
<<EOF>> { return 'EOF'; }
|
||||
|
||||
. { /* To prevent console logging of unknown chars */ }
|
||||
<between>. { }
|
||||
<hdfs>. { }
|
||||
<backtickedValue>. { }
|
||||
<singleQuotedValue>. { }
|
||||
<doubleQuotedValue>. { }
|
109
src/jison/sql/druid/sql_alter.jison
Normal file
109
src/jison/sql/druid/sql_alter.jison
Normal file
@ -0,0 +1,109 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: AlterStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: AlterStatement_EDIT
|
||||
;
|
||||
|
||||
AlterStatement
|
||||
: AlterTable
|
||||
| AlterView
|
||||
;
|
||||
|
||||
AlterStatement_EDIT
|
||||
: AlterTable_EDIT
|
||||
| AlterView_EDIT
|
||||
| 'ALTER' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['TABLE', 'VIEW']);
|
||||
}
|
||||
;
|
||||
|
||||
AlterTable
|
||||
: AlterTableLeftSide PartitionSpec
|
||||
;
|
||||
|
||||
AlterTable_EDIT
|
||||
: AlterTableLeftSide_EDIT
|
||||
| AlterTableLeftSide_EDIT PartitionSpec
|
||||
| AlterTableLeftSide 'CURSOR'
|
||||
| AlterTableLeftSide PartitionSpec 'CURSOR'
|
||||
;
|
||||
|
||||
AlterTableLeftSide
|
||||
: 'ALTER' 'TABLE' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
;
|
||||
|
||||
AlterTableLeftSide_EDIT
|
||||
: 'ALTER' 'TABLE' SchemaQualifiedTableIdentifier_EDIT
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyTables = true;
|
||||
}
|
||||
}
|
||||
| 'ALTER' 'TABLE' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables({ onlyTables: true });
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
;
|
||||
|
||||
AlterView
|
||||
: AlterViewLeftSide 'AS' QuerySpecification
|
||||
;
|
||||
|
||||
AlterView_EDIT
|
||||
: AlterViewLeftSide_EDIT
|
||||
| AlterViewLeftSide 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['AS']);
|
||||
}
|
||||
| AlterViewLeftSide 'SET' 'CURSOR'
|
||||
| AlterViewLeftSide 'AS' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
| AlterViewLeftSide 'AS' QuerySpecification_EDIT
|
||||
;
|
||||
|
||||
|
||||
AlterViewLeftSide
|
||||
: 'ALTER' 'VIEW' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
;
|
||||
|
||||
AlterViewLeftSide_EDIT
|
||||
: 'ALTER' 'VIEW' SchemaQualifiedTableIdentifier_EDIT
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyViews = true;
|
||||
}
|
||||
}
|
||||
| 'ALTER' 'VIEW' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables({ onlyViews: true });
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
;
|
615
src/jison/sql/druid/sql_create.jison
Normal file
615
src/jison/sql/druid/sql_create.jison
Normal file
@ -0,0 +1,615 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: CreateStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: CreateStatement_EDIT
|
||||
;
|
||||
|
||||
CreateStatement
|
||||
: DatabaseDefinition
|
||||
| TableDefinition
|
||||
| ViewDefinition
|
||||
| RoleDefinition
|
||||
;
|
||||
|
||||
CreateStatement_EDIT
|
||||
: DatabaseDefinition_EDIT
|
||||
| TableDefinition_EDIT
|
||||
| ViewDefinition_EDIT
|
||||
| 'CREATE' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['DATABASE', 'ROLE', 'SCHEMA', 'TABLE', 'VIEW']);
|
||||
}
|
||||
;
|
||||
|
||||
DatabaseDefinition
|
||||
: 'CREATE' DatabaseOrSchema OptionalIfNotExists
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals
|
||||
{
|
||||
parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
|
||||
}
|
||||
;
|
||||
|
||||
DatabaseDefinition_EDIT
|
||||
: 'CREATE' DatabaseOrSchema OptionalIfNotExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists_EDIT
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists 'CURSOR' RegularIdentifier
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
parser.addNewDatabaseLocation(@5, [{ name: $5 }]);
|
||||
}
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists_EDIT RegularIdentifier
|
||||
{
|
||||
parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
|
||||
}
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals 'CURSOR'
|
||||
{
|
||||
parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
|
||||
}
|
||||
;
|
||||
|
||||
DatabaseDefinitionOptionals
|
||||
: OptionalComment
|
||||
{
|
||||
if (!$1) {
|
||||
parser.suggestKeywords(['COMMENT']);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
DatabaseDefinitionOptionals_EDIT
|
||||
: OptionalComment_INVALID
|
||||
;
|
||||
|
||||
OptionalComment
|
||||
:
|
||||
| Comment
|
||||
;
|
||||
|
||||
Comment
|
||||
: 'COMMENT' QuotedValue
|
||||
;
|
||||
|
||||
OptionalComment_INVALID
|
||||
: Comment_INVALID
|
||||
;
|
||||
|
||||
Comment_INVALID
|
||||
: 'COMMENT' SINGLE_QUOTE
|
||||
| 'COMMENT' DOUBLE_QUOTE
|
||||
| 'COMMENT' SINGLE_QUOTE VALUE
|
||||
| 'COMMENT' DOUBLE_QUOTE VALUE
|
||||
;
|
||||
|
||||
TableDefinition
|
||||
: 'CREATE' 'TABLE' OptionalIfNotExists TableDefinitionRightPart
|
||||
;
|
||||
|
||||
TableDefinition_EDIT
|
||||
: 'CREATE' 'TABLE' OptionalIfNotExists TableDefinitionRightPart_EDIT
|
||||
| 'CREATE' 'TABLE' OptionalIfNotExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'CREATE' 'TABLE' OptionalIfNotExists_EDIT
|
||||
;
|
||||
|
||||
TableDefinitionRightPart
|
||||
: TableIdentifierAndOptionalColumnSpecification OptionalPartitionedBy OptionalAsSelectStatement
|
||||
;
|
||||
|
||||
TableDefinitionRightPart_EDIT
|
||||
: TableIdentifierAndOptionalColumnSpecification_EDIT OptionalPartitionedBy OptionalAsSelectStatement
|
||||
| TableIdentifierAndOptionalColumnSpecification PartitionedBy_EDIT OptionalAsSelectStatement
|
||||
| TableIdentifierAndOptionalColumnSpecification OptionalPartitionedBy OptionalAsSelectStatement_EDIT
|
||||
| TableIdentifierAndOptionalColumnSpecification OptionalPartitionedBy 'CURSOR'
|
||||
{
|
||||
var keywords = [];
|
||||
if (!$1 && !$2) {
|
||||
keywords.push({ value: 'LIKE', weight: 1 });
|
||||
} else {
|
||||
if (!$2) {
|
||||
keywords.push({ value: 'PARTITIONED BY', weight: 12 });
|
||||
}
|
||||
keywords.push({ value: 'AS', weight: 1 });
|
||||
}
|
||||
|
||||
if (keywords.length > 0) {
|
||||
parser.suggestKeywords(keywords);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
TableIdentifierAndOptionalColumnSpecification
|
||||
: SchemaQualifiedIdentifier OptionalColumnSpecificationsOrLike
|
||||
{
|
||||
parser.addNewTableLocation(@1, $1, $2);
|
||||
$$ = $2;
|
||||
}
|
||||
;
|
||||
|
||||
TableIdentifierAndOptionalColumnSpecification_EDIT
|
||||
: SchemaQualifiedIdentifier OptionalColumnSpecificationsOrLike_EDIT
|
||||
| SchemaQualifiedIdentifier_EDIT OptionalColumnSpecificationsOrLike
|
||||
;
|
||||
|
||||
OptionalColumnSpecificationsOrLike
|
||||
:
|
||||
| ParenthesizedColumnSpecificationList
|
||||
| 'LIKE' SchemaQualifiedTableIdentifier -> []
|
||||
;
|
||||
|
||||
OptionalColumnSpecificationsOrLike_EDIT
|
||||
: ParenthesizedColumnSpecificationList_EDIT
|
||||
| 'LIKE' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'LIKE' SchemaQualifiedTableIdentifier_EDIT
|
||||
;
|
||||
|
||||
ParenthesizedColumnSpecificationList
|
||||
: '(' ColumnSpecificationList ')' -> $2
|
||||
;
|
||||
|
||||
ParenthesizedColumnSpecificationList_EDIT
|
||||
: '(' ColumnSpecificationList_EDIT RightParenthesisOrError
|
||||
;
|
||||
|
||||
ColumnSpecificationList
|
||||
: ColumnSpecification -> [$1]
|
||||
| ColumnSpecificationList ',' ColumnSpecification -> $1.concat($3)
|
||||
;
|
||||
|
||||
ColumnSpecificationList_EDIT
|
||||
: ColumnSpecification_EDIT
|
||||
| ColumnSpecification_EDIT ',' ColumnSpecificationList
|
||||
| ColumnSpecificationList ',' ColumnSpecification_EDIT
|
||||
| ColumnSpecificationList ',' ColumnSpecification_EDIT ',' ColumnSpecificationList
|
||||
| ColumnSpecification 'CURSOR'
|
||||
{
|
||||
parser.checkForKeywords($1);
|
||||
}
|
||||
| ColumnSpecification 'CURSOR' ',' ColumnSpecificationList
|
||||
{
|
||||
parser.checkForKeywords($1);
|
||||
}
|
||||
| ColumnSpecificationList ',' ColumnSpecification 'CURSOR'
|
||||
{
|
||||
parser.checkForKeywords($3);
|
||||
}
|
||||
| ColumnSpecificationList ',' ColumnSpecification 'CURSOR' ',' ColumnSpecificationList
|
||||
{
|
||||
parser.checkForKeywords($3);
|
||||
}
|
||||
;
|
||||
|
||||
ColumnSpecification
|
||||
: ColumnIdentifier ColumnDataType OptionalColumnOptions
|
||||
{
|
||||
$$ = $1;
|
||||
$$.type = $2;
|
||||
var keywords = [];
|
||||
if (!$3['comment']) {
|
||||
keywords.push('COMMENT');
|
||||
}
|
||||
if (keywords.length > 0) {
|
||||
$$.suggestKeywords = keywords;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
ColumnSpecification_EDIT
|
||||
: ColumnIdentifier 'CURSOR' OptionalColumnOptions
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| ColumnIdentifier ColumnDataType_EDIT OptionalColumnOptions
|
||||
| ColumnIdentifier ColumnDataType ColumnOptions_EDIT
|
||||
;
|
||||
|
||||
OptionalColumnOptions
|
||||
: -> {}
|
||||
| ColumnOptions
|
||||
;
|
||||
|
||||
ColumnOptions
|
||||
: ColumnOption
|
||||
{
|
||||
$$ = {};
|
||||
$$[$1] = true;
|
||||
}
|
||||
| ColumnOptions ColumnOption
|
||||
{
|
||||
$1[$2] = true;
|
||||
}
|
||||
;
|
||||
|
||||
ColumnOptions_EDIT
|
||||
: ColumnOption_EDIT
|
||||
| ColumnOption_EDIT ColumnOptions
|
||||
| ColumnOptions ColumnOption_EDIT
|
||||
| ColumnOptions ColumnOption_EDIT ColumnOptions
|
||||
;
|
||||
|
||||
ColumnOption
|
||||
: 'NOT' 'NULL' -> 'null'
|
||||
| 'NULL' -> 'null'
|
||||
| Comment -> 'comment'
|
||||
;
|
||||
|
||||
ColumnOption_EDIT
|
||||
: 'NOT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['NULL']);
|
||||
}
|
||||
;
|
||||
|
||||
ColumnDataType
|
||||
: PrimitiveType
|
||||
| ArrayType
|
||||
| MapType
|
||||
| StructType
|
||||
| ArrayType_INVALID
|
||||
| MapType_INVALID
|
||||
| StructType_INVALID
|
||||
;
|
||||
|
||||
ColumnDataType_EDIT
|
||||
: ArrayType_EDIT
|
||||
| MapType_EDIT
|
||||
| StructType_EDIT
|
||||
;
|
||||
|
||||
ArrayType
|
||||
: 'ARRAY' '<' ColumnDataType '>'
|
||||
;
|
||||
|
||||
ArrayType_INVALID
|
||||
: 'ARRAY' '<' '>'
|
||||
;
|
||||
|
||||
ArrayType_EDIT
|
||||
: 'ARRAY' '<' AnyCursor GreaterThanOrError
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| 'ARRAY' '<' ColumnDataType_EDIT GreaterThanOrError
|
||||
;
|
||||
|
||||
MapType
|
||||
: 'MAP' '<' PrimitiveType ',' ColumnDataType '>'
|
||||
;
|
||||
|
||||
MapType_INVALID
|
||||
: 'MAP' '<' '>'
|
||||
;
|
||||
|
||||
MapType_EDIT
|
||||
: 'MAP' '<' PrimitiveType ',' ColumnDataType_EDIT GreaterThanOrError
|
||||
| 'MAP' '<' AnyCursor GreaterThanOrError
|
||||
{
|
||||
parser.suggestKeywords(parser.getTypeKeywords());
|
||||
}
|
||||
| 'MAP' '<' PrimitiveType ',' AnyCursor GreaterThanOrError
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| 'MAP' '<' ',' AnyCursor GreaterThanOrError
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
;
|
||||
|
||||
StructType
|
||||
: 'STRUCT' '<' StructDefinitionList '>'
|
||||
;
|
||||
|
||||
StructType_INVALID
|
||||
: 'STRUCT' '<' '>'
|
||||
;
|
||||
|
||||
StructType_EDIT
|
||||
: 'STRUCT' '<' StructDefinitionList_EDIT GreaterThanOrError
|
||||
;
|
||||
|
||||
StructDefinitionList
|
||||
: StructDefinition
|
||||
| StructDefinitionList ',' StructDefinition
|
||||
;
|
||||
|
||||
StructDefinitionList_EDIT
|
||||
: StructDefinition_EDIT
|
||||
| StructDefinition_EDIT Commas
|
||||
| StructDefinition_EDIT Commas StructDefinitionList
|
||||
| StructDefinitionList ',' StructDefinition_EDIT
|
||||
| StructDefinitionList ',' StructDefinition_EDIT Commas StructDefinitionList
|
||||
;
|
||||
|
||||
StructDefinition
|
||||
: RegularOrBacktickedIdentifier ':' ColumnDataType OptionalComment
|
||||
;
|
||||
|
||||
StructDefinition_EDIT
|
||||
: Commas RegularOrBacktickedIdentifier ':' ColumnDataType 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['COMMENT']);
|
||||
}
|
||||
| Commas RegularOrBacktickedIdentifier ':' AnyCursor
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| Commas RegularOrBacktickedIdentifier ':' ColumnDataType_EDIT
|
||||
| RegularOrBacktickedIdentifier ':' ColumnDataType 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['COMMENT']);
|
||||
}
|
||||
| RegularOrBacktickedIdentifier ':' AnyCursor
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| RegularOrBacktickedIdentifier ':' ColumnDataType_EDIT
|
||||
;
|
||||
|
||||
ColumnDataTypeList
|
||||
: ColumnDataType
|
||||
| ColumnDataTypeList ',' ColumnDataType
|
||||
;
|
||||
|
||||
ColumnDataTypeList_EDIT
|
||||
: ColumnDataTypeListInner_EDIT
|
||||
| ColumnDataTypeListInner_EDIT Commas
|
||||
| ColumnDataTypeList ',' ColumnDataTypeListInner_EDIT
|
||||
| ColumnDataTypeListInner_EDIT Commas ColumnDataTypeList
|
||||
| ColumnDataTypeList ',' ColumnDataTypeListInner_EDIT Commas ColumnDataTypeList
|
||||
;
|
||||
|
||||
ColumnDataTypeListInner_EDIT
|
||||
: Commas AnyCursor
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| Commas ColumnDataType_EDIT
|
||||
| AnyCursor
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| ColumnDataType_EDIT
|
||||
;
|
||||
|
||||
GreaterThanOrError
|
||||
: '>'
|
||||
| error
|
||||
;
|
||||
|
||||
OptionalPartitionedBy
|
||||
:
|
||||
| PartitionedBy
|
||||
;
|
||||
|
||||
PartitionedBy
|
||||
: 'PARTITION' 'BY' RangeClause
|
||||
;
|
||||
|
||||
PartitionedBy_EDIT
|
||||
: 'PARTITION' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['BY']);
|
||||
}
|
||||
| 'PARTITION' 'BY' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['RANGE']);
|
||||
}
|
||||
| 'PARTITION' 'BY' RangeClause_EDIT
|
||||
;
|
||||
|
||||
RangeClause
|
||||
: 'RANGE' ParenthesizedColumnList ParenthesizedPartitionValuesList
|
||||
;
|
||||
|
||||
RangeClause_EDIT
|
||||
: 'RANGE' 'CURSOR'
|
||||
| 'RANGE' ParenthesizedColumnList_EDIT
|
||||
| 'RANGE' ParenthesizedColumnList 'CURSOR'
|
||||
| 'RANGE' ParenthesizedColumnList ParenthesizedPartitionValuesList_EDIT
|
||||
| 'RANGE' ParenthesizedColumnList_EDIT ParenthesizedPartitionValuesList
|
||||
;
|
||||
|
||||
ParenthesizedPartitionValuesList
|
||||
: '(' PartitionValueList ')'
|
||||
;
|
||||
|
||||
ParenthesizedPartitionValuesList_EDIT
|
||||
: '(' 'CURSOR' RightParenthesisOrError
|
||||
{
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
|'(' PartitionValueList_EDIT RightParenthesisOrError
|
||||
;
|
||||
|
||||
PartitionValueList
|
||||
: PartitionValue
|
||||
| PartitionValueList ',' PartitionValue
|
||||
;
|
||||
|
||||
PartitionValueList_EDIT
|
||||
: PartitionValue_EDIT
|
||||
| PartitionValueList ',' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
| PartitionValueList ',' 'CURSOR' ',' PartitionValueList
|
||||
{
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
| PartitionValueList ',' PartitionValue_EDIT
|
||||
| PartitionValueList ',' PartitionValue_EDIT ',' PartitionValueList
|
||||
;
|
||||
|
||||
PartitionValue
|
||||
: 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' LessThanOrEqualTo ValueExpression
|
||||
| 'PARTITION' 'VALUES' LessThanOrEqualTo ValueExpression
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES'
|
||||
;
|
||||
|
||||
PartitionValue_EDIT
|
||||
: 'PARTITION' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['VALUE', 'VALUES']);
|
||||
}
|
||||
| 'PARTITION' ValueExpression_EDIT
|
||||
{
|
||||
if ($2.endsWithLessThanOrEqual) {
|
||||
parser.suggestKeywords(['VALUES']);
|
||||
}
|
||||
}
|
||||
| 'PARTITION' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['<', '<=']);
|
||||
}
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['VALUES']);
|
||||
}
|
||||
| 'PARTITION' ValueExpression_EDIT LessThanOrEqualTo 'VALUES'
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['<', '<=']);
|
||||
}
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' LessThanOrEqualTo 'CURSOR'
|
||||
{
|
||||
parser.suggestFunctions();
|
||||
}
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' LessThanOrEqualTo ValueExpression_EDIT
|
||||
| 'PARTITION' 'VALUES' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['<', '<=']);
|
||||
}
|
||||
| 'PARTITION' 'VALUES' LessThanOrEqualTo 'CURSOR'
|
||||
{
|
||||
parser.suggestFunctions();
|
||||
}
|
||||
| 'PARTITION' 'VALUES' LessThanOrEqualTo ValueExpression_EDIT
|
||||
;
|
||||
|
||||
LessThanOrEqualTo
|
||||
: '<'
|
||||
| 'COMPARISON_OPERATOR' // This is fine for autocompletion
|
||||
;
|
||||
|
||||
OptionalAsSelectStatement
|
||||
:
|
||||
| 'AS' CommitLocations QuerySpecification
|
||||
;
|
||||
|
||||
OptionalAsSelectStatement_EDIT
|
||||
: 'AS' CommitLocations 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
| 'AS' CommitLocations QuerySpecification_EDIT
|
||||
;
|
||||
|
||||
CommitLocations
|
||||
: /* empty */
|
||||
{
|
||||
parser.commitLocations();
|
||||
}
|
||||
;
|
||||
|
||||
ViewDefinition
|
||||
: 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'AS' QuerySpecification
|
||||
;
|
||||
|
||||
ViewDefinition_EDIT
|
||||
: 'CREATE' 'VIEW' OptionalIfNotExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists 'CURSOR' SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'AS' QuerySpecification
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists_EDIT
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedViewColumnList_EDIT OptionalComment
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'CURSOR'
|
||||
{
|
||||
var keywords = [{value: 'AS', weight: 1 }];
|
||||
if (!$6) {
|
||||
keywords.push({ value: 'COMMENT', weight: 3 });
|
||||
}
|
||||
parser.suggestKeywords(keywords);
|
||||
}
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'AS' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'AS' QuerySpecification_EDIT
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier_EDIT OptionalParenthesizedViewColumnList OptionalComment 'AS' QuerySpecification
|
||||
;
|
||||
|
||||
OptionalParenthesizedViewColumnList
|
||||
:
|
||||
| ParenthesizedViewColumnList
|
||||
;
|
||||
|
||||
ParenthesizedViewColumnList
|
||||
: '(' ViewColumnList ')'
|
||||
;
|
||||
|
||||
ParenthesizedViewColumnList_EDIT
|
||||
: '(' ViewColumnList_EDIT RightParenthesisOrError
|
||||
{
|
||||
if (!$2) {
|
||||
parser.suggestKeywords(['COMMENT']);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
ViewColumnList
|
||||
: ColumnReference OptionalComment
|
||||
| ViewColumnList ',' ColumnReference OptionalComment
|
||||
;
|
||||
|
||||
ViewColumnList_EDIT
|
||||
: ColumnReference OptionalComment 'CURSOR' -> $2
|
||||
| ColumnReference OptionalComment 'CURSOR' ',' ViewColumnList -> $2
|
||||
| ViewColumnList ',' ColumnReference OptionalComment 'CURSOR' -> $4
|
||||
| ViewColumnList ',' ColumnReference OptionalComment 'CURSOR' ',' ViewColumnList -> $4
|
||||
;
|
||||
|
||||
RoleDefinition
|
||||
: 'CREATE' 'ROLE' RegularIdentifier
|
||||
;
|
184
src/jison/sql/druid/sql_drop.jison
Normal file
184
src/jison/sql/druid/sql_drop.jison
Normal file
@ -0,0 +1,184 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: DropStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: DropStatement_EDIT
|
||||
;
|
||||
|
||||
DropStatement
|
||||
: DropDatabaseStatement
|
||||
| DropRoleStatement
|
||||
| DropTableStatement
|
||||
| DropViewStatement
|
||||
| TruncateTableStatement
|
||||
;
|
||||
|
||||
DropStatement_EDIT
|
||||
: DropDatabaseStatement_EDIT
|
||||
| DropTableStatement_EDIT
|
||||
| DropViewStatement_EDIT
|
||||
| TruncateTableStatement_EDIT
|
||||
| 'DROP' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['DATABASE', 'ROLE', 'SCHEMA', 'TABLE', 'VIEW']);
|
||||
}
|
||||
;
|
||||
|
||||
DropDatabaseStatement
|
||||
: 'DROP' DatabaseOrSchema OptionalIfExists RegularOrBacktickedIdentifier OptionalCascade
|
||||
;
|
||||
|
||||
DropDatabaseStatement_EDIT
|
||||
: 'DROP' DatabaseOrSchema OptionalIfExists
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists_EDIT
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
parser.suggestDatabases();
|
||||
}
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists RegularOrBacktickedIdentifier 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['CASCADE']);
|
||||
}
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists_EDIT RegularOrBacktickedIdentifier OptionalCascade
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists 'CURSOR' RegularOrBacktickedIdentifier OptionalCascade
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
;
|
||||
DropRoleStatement
|
||||
: 'DROP' 'ROLE' RegularIdentifier
|
||||
;
|
||||
|
||||
DropTableStatement
|
||||
: 'DROP' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier OptionalPurge
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
DropTableStatement_EDIT
|
||||
: 'DROP' 'TABLE' OptionalIfExists_EDIT
|
||||
| 'DROP' 'TABLE' OptionalIfExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
parser.suggestTables({ onlyTables: true });
|
||||
parser.suggestDatabases({
|
||||
appendDot: true
|
||||
});
|
||||
}
|
||||
| 'DROP' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier_EDIT OptionalPurge
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyTables = true;
|
||||
}
|
||||
}
|
||||
| 'DROP' 'TABLE' OptionalIfExists_EDIT SchemaQualifiedTableIdentifier OptionalPurge
|
||||
| 'DROP' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier OptionalPurge 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
if (!$5) {
|
||||
parser.suggestKeywords(['PURGE']);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
OptionalPurge
|
||||
:
|
||||
| 'PURGE'
|
||||
;
|
||||
|
||||
DropViewStatement
|
||||
: 'DROP' 'VIEW' OptionalIfExists SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
DropViewStatement_EDIT
|
||||
: 'DROP' 'VIEW' OptionalIfExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
parser.suggestTables({ onlyViews: true });
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'DROP' 'VIEW' OptionalIfExists 'CURSOR' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($5);
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'DROP' 'VIEW' OptionalIfExists_EDIT
|
||||
| 'DROP' 'VIEW' OptionalIfExists_EDIT SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
| 'DROP' 'VIEW' OptionalIfExists SchemaQualifiedTableIdentifier_EDIT
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyViews = true;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
TruncateTableStatement
|
||||
: 'TRUNCATE' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
TruncateTableStatement_EDIT
|
||||
: 'TRUNCATE' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['TABLE']);
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists_EDIT
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier_EDIT
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists 'CURSOR' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists_EDIT SchemaQualifiedTableIdentifier OptionalPartitionSpec
|
||||
;
|
132
src/jison/sql/druid/sql_error.jison
Normal file
132
src/jison/sql/druid/sql_error.jison
Normal file
@ -0,0 +1,132 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
SqlStatements
|
||||
: error
|
||||
| NonStartingToken error // Having just ': error' does not work for some reason, jison bug?
|
||||
;
|
||||
|
||||
SqlStatement_EDIT
|
||||
: AnyCursor error
|
||||
{
|
||||
parser.suggestDdlAndDmlKeywords();
|
||||
}
|
||||
;
|
||||
|
||||
SelectStatement
|
||||
: 'SELECT' OptionalAllOrDistinct SelectList_ERROR TableExpression
|
||||
| 'SELECT' OptionalAllOrDistinct SelectList TableExpression_ERROR
|
||||
;
|
||||
|
||||
SelectStatement_EDIT
|
||||
: 'SELECT' OptionalAllOrDistinct SelectList_ERROR_EDIT TableExpression
|
||||
{
|
||||
parser.selectListNoTableSuggest($3, $2);
|
||||
}
|
||||
| 'SELECT' OptionalAllOrDistinct SelectList_ERROR TableExpression_EDIT
|
||||
;
|
||||
|
||||
SelectList_ERROR
|
||||
: ErrorList
|
||||
| SelectList ',' ErrorList
|
||||
| ErrorList ',' SelectList ',' ErrorList
|
||||
| ErrorList ',' SelectList
|
||||
| SelectList ',' ErrorList ',' SelectList
|
||||
;
|
||||
|
||||
SelectList_ERROR_EDIT
|
||||
: ErrorList ',' SelectList_EDIT -> $3
|
||||
| SelectList ',' ErrorList ',' SelectList_EDIT -> $5
|
||||
| ErrorList ',' SelectList ',' ErrorList ',' SelectList_EDIT -> $7
|
||||
| ErrorList ',' AnyCursor
|
||||
{
|
||||
$$ = { cursorAtStart : false, suggestFunctions: true, suggestColumns: true, suggestAggregateFunctions: true };
|
||||
}
|
||||
| SelectList ',' ErrorList ',' AnyCursor
|
||||
{
|
||||
$$ = { cursorAtStart : false, suggestFunctions: true, suggestColumns: true, suggestAggregateFunctions: true };
|
||||
}
|
||||
| ErrorList ',' SelectList ',' Errors ',' AnyCursor
|
||||
{
|
||||
$$ = { cursorAtStart : true, suggestFunctions: true, suggestColumns: true, suggestAggregateFunctions: true };
|
||||
}
|
||||
;
|
||||
|
||||
SetSpecification
|
||||
: 'SET' SetOption '=' error
|
||||
;
|
||||
|
||||
ErrorList
|
||||
: error
|
||||
| Errors ',' error
|
||||
;
|
||||
|
||||
JoinType_EDIT
|
||||
: 'FULL' 'CURSOR' error
|
||||
{
|
||||
parser.suggestKeywords(['JOIN', 'OUTER JOIN']);
|
||||
}
|
||||
| 'LEFT' 'CURSOR' error
|
||||
{
|
||||
parser.suggestKeywords(['JOIN', 'OUTER JOIN']);
|
||||
}
|
||||
| 'RIGHT' 'CURSOR' error
|
||||
{
|
||||
parser.suggestKeywords(['JOIN', 'OUTER JOIN']);
|
||||
}
|
||||
;
|
||||
|
||||
OptionalSelectConditions_EDIT
|
||||
: WhereClause error 'CURSOR' OptionalGroupByClause OptionalHavingClause OptionalOrderByClause OptionalLimitClause
|
||||
{
|
||||
$$ = {
|
||||
suggestKeywords: parser.getKeywordsForOptionalsLR([$4, $5, $6, $7], [{ value: 'GROUP BY', weight: 8 }, { value: 'HAVING', weight: 7 }, { value: 'ORDER BY', weight: 5 }, { value: 'LIMIT', weight: 3 }], [true, true, true, true]),
|
||||
cursorAtEnd: !$4 && !$5 && !$6 && !$7
|
||||
};
|
||||
}
|
||||
| OptionalWhereClause OptionalGroupByClause HavingClause error 'CURSOR' OptionalOrderByClause OptionalLimitClause
|
||||
{
|
||||
$$ = {
|
||||
suggestKeywords: parser.getKeywordsForOptionalsLR([$6, $7], [{ value: 'ORDER BY', weight: 5 }, { value: 'LIMIT', weight: 3 }], [true, true]),
|
||||
cursorAtEnd: !$6 && !$7
|
||||
}
|
||||
}
|
||||
| OptionalWhereClause OptionalGroupByClause OptionalHavingClause OrderByClause error 'CURSOR' OptionalLimitClause
|
||||
{
|
||||
$$ = {
|
||||
suggestKeywords: parser.getKeywordsForOptionalsLR([$7], [{ value: 'LIMIT', weight: 3 }], [true]),
|
||||
cursorAtEnd: !$7
|
||||
}
|
||||
}
|
||||
| OptionalWhereClause OptionalGroupByClause OptionalHavingClause OptionalOrderByClause LimitClause error 'CURSOR'
|
||||
;
|
||||
|
||||
OptionalSelectConditions_EDIT
|
||||
: WhereClause error GroupByClause_EDIT OptionalHavingClause OptionalOrderByClause OptionalLimitClause
|
||||
| WhereClause error OptionalGroupByClause HavingClause_EDIT OptionalOrderByClause OptionalLimitClause
|
||||
| WhereClause error OptionalGroupByClause OptionalHavingClause OrderByClause_EDIT OptionalLimitClause
|
||||
| WhereClause error OptionalGroupByClause OptionalHavingClause OptionalOrderByClause LimitClause_EDIT
|
||||
| OptionalWhereClause GroupByClause error HavingClause_EDIT OptionalOrderByClause OptionalLimitClause
|
||||
| OptionalWhereClause GroupByClause error OptionalHavingClause OrderByClause_EDIT OptionalLimitClause
|
||||
| OptionalWhereClause GroupByClause error OptionalHavingClause OptionalOrderByClause LimitClause_EDIT
|
||||
| OptionalWhereClause OptionalGroupByClause HavingClause error OrderByClause_EDIT OptionalLimitClause
|
||||
| OptionalWhereClause OptionalGroupByClause HavingClause error OptionalOrderByClause LimitClause_EDIT
|
||||
| OptionalWhereClause OptionalGroupByClause OptionalHavingClause OrderByClause error LimitClause_EDIT
|
||||
;
|
||||
|
||||
DatabaseDefinition_EDIT
|
||||
: 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals_EDIT error
|
||||
;
|
72
src/jison/sql/druid/sql_insert.jison
Normal file
72
src/jison/sql/druid/sql_insert.jison
Normal file
@ -0,0 +1,72 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataManipulation
|
||||
: InsertStatement
|
||||
;
|
||||
|
||||
InsertStatement
|
||||
: InsertValuesStatement
|
||||
;
|
||||
|
||||
DataManipulation_EDIT
|
||||
: InsertValuesStatement_EDIT
|
||||
;
|
||||
|
||||
InsertValuesStatement
|
||||
: 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier 'VALUES' InsertValuesList
|
||||
{
|
||||
$4.owner = 'insert';
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
InsertValuesStatement_EDIT
|
||||
: 'INSERT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['INTO']);
|
||||
}
|
||||
| 'INSERT' 'INTO' OptionalTable 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['TABLE']);
|
||||
}
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier_EDIT
|
||||
| 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier 'CURSOR'
|
||||
{
|
||||
$4.owner = 'insert';
|
||||
parser.addTablePrimary($4);
|
||||
parser.suggestKeywords(['VALUES']);
|
||||
}
|
||||
| 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier_EDIT 'VALUES' InsertValuesList
|
||||
;
|
||||
|
||||
InsertValuesList
|
||||
: ParenthesizedRowValuesList
|
||||
| RowValuesList ',' ParenthesizedRowValuesList
|
||||
;
|
||||
|
||||
ParenthesizedRowValuesList
|
||||
: '(' InValueList ')'
|
||||
;
|
||||
|
||||
OptionalTable
|
||||
:
|
||||
| 'TABLE'
|
||||
;
|
2762
src/jison/sql/druid/sql_main.jison
Normal file
2762
src/jison/sql/druid/sql_main.jison
Normal file
File diff suppressed because it is too large
Load Diff
46
src/jison/sql/druid/sql_set.jison
Normal file
46
src/jison/sql/druid/sql_set.jison
Normal file
@ -0,0 +1,46 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: SetSpecification
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: 'SET' 'CURSOR'
|
||||
{
|
||||
parser.suggestSetOptions();
|
||||
}
|
||||
;
|
||||
|
||||
SetSpecification
|
||||
: 'SET' SetOption '=' SetValue
|
||||
| 'SET' 'ALL'
|
||||
;
|
||||
|
||||
SetOption
|
||||
: RegularIdentifier
|
||||
| SetOption '.' RegularIdentifier
|
||||
;
|
||||
|
||||
SetValue
|
||||
: RegularIdentifier
|
||||
| SignedInteger
|
||||
| SignedInteger RegularIdentifier
|
||||
| QuotedValue
|
||||
| 'TRUE'
|
||||
| 'FALSE'
|
||||
| 'NULL'
|
||||
;
|
122
src/jison/sql/druid/sql_update.jison
Normal file
122
src/jison/sql/druid/sql_update.jison
Normal file
@ -0,0 +1,122 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataManipulation
|
||||
: UpdateStatement
|
||||
;
|
||||
|
||||
DataManipulation_EDIT
|
||||
: UpdateStatement_EDIT
|
||||
;
|
||||
|
||||
UpdateStatement
|
||||
: 'UPDATE' TargetTable 'SET' SetClauseList OptionalFromJoinedTable OptionalWhereClause
|
||||
;
|
||||
|
||||
UpdateStatement_EDIT
|
||||
: 'UPDATE' TargetTable_EDIT 'SET' SetClauseList OptionalFromJoinedTable OptionalWhereClause
|
||||
| 'UPDATE' TargetTable 'SET' SetClauseList_EDIT OptionalFromJoinedTable OptionalWhereClause
|
||||
| 'UPDATE' TargetTable 'SET' SetClauseList FromJoinedTable_EDIT OptionalWhereClause
|
||||
| 'UPDATE' TargetTable 'SET' SetClauseList OptionalFromJoinedTable WhereClause_EDIT
|
||||
| 'UPDATE' TargetTable 'SET' SetClauseList OptionalFromJoinedTable OptionalWhereClause 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords([ 'WHERE' ]);
|
||||
}
|
||||
| 'UPDATE' TargetTable 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords([ 'SET' ]);
|
||||
}
|
||||
| 'UPDATE' TargetTable_EDIT
|
||||
| 'UPDATE' TargetTable
|
||||
| 'UPDATE' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
;
|
||||
|
||||
TargetTable
|
||||
: TableName
|
||||
;
|
||||
|
||||
TargetTable_EDIT
|
||||
: TableName_EDIT
|
||||
;
|
||||
|
||||
TableName
|
||||
: LocalOrSchemaQualifiedName
|
||||
{
|
||||
parser.addTablePrimary($1);
|
||||
}
|
||||
;
|
||||
|
||||
TableName_EDIT
|
||||
: LocalOrSchemaQualifiedName_EDIT
|
||||
;
|
||||
|
||||
SetClauseList
|
||||
: SetClause
|
||||
| SetClauseList ',' SetClause
|
||||
;
|
||||
|
||||
SetClauseList_EDIT
|
||||
: SetClause_EDIT
|
||||
| SetClauseList ',' SetClause_EDIT
|
||||
| SetClause_EDIT ',' SetClauseList
|
||||
| SetClauseList ',' SetClause_EDIT ',' SetClauseList
|
||||
;
|
||||
|
||||
SetClause
|
||||
: SetTarget '=' UpdateSource
|
||||
;
|
||||
|
||||
SetClause_EDIT
|
||||
: SetTarget '=' UpdateSource_EDIT
|
||||
| SetTarget 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords([ '=' ]);
|
||||
}
|
||||
| 'CURSOR'
|
||||
{
|
||||
parser.suggestColumns();
|
||||
}
|
||||
;
|
||||
|
||||
SetTarget
|
||||
: ColumnReference
|
||||
;
|
||||
|
||||
UpdateSource
|
||||
: ValueExpression
|
||||
;
|
||||
|
||||
UpdateSource_EDIT
|
||||
: ValueExpression_EDIT
|
||||
;
|
||||
|
||||
OptionalFromJoinedTable
|
||||
:
|
||||
| 'FROM' TableReference -> $2
|
||||
;
|
||||
|
||||
FromJoinedTable_EDIT
|
||||
: 'FROM' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'FROM' TableReference_EDIT
|
||||
;
|
39
src/jison/sql/druid/sql_use.jison
Normal file
39
src/jison/sql/druid/sql_use.jison
Normal file
@ -0,0 +1,39 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: UseStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: UseStatement_EDIT
|
||||
;
|
||||
|
||||
UseStatement
|
||||
: 'USE' RegularIdentifier
|
||||
{
|
||||
if (! parser.yy.cursorFound) {
|
||||
parser.yy.result.useDatabase = $2;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
UseStatement_EDIT
|
||||
: 'USE' 'CURSOR'
|
||||
{
|
||||
parser.suggestDatabases();
|
||||
}
|
||||
;
|
839
src/jison/sql/druid/sql_valueExpression.jison
Normal file
839
src/jison/sql/druid/sql_valueExpression.jison
Normal file
@ -0,0 +1,839 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
ValueExpression
|
||||
: 'NOT' ValueExpression
|
||||
{
|
||||
// verifyType($2, 'BOOLEAN');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| '!' ValueExpression
|
||||
{
|
||||
// verifyType($2, 'BOOLEAN');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| '~' ValueExpression -> $2
|
||||
| '-' ValueExpression %prec NEGATION
|
||||
{
|
||||
// verifyType($2, 'NUMBER');
|
||||
$$ = $2;
|
||||
$2.types = ['NUMBER'];
|
||||
}
|
||||
| ValueExpression 'IS' OptionalNot 'NULL' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IS' OptionalNot 'TRUE' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IS' OptionalNot 'FALSE' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IS' OptionalNot 'DISTINCT' 'FROM' ValueExpression -> { types: [ 'BOOLEAN' ] }
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'NOT' ValueExpression_EDIT -> { types: [ 'BOOLEAN' ], suggestFilters: $2.suggestFilters }
|
||||
| 'NOT' 'CURSOR'
|
||||
{
|
||||
parser.suggestFunctions();
|
||||
parser.suggestColumns();
|
||||
parser.suggestKeywords(['EXISTS']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| '!' ValueExpression_EDIT -> { types: [ 'BOOLEAN' ], suggestFilters: $2.suggestFilters }
|
||||
| '!' AnyCursor
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'BOOLEAN' ] });
|
||||
parser.suggestColumns({ types: [ 'BOOLEAN' ] });
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| '~' ValueExpression_EDIT -> { types: [ 'T' ], suggestFilters: $2.suggestFilters }
|
||||
| '~' 'PARTIAL_CURSOR'
|
||||
{
|
||||
parser.suggestFunctions();
|
||||
parser.suggestColumns();
|
||||
$$ = { types: [ 'T' ] };
|
||||
}
|
||||
| '-' ValueExpression_EDIT %prec NEGATION
|
||||
{
|
||||
if (!$2.typeSet) {
|
||||
parser.applyTypeToSuggestions('NUMBER');
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $2.suggestFilters };
|
||||
}
|
||||
| '-' 'PARTIAL_CURSOR' %prec NEGATION
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'NUMBER' ] });
|
||||
parser.suggestColumns({ types: [ 'NUMBER' ] });
|
||||
$$ = { types: [ 'NUMBER' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['FALSE', 'NOT NULL', 'NOT TRUE', 'NOT FALSE', 'NULL', 'TRUE']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'NOT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['FALSE', 'NULL', 'TRUE']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' OptionalNot 'DISTINCT' 'CURSOR'
|
||||
{
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'CURSOR' 'NULL'
|
||||
{
|
||||
parser.suggestKeywords(['NOT']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'CURSOR' 'FALSE'
|
||||
{
|
||||
parser.suggestKeywords(['NOT']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'CURSOR' 'TRUE'
|
||||
{
|
||||
parser.suggestKeywords(['NOT']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' OptionalNot 'DISTINCT' 'FROM' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $3 ? 'IS NOT DISTINCT FROM' : 'IS DISTINCT FROM');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' OptionalNot 'DISTINCT' 'FROM' ValueExpression_EDIT
|
||||
{
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $6.suggestFilters }
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ EXISTS and parenthesized ------------------
|
||||
ValueExpression
|
||||
: 'EXISTS' TableSubQuery
|
||||
{
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
// clear correlated flag after completed sub-query (set by lexer)
|
||||
parser.yy.correlatedSubQuery = false;
|
||||
}
|
||||
| '(' ValueExpression ')' -> $2
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'EXISTS' TableSubQuery_EDIT -> { types: [ 'BOOLEAN' ] }
|
||||
| '(' ValueExpression_EDIT RightParenthesisOrError
|
||||
{
|
||||
$$ = $2;
|
||||
}
|
||||
| '(' 'CURSOR' RightParenthesisOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { types: ['T'], typeSet: true };
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ COMPARISON ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression '=' ValueExpression
|
||||
{
|
||||
parser.addColRefToVariableIfExists($1, $3);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression '<' ValueExpression
|
||||
{
|
||||
parser.addColRefToVariableIfExists($1, $3);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression '>' ValueExpression
|
||||
{
|
||||
parser.addColRefToVariableIfExists($1, $3);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'COMPARISON_OPERATOR' ValueExpression
|
||||
{
|
||||
parser.addColRefToVariableIfExists($1, $3);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'CURSOR' '=' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest($3, $2);
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' '<' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest($3, $2);
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' '>' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest($3, $2);
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' 'COMPARISON_OPERATOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest($3, $2);
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression_EDIT '=' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT '<' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT '>' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT 'COMPARISON_OPERATOR' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression '=' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression '<' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ] , typeSet: true, endsWithLessThanOrEqual: true };
|
||||
}
|
||||
| ValueExpression '>' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'COMPARISON_OPERATOR' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, endsWithLessThanOrEqual: $2 === '<=' };
|
||||
}
|
||||
| ValueExpression '=' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
| ValueExpression '<' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
| ValueExpression '>' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
| ValueExpression 'COMPARISON_OPERATOR' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
// ------------------ IN ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression 'NOT' 'IN' '(' TableSubQueryInner ')' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'NOT' 'IN' '(' ValueExpressionList ')' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IN' '(' TableSubQueryInner ')' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IN' '(' ValueExpressionList ')' -> { types: [ 'BOOLEAN' ] }
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: ValueExpression 'NOT' 'IN' ValueExpressionInSecondPart_EDIT
|
||||
{
|
||||
if ($4.inValueEdit) {
|
||||
parser.valueExpressionSuggest($1, $2 + ' ' + $3);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
}
|
||||
if ($4.cursorAtStart) {
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'IN' ValueExpressionInSecondPart_EDIT
|
||||
{
|
||||
if ($3.inValueEdit) {
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
}
|
||||
if ($3.cursorAtStart) {
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression_EDIT 'NOT' 'IN' '(' ValueExpressionList RightParenthesisOrError -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression_EDIT 'NOT' 'IN' '(' TableSubQueryInner RightParenthesisOrError -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression_EDIT 'IN' '(' ValueExpressionList RightParenthesisOrError -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression_EDIT 'IN' '(' TableSubQueryInner RightParenthesisOrError -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
;
|
||||
|
||||
ValueExpressionInSecondPart_EDIT
|
||||
: '(' TableSubQueryInner_EDIT RightParenthesisOrError
|
||||
| '(' ValueExpressionList_EDIT RightParenthesisOrError -> { inValueEdit: true }
|
||||
| '(' AnyCursor RightParenthesisOrError -> { inValueEdit: true, cursorAtStart: true }
|
||||
;
|
||||
|
||||
// ------------------ BETWEEN ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression 'NOT' 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression -> { types: [ 'BOOLEAN' ] }
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: ValueExpression_EDIT 'NOT' 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression
|
||||
{
|
||||
if ($4.types[0] === $6.types[0] && !$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($4.types);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' ValueExpression_EDIT 'BETWEEN_AND' ValueExpression
|
||||
{
|
||||
if ($1.types[0] === $6.types[0] && !$4.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $4.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression_EDIT
|
||||
{
|
||||
if ($1.types[0] === $4.types[0] && !$6.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $6.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' ValueExpression 'BETWEEN_AND' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $5);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($4, ['AND']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2 + ' ' + $3);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression_EDIT 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression
|
||||
{
|
||||
if ($1.types[0] === $3.types[0] && !$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types)
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' ValueExpression_EDIT 'BETWEEN_AND' ValueExpression
|
||||
{
|
||||
if ($1.types[0] === $3.types[0] && !$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types)
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression_EDIT
|
||||
{
|
||||
if ($1.types[0] === $3.types[0] && !$5.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types)
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $5.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' ValueExpression 'BETWEEN_AND' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $4);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($3, ['AND']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ BOOLEAN ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression 'OR' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'BOOLEAN');
|
||||
// verifyType($3, 'BOOLEAN');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'AND' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'BOOLEAN');
|
||||
// verifyType($3, 'BOOLEAN');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'CURSOR' 'OR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, suggestFilters: true };
|
||||
}
|
||||
| ValueExpression_EDIT 'OR' ValueExpression
|
||||
{
|
||||
parser.addColRefIfExists($3);
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression 'OR' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, suggestFilters: true };
|
||||
}
|
||||
| ValueExpression 'OR' ValueExpression_EDIT
|
||||
{
|
||||
parser.addColRefIfExists($1);
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
| 'CURSOR' 'AND' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, suggestFilters: true };
|
||||
}
|
||||
| ValueExpression_EDIT 'AND' ValueExpression
|
||||
{
|
||||
parser.addColRefIfExists($3);
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression 'AND' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, suggestFilters: true };
|
||||
}
|
||||
| ValueExpression 'AND' ValueExpression_EDIT
|
||||
{
|
||||
parser.addColRefIfExists($1);
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ ARITHMETIC ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression '-' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'NUMBER');
|
||||
// verifyType($3, 'NUMBER');
|
||||
$$ = { types: [ 'NUMBER' ] };
|
||||
}
|
||||
| ValueExpression '*' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'NUMBER');
|
||||
// verifyType($3, 'NUMBER');
|
||||
$$ = { types: [ 'NUMBER' ] };
|
||||
}
|
||||
| ValueExpression 'ARITHMETIC_OPERATOR' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'NUMBER');
|
||||
// verifyType($3, 'NUMBER');
|
||||
$$ = { types: [ 'NUMBER' ] };
|
||||
}
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'CURSOR' '*' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions([ 'NUMBER' ]);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' 'ARITHMETIC_OPERATOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions([ 'NUMBER' ]);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression_EDIT '-' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT '*' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT 'ARITHMETIC_OPERATOR' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression '-' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression '*' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'ARITHMETIC_OPERATOR' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression '-' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $3.suggestFilters };
|
||||
}
|
||||
| ValueExpression '*' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $3.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'ARITHMETIC_OPERATOR' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $3.suggestFilters };
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ LIKE, RLIKE and REGEXP ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression LikeRightPart -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'NOT' LikeRightPart -> { types: [ 'BOOLEAN' ] }
|
||||
;
|
||||
|
||||
LikeRightPart
|
||||
: 'LIKE' ValueExpression -> { suggestKeywords: ['NOT'] }
|
||||
| 'RLIKE' ValueExpression -> { suggestKeywords: ['NOT'] }
|
||||
| 'REGEXP' ValueExpression -> { suggestKeywords: ['NOT'] }
|
||||
;
|
||||
|
||||
LikeRightPart_EDIT
|
||||
: 'LIKE' ValueExpression_EDIT
|
||||
| 'RLIKE' ValueExpression_EDIT
|
||||
| 'REGEXP' ValueExpression_EDIT
|
||||
| 'LIKE' PartialBacktickedOrCursor
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'STRING' ] });
|
||||
parser.suggestColumns({ types: [ 'STRING' ] });
|
||||
$$ = { types: ['BOOLEAN'] }
|
||||
}
|
||||
| 'RLIKE' PartialBacktickedOrCursor
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'STRING' ] });
|
||||
parser.suggestColumns({ types: [ 'STRING' ] });
|
||||
$$ = { types: ['BOOLEAN'] }
|
||||
}
|
||||
| 'REGEXP' PartialBacktickedOrCursor
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'STRING' ] });
|
||||
parser.suggestColumns({ types: [ 'STRING' ] });
|
||||
$$ = { types: ['BOOLEAN'] }
|
||||
}
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: ValueExpression_EDIT LikeRightPart -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression_EDIT 'NOT' LikeRightPart -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression LikeRightPart_EDIT -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'NOT' LikeRightPart_EDIT -> { types: [ 'BOOLEAN' ] }
|
||||
| 'CURSOR' LikeRightPart
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions([ 'STRING' ]);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' 'NOT' LikeRightPart
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2 + ' ' + $3);
|
||||
parser.applyTypeToSuggestions([ 'STRING' ]);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ CASE, WHEN, THEN ------------------
|
||||
|
||||
ValueExpression
|
||||
: 'CASE' CaseRightPart -> $2
|
||||
| 'CASE' ValueExpression CaseRightPart -> $3
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'CASE' CaseRightPart_EDIT -> $2
|
||||
| 'CASE' 'CURSOR' EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { types: [ 'T' ], typeSet: true };
|
||||
}
|
||||
| 'CASE' ValueExpression CaseRightPart_EDIT -> $3
|
||||
| 'CASE' ValueExpression 'CURSOR' EndOrError
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($2, ['WHEN']);
|
||||
$$ = { types: [ 'T' ], typeSet: true };
|
||||
}
|
||||
| 'CASE' ValueExpression_EDIT CaseRightPart
|
||||
{
|
||||
$$ = $3;
|
||||
$$.suggestFilters = $2.suggestFilters;
|
||||
}
|
||||
| 'CASE' ValueExpression_EDIT EndOrError -> { types: [ 'T' ], suggestFilters: $2.suggestFilters }
|
||||
| 'CASE' 'CURSOR' CaseRightPart -> { types: [ 'T' ] }
|
||||
;
|
||||
|
||||
CaseRightPart
|
||||
: CaseWhenThenList 'END' -> parser.findCaseType($1)
|
||||
| CaseWhenThenList 'ELSE' ValueExpression 'END'
|
||||
{
|
||||
$1.caseTypes.push($3);
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
;
|
||||
|
||||
CaseRightPart_EDIT
|
||||
: CaseWhenThenList_EDIT EndOrError -> parser.findCaseType($1)
|
||||
| CaseWhenThenList 'ELSE' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($3, ['END']);
|
||||
$1.caseTypes.push($3);
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| CaseWhenThenList_EDIT 'ELSE' ValueExpression EndOrError
|
||||
{
|
||||
$1.caseTypes.push($3);
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| CaseWhenThenList_EDIT 'ELSE' EndOrError -> parser.findCaseType($1)
|
||||
| CaseWhenThenList 'CURSOR' ValueExpression EndOrError
|
||||
{
|
||||
if ($4.toLowerCase() !== 'end') {
|
||||
parser.suggestValueExpressionKeywords($1, [{ value: 'END', weight: 3 }, { value: 'ELSE', weight: 2 }, { value: 'WHEN', weight: 1 }]);
|
||||
} else {
|
||||
parser.suggestValueExpressionKeywords($1, [{ value: 'ELSE', weight: 2 }, { value: 'WHEN', weight: 1 }]);
|
||||
}
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| CaseWhenThenList 'CURSOR' EndOrError
|
||||
{
|
||||
if ($3.toLowerCase() !== 'end') {
|
||||
parser.suggestValueExpressionKeywords($1, [{ value: 'END', weight: 3 }, { value: 'ELSE', weight: 2 }, { value: 'WHEN', weight: 1 }]);
|
||||
} else {
|
||||
parser.suggestValueExpressionKeywords($1, [{ value: 'ELSE', weight: 2 }, { value: 'WHEN', weight: 1 }]);
|
||||
}
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| CaseWhenThenList 'ELSE' ValueExpression_EDIT EndOrError
|
||||
{
|
||||
$1.caseTypes.push($3);
|
||||
$$ = parser.findCaseType($1);
|
||||
$$.suggestFilters = $3.suggestFilters
|
||||
}
|
||||
| CaseWhenThenList 'ELSE' 'CURSOR' EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| 'ELSE' 'CURSOR' EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { types: [ 'T' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' 'ELSE' ValueExpression EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = $3;
|
||||
}
|
||||
| 'CURSOR' 'ELSE' EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { types: [ 'T' ] };
|
||||
}
|
||||
;
|
||||
|
||||
EndOrError
|
||||
: 'END'
|
||||
| error
|
||||
;
|
||||
|
||||
CaseWhenThenList
|
||||
: CaseWhenThenListPartTwo -> { caseTypes: [ $1 ], lastType: $1 }
|
||||
| CaseWhenThenList CaseWhenThenListPartTwo
|
||||
{
|
||||
$1.caseTypes.push($2);
|
||||
$$ = { caseTypes: $1.caseTypes, lastType: $2 };
|
||||
}
|
||||
;
|
||||
|
||||
CaseWhenThenList_EDIT
|
||||
: CaseWhenThenListPartTwo_EDIT
|
||||
| CaseWhenThenList CaseWhenThenListPartTwo_EDIT
|
||||
| CaseWhenThenList CaseWhenThenListPartTwo_EDIT CaseWhenThenList
|
||||
| CaseWhenThenList 'CURSOR' CaseWhenThenList
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($1, ['WHEN']);
|
||||
}
|
||||
| CaseWhenThenListPartTwo_EDIT CaseWhenThenList -> $2
|
||||
;
|
||||
|
||||
CaseWhenThenListPartTwo
|
||||
: 'WHEN' ValueExpression 'THEN' ValueExpression -> $4
|
||||
;
|
||||
|
||||
CaseWhenThenListPartTwo_EDIT
|
||||
: 'WHEN' ValueExpression_EDIT -> { caseTypes: [{ types: ['T'] }], suggestFilters: $2.suggestFilters }
|
||||
| 'WHEN' ValueExpression_EDIT 'THEN' -> { caseTypes: [{ types: ['T'] }], suggestFilters: $2.suggestFilters }
|
||||
| 'WHEN' ValueExpression_EDIT 'THEN' ValueExpression -> { caseTypes: [$4], suggestFilters: $2.suggestFilters }
|
||||
| 'WHEN' ValueExpression 'THEN' ValueExpression_EDIT -> { caseTypes: [$4], suggestFilters: $4.suggestFilters }
|
||||
| 'WHEN' 'THEN' ValueExpression_EDIT -> { caseTypes: [$3], suggestFilters: $3.suggestFilters }
|
||||
| 'CURSOR' ValueExpression 'THEN'
|
||||
{
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'CURSOR' ValueExpression 'THEN' ValueExpression
|
||||
{
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { caseTypes: [$4] };
|
||||
}
|
||||
| 'CURSOR' 'THEN'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'CURSOR' 'THEN' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }], suggestFilters: true };
|
||||
}
|
||||
| 'WHEN' 'CURSOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['THEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }], suggestFilters: true };
|
||||
}
|
||||
| 'WHEN' 'CURSOR' 'THEN'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }], suggestFilters: true };
|
||||
}
|
||||
| 'WHEN' 'CURSOR' 'THEN' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [$4], suggestFilters: true };
|
||||
}
|
||||
| 'WHEN' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($2, ['THEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' ValueExpression 'CURSOR' ValueExpression
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($2, ['THEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' ValueExpression 'THEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' ValueExpression 'THEN' 'CURSOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' 'THEN' 'CURSOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' 'THEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
;
|
19
src/jison/sql/druid/syntax_footer.jison
Normal file
19
src/jison/sql/druid/syntax_footer.jison
Normal file
@ -0,0 +1,19 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%%
|
||||
|
||||
SqlParseSupport.initSyntaxParser(parser);
|
28
src/jison/sql/druid/syntax_header.jison
Normal file
28
src/jison/sql/druid/syntax_header.jison
Normal file
@ -0,0 +1,28 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%left 'AND' 'OR'
|
||||
%left 'BETWEEN'
|
||||
%left 'NOT' '!' '~'
|
||||
%left '=' '<' '>' 'COMPARISON_OPERATOR'
|
||||
%left '-' '*' 'ARITHMETIC_OPERATOR'
|
||||
|
||||
%left ';' ','
|
||||
%nonassoc 'IN' 'IS' 'LIKE' 'RLIKE' 'REGEXP' 'EXISTS' NEGATION
|
||||
|
||||
%start SqlSyntax
|
||||
|
||||
%%
|
19
src/jison/sql/elasticsearch/autocomplete_footer.jison
Normal file
19
src/jison/sql/elasticsearch/autocomplete_footer.jison
Normal file
@ -0,0 +1,19 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%%
|
||||
|
||||
SqlParseSupport.initSqlParser(parser);
|
29
src/jison/sql/elasticsearch/autocomplete_header.jison
Normal file
29
src/jison/sql/elasticsearch/autocomplete_header.jison
Normal file
@ -0,0 +1,29 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%left 'AND' 'OR'
|
||||
%left 'BETWEEN'
|
||||
%left 'NOT' '!' '~'
|
||||
%left '=' '<' '>' 'COMPARISON_OPERATOR'
|
||||
%left '-' '*' 'ARITHMETIC_OPERATOR'
|
||||
|
||||
%left ';' ','
|
||||
%nonassoc 'CURSOR' 'PARTIAL_CURSOR'
|
||||
%nonassoc 'IN' 'IS' 'LIKE' 'RLIKE' 'REGEXP' 'EXISTS' NEGATION
|
||||
|
||||
%start SqlAutocomplete
|
||||
|
||||
%%
|
226
src/jison/sql/elasticsearch/sql.jisonlex
Normal file
226
src/jison/sql/elasticsearch/sql.jisonlex
Normal file
@ -0,0 +1,226 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%options case-insensitive flex
|
||||
%s between
|
||||
%x hdfs doubleQuotedValue singleQuotedValue backtickedValue
|
||||
%%
|
||||
|
||||
\s { /* skip whitespace */ }
|
||||
'--'.* { /* skip comments */ }
|
||||
[/][*][^*]*[*]+([^/*][^*]*[*]+)*[/] { /* skip comments */ }
|
||||
|
||||
'\u2020' { parser.yy.partialCursor = false; parser.yy.cursorFound = yylloc; return 'CURSOR'; }
|
||||
'\u2021' { parser.yy.partialCursor = true; parser.yy.cursorFound = yylloc; return 'PARTIAL_CURSOR'; }
|
||||
|
||||
<between>'AND' { this.popState(); return 'BETWEEN_AND'; }
|
||||
|
||||
// Reserved Keywords
|
||||
'ALL' { return 'ALL'; }
|
||||
'ALTER' { parser.determineCase(yytext); parser.addStatementTypeLocation('ALTER', yylloc, yy.lexer.upcomingInput()); return 'ALTER'; }
|
||||
'AND' { return 'AND'; }
|
||||
'AS' { return 'AS'; }
|
||||
'ASC' { return 'ASC'; }
|
||||
'BETWEEN' { this.begin('between'); return 'BETWEEN'; }
|
||||
'BIGINT' { return 'BIGINT'; }
|
||||
'BOOLEAN' { return 'BOOLEAN'; }
|
||||
'BY' { return 'BY'; }
|
||||
'CASCADE' { return 'CASCADE'; }
|
||||
'CASE' { return 'CASE'; }
|
||||
'CHAR' { return 'CHAR'; }
|
||||
'COMMENT' { return 'COMMENT'; }
|
||||
'CREATE' { parser.determineCase(yytext); return 'CREATE'; }
|
||||
'CROSS' { return 'CROSS'; }
|
||||
'CURRENT' { return 'CURRENT'; }
|
||||
'DATABASE' { return 'DATABASE'; }
|
||||
'DECIMAL' { return 'DECIMAL'; }
|
||||
'DESC' { return 'DESC'; }
|
||||
'DISTINCT' { return 'DISTINCT'; }
|
||||
'DIV' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'DOUBLE' { return 'DOUBLE'; }
|
||||
'DROP' { parser.determineCase(yytext); parser.addStatementTypeLocation('DROP', yylloc, yy.lexer.upcomingInput()); return 'DROP'; }
|
||||
'ELSE' { return 'ELSE'; }
|
||||
'END' { return 'END'; }
|
||||
'EXISTS' { parser.yy.correlatedSubQuery = true; return 'EXISTS'; }
|
||||
'FALSE' { return 'FALSE'; }
|
||||
'FLOAT' { return 'FLOAT'; }
|
||||
'FOLLOWING' { return 'FOLLOWING'; }
|
||||
'FROM' { parser.determineCase(yytext); return 'FROM'; }
|
||||
'FULL' { return 'FULL'; }
|
||||
'GROUP' { return 'GROUP'; }
|
||||
'HAVING' { return 'HAVING'; }
|
||||
'IF' { return 'IF'; }
|
||||
'IN' { return 'IN'; }
|
||||
'INNER' { return 'INNER'; }
|
||||
'INSERT' { return 'INSERT'; }
|
||||
'INT' { return 'INT'; }
|
||||
'INTO' { return 'INTO'; }
|
||||
'IS' { return 'IS'; }
|
||||
'JOIN' { return 'JOIN'; }
|
||||
'LEFT' { return 'LEFT'; }
|
||||
'LIKE' { return 'LIKE'; }
|
||||
'LIMIT' { return 'LIMIT'; }
|
||||
'NOT' { return 'NOT'; }
|
||||
'NULL' { return 'NULL'; }
|
||||
'ON' { return 'ON'; }
|
||||
'OPTION' { return 'OPTION'; }
|
||||
'OR' { return 'OR'; }
|
||||
'ORDER' { return 'ORDER'; }
|
||||
'OUTER' { return 'OUTER'; }
|
||||
'PARTITION' { return 'PARTITION'; }
|
||||
'PRECEDING' { return 'PRECEDING'; }
|
||||
'PURGE' { return 'PURGE'; }
|
||||
'RANGE' { return 'RANGE'; }
|
||||
'REGEXP' { return 'REGEXP'; }
|
||||
'RIGHT' { return 'RIGHT'; }
|
||||
'RLIKE' { return 'RLIKE'; }
|
||||
'ROW' { return 'ROW'; }
|
||||
'ROLE' { return 'ROLE'; }
|
||||
'ROWS' { return 'ROWS'; }
|
||||
'SCHEMA' { return 'SCHEMA'; }
|
||||
'SELECT' { parser.determineCase(yytext); parser.addStatementTypeLocation('SELECT', yylloc); return 'SELECT'; }
|
||||
'SEMI' { return 'SEMI'; }
|
||||
'SET' { parser.determineCase(yytext); parser.addStatementTypeLocation('SET', yylloc); return 'SET'; }
|
||||
'SHOW' { parser.determineCase(yytext); parser.addStatementTypeLocation('SHOW', yylloc); return 'SHOW'; }
|
||||
'SMALLINT' { return 'SMALLINT'; }
|
||||
'STRING' { return 'STRING'; }
|
||||
'TABLE' { return 'TABLE'; }
|
||||
'THEN' { return 'THEN'; }
|
||||
'TIMESTAMP' { return 'TIMESTAMP'; }
|
||||
'TINYINT' { return 'TINYINT'; }
|
||||
'TO' { return 'TO'; }
|
||||
'TRUE' { return 'TRUE'; }
|
||||
'TRUNCATE' { parser.determineCase(yytext); parser.addStatementTypeLocation('TRUNCATE', yylloc, yy.lexer.upcomingInput()); return 'TRUNCATE'; }
|
||||
'UNBOUNDED' { return 'UNBOUNDED'; }
|
||||
'UNION' { return 'UNION'; }
|
||||
'UPDATE' { parser.determineCase(yytext); return 'UPDATE'; }
|
||||
'USE' { parser.determineCase(yytext); parser.addStatementTypeLocation('USE', yylloc); return 'USE'; }
|
||||
'VALUES' { return 'VALUES'; }
|
||||
'VARCHAR' { return 'VARCHAR'; }
|
||||
'VIEW' { return 'VIEW'; }
|
||||
'WHEN' { return 'WHEN'; }
|
||||
'WHERE' { return 'WHERE'; }
|
||||
'WITH' { parser.determineCase(yytext); parser.addStatementTypeLocation('WITH', yylloc); return 'WITH'; }
|
||||
|
||||
// Non-reserved Keywords
|
||||
'OVER' { return 'OVER'; }
|
||||
'ROLE' { return 'ROLE'; }
|
||||
|
||||
// --- UDFs ---
|
||||
AVG\s*\( { yy.lexer.unput('('); yytext = 'avg'; parser.addFunctionLocation(yylloc, yytext); return 'AVG'; }
|
||||
CAST\s*\( { yy.lexer.unput('('); yytext = 'cast'; parser.addFunctionLocation(yylloc, yytext); return 'CAST'; }
|
||||
COUNT\s*\( { yy.lexer.unput('('); yytext = 'count'; parser.addFunctionLocation(yylloc, yytext); return 'COUNT'; }
|
||||
MAX\s*\( { yy.lexer.unput('('); yytext = 'max'; parser.addFunctionLocation(yylloc, yytext); return 'MAX'; }
|
||||
MIN\s*\( { yy.lexer.unput('('); yytext = 'min'; parser.addFunctionLocation(yylloc, yytext); return 'MIN'; }
|
||||
STDDEV_POP\s*\( { yy.lexer.unput('('); yytext = 'stddev_pop'; parser.addFunctionLocation(yylloc, yytext); return 'STDDEV_POP'; }
|
||||
STDDEV_SAMP\s*\( { yy.lexer.unput('('); yytext = 'stddev_samp'; parser.addFunctionLocation(yylloc, yytext); return 'STDDEV_SAMP'; }
|
||||
SUM\s*\( { yy.lexer.unput('('); yytext = 'sum'; parser.addFunctionLocation(yylloc, yytext); return 'SUM'; }
|
||||
VAR_POP\s*\( { yy.lexer.unput('('); yytext = 'var_pop'; parser.addFunctionLocation(yylloc, yytext); return 'VAR_POP'; }
|
||||
VAR_SAMP\s*\( { yy.lexer.unput('('); yytext = 'var_samp'; parser.addFunctionLocation(yylloc, yytext); return 'VAR_SAMP'; }
|
||||
VARIANCE\s*\( { yy.lexer.unput('('); yytext = 'variance'; parser.addFunctionLocation(yylloc, yytext); return 'VARIANCE'; }
|
||||
|
||||
// Analytical functions
|
||||
CUME_DIST\s*\( { yy.lexer.unput('('); yytext = 'cume_dist'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
DENSE_RANK\s*\( { yy.lexer.unput('('); yytext = 'dense_rank'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
FIRST_VALUE\s*\( { yy.lexer.unput('('); yytext = 'first_value'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
LAG\s*\( { yy.lexer.unput('('); yytext = 'lag'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
LAST_VALUE\s*\( { yy.lexer.unput('('); yytext = 'last_value'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
LEAD\s*\( { yy.lexer.unput('('); yytext = 'lead'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
RANK\s*\( { yy.lexer.unput('('); yytext = 'rank'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
ROW_NUMBER\s*\( { yy.lexer.unput('('); yytext = 'row_number'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
|
||||
[0-9]+ { return 'UNSIGNED_INTEGER'; }
|
||||
[0-9]+(?:[YSL]|BD)? { return 'UNSIGNED_INTEGER'; }
|
||||
[0-9]+E { return 'UNSIGNED_INTEGER_E'; }
|
||||
[A-Za-z0-9_]+ { return 'REGULAR_IDENTIFIER'; }
|
||||
|
||||
<hdfs>'\u2020' { parser.yy.cursorFound = true; return 'CURSOR'; }
|
||||
<hdfs>'\u2021' { parser.yy.cursorFound = true; return 'PARTIAL_CURSOR'; }
|
||||
<hdfs>\s+['"] { return 'HDFS_START_QUOTE'; }
|
||||
<hdfs>[^'"\u2020\u2021]+ { parser.addFileLocation(yylloc, yytext); return 'HDFS_PATH'; }
|
||||
<hdfs>['"] { this.popState(); return 'HDFS_END_QUOTE'; }
|
||||
<hdfs><<EOF>> { return 'EOF'; }
|
||||
|
||||
'&&' { return 'AND'; }
|
||||
'||' { return 'OR'; }
|
||||
|
||||
'=' { return '='; }
|
||||
'<' { return '<'; }
|
||||
'>' { return '>'; }
|
||||
'!=' { return 'COMPARISON_OPERATOR'; }
|
||||
'<=' { return 'COMPARISON_OPERATOR'; }
|
||||
'>=' { return 'COMPARISON_OPERATOR'; }
|
||||
'<>' { return 'COMPARISON_OPERATOR'; }
|
||||
'<=>' { return 'COMPARISON_OPERATOR'; }
|
||||
|
||||
'-' { return '-'; }
|
||||
'*' { return '*'; }
|
||||
'+' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'/' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'%' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'|' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'^' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'&' { return 'ARITHMETIC_OPERATOR'; }
|
||||
|
||||
',' { return ','; }
|
||||
'.' { return '.'; }
|
||||
':' { return ':'; }
|
||||
';' { return ';'; }
|
||||
'~' { return '~'; }
|
||||
'!' { return '!'; }
|
||||
|
||||
'(' { return '('; }
|
||||
')' { return ')'; }
|
||||
'[' { return '['; }
|
||||
']' { return ']'; }
|
||||
|
||||
\$\{[^}]*\} { return 'VARIABLE_REFERENCE'; }
|
||||
|
||||
\` { this.begin('backtickedValue'); return 'BACKTICK'; }
|
||||
<backtickedValue>[^`]+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '`')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<backtickedValue>\` { this.popState(); return 'BACKTICK'; }
|
||||
|
||||
\' { this.begin('singleQuotedValue'); return 'SINGLE_QUOTE'; }
|
||||
<singleQuotedValue>(?:\\\\|\\[']|[^'])+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '\'')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<singleQuotedValue>\' { this.popState(); return 'SINGLE_QUOTE'; }
|
||||
|
||||
\" { this.begin('doubleQuotedValue'); return 'DOUBLE_QUOTE'; }
|
||||
<doubleQuotedValue>(?:\\\\|\\["]|[^"])+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '"')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<doubleQuotedValue>\" { this.popState(); return 'DOUBLE_QUOTE'; }
|
||||
|
||||
<<EOF>> { return 'EOF'; }
|
||||
|
||||
. { /* To prevent console logging of unknown chars */ }
|
||||
<between>. { }
|
||||
<hdfs>. { }
|
||||
<backtickedValue>. { }
|
||||
<singleQuotedValue>. { }
|
||||
<doubleQuotedValue>. { }
|
109
src/jison/sql/elasticsearch/sql_alter.jison
Normal file
109
src/jison/sql/elasticsearch/sql_alter.jison
Normal file
@ -0,0 +1,109 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: AlterStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: AlterStatement_EDIT
|
||||
;
|
||||
|
||||
AlterStatement
|
||||
: AlterTable
|
||||
| AlterView
|
||||
;
|
||||
|
||||
AlterStatement_EDIT
|
||||
: AlterTable_EDIT
|
||||
| AlterView_EDIT
|
||||
| 'ALTER' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['TABLE', 'VIEW']);
|
||||
}
|
||||
;
|
||||
|
||||
AlterTable
|
||||
: AlterTableLeftSide PartitionSpec
|
||||
;
|
||||
|
||||
AlterTable_EDIT
|
||||
: AlterTableLeftSide_EDIT
|
||||
| AlterTableLeftSide_EDIT PartitionSpec
|
||||
| AlterTableLeftSide 'CURSOR'
|
||||
| AlterTableLeftSide PartitionSpec 'CURSOR'
|
||||
;
|
||||
|
||||
AlterTableLeftSide
|
||||
: 'ALTER' 'TABLE' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
;
|
||||
|
||||
AlterTableLeftSide_EDIT
|
||||
: 'ALTER' 'TABLE' SchemaQualifiedTableIdentifier_EDIT
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyTables = true;
|
||||
}
|
||||
}
|
||||
| 'ALTER' 'TABLE' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables({ onlyTables: true });
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
;
|
||||
|
||||
AlterView
|
||||
: AlterViewLeftSide 'AS' QuerySpecification
|
||||
;
|
||||
|
||||
AlterView_EDIT
|
||||
: AlterViewLeftSide_EDIT
|
||||
| AlterViewLeftSide 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['AS']);
|
||||
}
|
||||
| AlterViewLeftSide 'SET' 'CURSOR'
|
||||
| AlterViewLeftSide 'AS' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
| AlterViewLeftSide 'AS' QuerySpecification_EDIT
|
||||
;
|
||||
|
||||
|
||||
AlterViewLeftSide
|
||||
: 'ALTER' 'VIEW' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
;
|
||||
|
||||
AlterViewLeftSide_EDIT
|
||||
: 'ALTER' 'VIEW' SchemaQualifiedTableIdentifier_EDIT
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyViews = true;
|
||||
}
|
||||
}
|
||||
| 'ALTER' 'VIEW' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables({ onlyViews: true });
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
;
|
615
src/jison/sql/elasticsearch/sql_create.jison
Normal file
615
src/jison/sql/elasticsearch/sql_create.jison
Normal file
@ -0,0 +1,615 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: CreateStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: CreateStatement_EDIT
|
||||
;
|
||||
|
||||
CreateStatement
|
||||
: DatabaseDefinition
|
||||
| TableDefinition
|
||||
| ViewDefinition
|
||||
| RoleDefinition
|
||||
;
|
||||
|
||||
CreateStatement_EDIT
|
||||
: DatabaseDefinition_EDIT
|
||||
| TableDefinition_EDIT
|
||||
| ViewDefinition_EDIT
|
||||
| 'CREATE' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['DATABASE', 'ROLE', 'SCHEMA', 'TABLE', 'VIEW']);
|
||||
}
|
||||
;
|
||||
|
||||
DatabaseDefinition
|
||||
: 'CREATE' DatabaseOrSchema OptionalIfNotExists
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals
|
||||
{
|
||||
parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
|
||||
}
|
||||
;
|
||||
|
||||
DatabaseDefinition_EDIT
|
||||
: 'CREATE' DatabaseOrSchema OptionalIfNotExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists_EDIT
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists 'CURSOR' RegularIdentifier
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
parser.addNewDatabaseLocation(@5, [{ name: $5 }]);
|
||||
}
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists_EDIT RegularIdentifier
|
||||
{
|
||||
parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
|
||||
}
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals 'CURSOR'
|
||||
{
|
||||
parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
|
||||
}
|
||||
;
|
||||
|
||||
DatabaseDefinitionOptionals
|
||||
: OptionalComment
|
||||
{
|
||||
if (!$1) {
|
||||
parser.suggestKeywords(['COMMENT']);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
DatabaseDefinitionOptionals_EDIT
|
||||
: OptionalComment_INVALID
|
||||
;
|
||||
|
||||
OptionalComment
|
||||
:
|
||||
| Comment
|
||||
;
|
||||
|
||||
Comment
|
||||
: 'COMMENT' QuotedValue
|
||||
;
|
||||
|
||||
OptionalComment_INVALID
|
||||
: Comment_INVALID
|
||||
;
|
||||
|
||||
Comment_INVALID
|
||||
: 'COMMENT' SINGLE_QUOTE
|
||||
| 'COMMENT' DOUBLE_QUOTE
|
||||
| 'COMMENT' SINGLE_QUOTE VALUE
|
||||
| 'COMMENT' DOUBLE_QUOTE VALUE
|
||||
;
|
||||
|
||||
TableDefinition
|
||||
: 'CREATE' 'TABLE' OptionalIfNotExists TableDefinitionRightPart
|
||||
;
|
||||
|
||||
TableDefinition_EDIT
|
||||
: 'CREATE' 'TABLE' OptionalIfNotExists TableDefinitionRightPart_EDIT
|
||||
| 'CREATE' 'TABLE' OptionalIfNotExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'CREATE' 'TABLE' OptionalIfNotExists_EDIT
|
||||
;
|
||||
|
||||
TableDefinitionRightPart
|
||||
: TableIdentifierAndOptionalColumnSpecification OptionalPartitionedBy OptionalAsSelectStatement
|
||||
;
|
||||
|
||||
TableDefinitionRightPart_EDIT
|
||||
: TableIdentifierAndOptionalColumnSpecification_EDIT OptionalPartitionedBy OptionalAsSelectStatement
|
||||
| TableIdentifierAndOptionalColumnSpecification PartitionedBy_EDIT OptionalAsSelectStatement
|
||||
| TableIdentifierAndOptionalColumnSpecification OptionalPartitionedBy OptionalAsSelectStatement_EDIT
|
||||
| TableIdentifierAndOptionalColumnSpecification OptionalPartitionedBy 'CURSOR'
|
||||
{
|
||||
var keywords = [];
|
||||
if (!$1 && !$2) {
|
||||
keywords.push({ value: 'LIKE', weight: 1 });
|
||||
} else {
|
||||
if (!$2) {
|
||||
keywords.push({ value: 'PARTITIONED BY', weight: 12 });
|
||||
}
|
||||
keywords.push({ value: 'AS', weight: 1 });
|
||||
}
|
||||
|
||||
if (keywords.length > 0) {
|
||||
parser.suggestKeywords(keywords);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
TableIdentifierAndOptionalColumnSpecification
|
||||
: SchemaQualifiedIdentifier OptionalColumnSpecificationsOrLike
|
||||
{
|
||||
parser.addNewTableLocation(@1, $1, $2);
|
||||
$$ = $2;
|
||||
}
|
||||
;
|
||||
|
||||
TableIdentifierAndOptionalColumnSpecification_EDIT
|
||||
: SchemaQualifiedIdentifier OptionalColumnSpecificationsOrLike_EDIT
|
||||
| SchemaQualifiedIdentifier_EDIT OptionalColumnSpecificationsOrLike
|
||||
;
|
||||
|
||||
OptionalColumnSpecificationsOrLike
|
||||
:
|
||||
| ParenthesizedColumnSpecificationList
|
||||
| 'LIKE' SchemaQualifiedTableIdentifier -> []
|
||||
;
|
||||
|
||||
OptionalColumnSpecificationsOrLike_EDIT
|
||||
: ParenthesizedColumnSpecificationList_EDIT
|
||||
| 'LIKE' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'LIKE' SchemaQualifiedTableIdentifier_EDIT
|
||||
;
|
||||
|
||||
ParenthesizedColumnSpecificationList
|
||||
: '(' ColumnSpecificationList ')' -> $2
|
||||
;
|
||||
|
||||
ParenthesizedColumnSpecificationList_EDIT
|
||||
: '(' ColumnSpecificationList_EDIT RightParenthesisOrError
|
||||
;
|
||||
|
||||
ColumnSpecificationList
|
||||
: ColumnSpecification -> [$1]
|
||||
| ColumnSpecificationList ',' ColumnSpecification -> $1.concat($3)
|
||||
;
|
||||
|
||||
ColumnSpecificationList_EDIT
|
||||
: ColumnSpecification_EDIT
|
||||
| ColumnSpecification_EDIT ',' ColumnSpecificationList
|
||||
| ColumnSpecificationList ',' ColumnSpecification_EDIT
|
||||
| ColumnSpecificationList ',' ColumnSpecification_EDIT ',' ColumnSpecificationList
|
||||
| ColumnSpecification 'CURSOR'
|
||||
{
|
||||
parser.checkForKeywords($1);
|
||||
}
|
||||
| ColumnSpecification 'CURSOR' ',' ColumnSpecificationList
|
||||
{
|
||||
parser.checkForKeywords($1);
|
||||
}
|
||||
| ColumnSpecificationList ',' ColumnSpecification 'CURSOR'
|
||||
{
|
||||
parser.checkForKeywords($3);
|
||||
}
|
||||
| ColumnSpecificationList ',' ColumnSpecification 'CURSOR' ',' ColumnSpecificationList
|
||||
{
|
||||
parser.checkForKeywords($3);
|
||||
}
|
||||
;
|
||||
|
||||
ColumnSpecification
|
||||
: ColumnIdentifier ColumnDataType OptionalColumnOptions
|
||||
{
|
||||
$$ = $1;
|
||||
$$.type = $2;
|
||||
var keywords = [];
|
||||
if (!$3['comment']) {
|
||||
keywords.push('COMMENT');
|
||||
}
|
||||
if (keywords.length > 0) {
|
||||
$$.suggestKeywords = keywords;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
ColumnSpecification_EDIT
|
||||
: ColumnIdentifier 'CURSOR' OptionalColumnOptions
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| ColumnIdentifier ColumnDataType_EDIT OptionalColumnOptions
|
||||
| ColumnIdentifier ColumnDataType ColumnOptions_EDIT
|
||||
;
|
||||
|
||||
OptionalColumnOptions
|
||||
: -> {}
|
||||
| ColumnOptions
|
||||
;
|
||||
|
||||
ColumnOptions
|
||||
: ColumnOption
|
||||
{
|
||||
$$ = {};
|
||||
$$[$1] = true;
|
||||
}
|
||||
| ColumnOptions ColumnOption
|
||||
{
|
||||
$1[$2] = true;
|
||||
}
|
||||
;
|
||||
|
||||
ColumnOptions_EDIT
|
||||
: ColumnOption_EDIT
|
||||
| ColumnOption_EDIT ColumnOptions
|
||||
| ColumnOptions ColumnOption_EDIT
|
||||
| ColumnOptions ColumnOption_EDIT ColumnOptions
|
||||
;
|
||||
|
||||
ColumnOption
|
||||
: 'NOT' 'NULL' -> 'null'
|
||||
| 'NULL' -> 'null'
|
||||
| Comment -> 'comment'
|
||||
;
|
||||
|
||||
ColumnOption_EDIT
|
||||
: 'NOT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['NULL']);
|
||||
}
|
||||
;
|
||||
|
||||
ColumnDataType
|
||||
: PrimitiveType
|
||||
| ArrayType
|
||||
| MapType
|
||||
| StructType
|
||||
| ArrayType_INVALID
|
||||
| MapType_INVALID
|
||||
| StructType_INVALID
|
||||
;
|
||||
|
||||
ColumnDataType_EDIT
|
||||
: ArrayType_EDIT
|
||||
| MapType_EDIT
|
||||
| StructType_EDIT
|
||||
;
|
||||
|
||||
ArrayType
|
||||
: 'ARRAY' '<' ColumnDataType '>'
|
||||
;
|
||||
|
||||
ArrayType_INVALID
|
||||
: 'ARRAY' '<' '>'
|
||||
;
|
||||
|
||||
ArrayType_EDIT
|
||||
: 'ARRAY' '<' AnyCursor GreaterThanOrError
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| 'ARRAY' '<' ColumnDataType_EDIT GreaterThanOrError
|
||||
;
|
||||
|
||||
MapType
|
||||
: 'MAP' '<' PrimitiveType ',' ColumnDataType '>'
|
||||
;
|
||||
|
||||
MapType_INVALID
|
||||
: 'MAP' '<' '>'
|
||||
;
|
||||
|
||||
MapType_EDIT
|
||||
: 'MAP' '<' PrimitiveType ',' ColumnDataType_EDIT GreaterThanOrError
|
||||
| 'MAP' '<' AnyCursor GreaterThanOrError
|
||||
{
|
||||
parser.suggestKeywords(parser.getTypeKeywords());
|
||||
}
|
||||
| 'MAP' '<' PrimitiveType ',' AnyCursor GreaterThanOrError
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| 'MAP' '<' ',' AnyCursor GreaterThanOrError
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
;
|
||||
|
||||
StructType
|
||||
: 'STRUCT' '<' StructDefinitionList '>'
|
||||
;
|
||||
|
||||
StructType_INVALID
|
||||
: 'STRUCT' '<' '>'
|
||||
;
|
||||
|
||||
StructType_EDIT
|
||||
: 'STRUCT' '<' StructDefinitionList_EDIT GreaterThanOrError
|
||||
;
|
||||
|
||||
StructDefinitionList
|
||||
: StructDefinition
|
||||
| StructDefinitionList ',' StructDefinition
|
||||
;
|
||||
|
||||
StructDefinitionList_EDIT
|
||||
: StructDefinition_EDIT
|
||||
| StructDefinition_EDIT Commas
|
||||
| StructDefinition_EDIT Commas StructDefinitionList
|
||||
| StructDefinitionList ',' StructDefinition_EDIT
|
||||
| StructDefinitionList ',' StructDefinition_EDIT Commas StructDefinitionList
|
||||
;
|
||||
|
||||
StructDefinition
|
||||
: RegularOrBacktickedIdentifier ':' ColumnDataType OptionalComment
|
||||
;
|
||||
|
||||
StructDefinition_EDIT
|
||||
: Commas RegularOrBacktickedIdentifier ':' ColumnDataType 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['COMMENT']);
|
||||
}
|
||||
| Commas RegularOrBacktickedIdentifier ':' AnyCursor
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| Commas RegularOrBacktickedIdentifier ':' ColumnDataType_EDIT
|
||||
| RegularOrBacktickedIdentifier ':' ColumnDataType 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['COMMENT']);
|
||||
}
|
||||
| RegularOrBacktickedIdentifier ':' AnyCursor
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| RegularOrBacktickedIdentifier ':' ColumnDataType_EDIT
|
||||
;
|
||||
|
||||
ColumnDataTypeList
|
||||
: ColumnDataType
|
||||
| ColumnDataTypeList ',' ColumnDataType
|
||||
;
|
||||
|
||||
ColumnDataTypeList_EDIT
|
||||
: ColumnDataTypeListInner_EDIT
|
||||
| ColumnDataTypeListInner_EDIT Commas
|
||||
| ColumnDataTypeList ',' ColumnDataTypeListInner_EDIT
|
||||
| ColumnDataTypeListInner_EDIT Commas ColumnDataTypeList
|
||||
| ColumnDataTypeList ',' ColumnDataTypeListInner_EDIT Commas ColumnDataTypeList
|
||||
;
|
||||
|
||||
ColumnDataTypeListInner_EDIT
|
||||
: Commas AnyCursor
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| Commas ColumnDataType_EDIT
|
||||
| AnyCursor
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| ColumnDataType_EDIT
|
||||
;
|
||||
|
||||
GreaterThanOrError
|
||||
: '>'
|
||||
| error
|
||||
;
|
||||
|
||||
OptionalPartitionedBy
|
||||
:
|
||||
| PartitionedBy
|
||||
;
|
||||
|
||||
PartitionedBy
|
||||
: 'PARTITION' 'BY' RangeClause
|
||||
;
|
||||
|
||||
PartitionedBy_EDIT
|
||||
: 'PARTITION' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['BY']);
|
||||
}
|
||||
| 'PARTITION' 'BY' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['RANGE']);
|
||||
}
|
||||
| 'PARTITION' 'BY' RangeClause_EDIT
|
||||
;
|
||||
|
||||
RangeClause
|
||||
: 'RANGE' ParenthesizedColumnList ParenthesizedPartitionValuesList
|
||||
;
|
||||
|
||||
RangeClause_EDIT
|
||||
: 'RANGE' 'CURSOR'
|
||||
| 'RANGE' ParenthesizedColumnList_EDIT
|
||||
| 'RANGE' ParenthesizedColumnList 'CURSOR'
|
||||
| 'RANGE' ParenthesizedColumnList ParenthesizedPartitionValuesList_EDIT
|
||||
| 'RANGE' ParenthesizedColumnList_EDIT ParenthesizedPartitionValuesList
|
||||
;
|
||||
|
||||
ParenthesizedPartitionValuesList
|
||||
: '(' PartitionValueList ')'
|
||||
;
|
||||
|
||||
ParenthesizedPartitionValuesList_EDIT
|
||||
: '(' 'CURSOR' RightParenthesisOrError
|
||||
{
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
|'(' PartitionValueList_EDIT RightParenthesisOrError
|
||||
;
|
||||
|
||||
PartitionValueList
|
||||
: PartitionValue
|
||||
| PartitionValueList ',' PartitionValue
|
||||
;
|
||||
|
||||
PartitionValueList_EDIT
|
||||
: PartitionValue_EDIT
|
||||
| PartitionValueList ',' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
| PartitionValueList ',' 'CURSOR' ',' PartitionValueList
|
||||
{
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
| PartitionValueList ',' PartitionValue_EDIT
|
||||
| PartitionValueList ',' PartitionValue_EDIT ',' PartitionValueList
|
||||
;
|
||||
|
||||
PartitionValue
|
||||
: 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' LessThanOrEqualTo ValueExpression
|
||||
| 'PARTITION' 'VALUES' LessThanOrEqualTo ValueExpression
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES'
|
||||
;
|
||||
|
||||
PartitionValue_EDIT
|
||||
: 'PARTITION' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['VALUE', 'VALUES']);
|
||||
}
|
||||
| 'PARTITION' ValueExpression_EDIT
|
||||
{
|
||||
if ($2.endsWithLessThanOrEqual) {
|
||||
parser.suggestKeywords(['VALUES']);
|
||||
}
|
||||
}
|
||||
| 'PARTITION' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['<', '<=']);
|
||||
}
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['VALUES']);
|
||||
}
|
||||
| 'PARTITION' ValueExpression_EDIT LessThanOrEqualTo 'VALUES'
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['<', '<=']);
|
||||
}
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' LessThanOrEqualTo 'CURSOR'
|
||||
{
|
||||
parser.suggestFunctions();
|
||||
}
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' LessThanOrEqualTo ValueExpression_EDIT
|
||||
| 'PARTITION' 'VALUES' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['<', '<=']);
|
||||
}
|
||||
| 'PARTITION' 'VALUES' LessThanOrEqualTo 'CURSOR'
|
||||
{
|
||||
parser.suggestFunctions();
|
||||
}
|
||||
| 'PARTITION' 'VALUES' LessThanOrEqualTo ValueExpression_EDIT
|
||||
;
|
||||
|
||||
LessThanOrEqualTo
|
||||
: '<'
|
||||
| 'COMPARISON_OPERATOR' // This is fine for autocompletion
|
||||
;
|
||||
|
||||
OptionalAsSelectStatement
|
||||
:
|
||||
| 'AS' CommitLocations QuerySpecification
|
||||
;
|
||||
|
||||
OptionalAsSelectStatement_EDIT
|
||||
: 'AS' CommitLocations 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
| 'AS' CommitLocations QuerySpecification_EDIT
|
||||
;
|
||||
|
||||
CommitLocations
|
||||
: /* empty */
|
||||
{
|
||||
parser.commitLocations();
|
||||
}
|
||||
;
|
||||
|
||||
ViewDefinition
|
||||
: 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'AS' QuerySpecification
|
||||
;
|
||||
|
||||
ViewDefinition_EDIT
|
||||
: 'CREATE' 'VIEW' OptionalIfNotExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists 'CURSOR' SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'AS' QuerySpecification
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists_EDIT
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedViewColumnList_EDIT OptionalComment
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'CURSOR'
|
||||
{
|
||||
var keywords = [{value: 'AS', weight: 1 }];
|
||||
if (!$6) {
|
||||
keywords.push({ value: 'COMMENT', weight: 3 });
|
||||
}
|
||||
parser.suggestKeywords(keywords);
|
||||
}
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'AS' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'AS' QuerySpecification_EDIT
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier_EDIT OptionalParenthesizedViewColumnList OptionalComment 'AS' QuerySpecification
|
||||
;
|
||||
|
||||
OptionalParenthesizedViewColumnList
|
||||
:
|
||||
| ParenthesizedViewColumnList
|
||||
;
|
||||
|
||||
ParenthesizedViewColumnList
|
||||
: '(' ViewColumnList ')'
|
||||
;
|
||||
|
||||
ParenthesizedViewColumnList_EDIT
|
||||
: '(' ViewColumnList_EDIT RightParenthesisOrError
|
||||
{
|
||||
if (!$2) {
|
||||
parser.suggestKeywords(['COMMENT']);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
ViewColumnList
|
||||
: ColumnReference OptionalComment
|
||||
| ViewColumnList ',' ColumnReference OptionalComment
|
||||
;
|
||||
|
||||
ViewColumnList_EDIT
|
||||
: ColumnReference OptionalComment 'CURSOR' -> $2
|
||||
| ColumnReference OptionalComment 'CURSOR' ',' ViewColumnList -> $2
|
||||
| ViewColumnList ',' ColumnReference OptionalComment 'CURSOR' -> $4
|
||||
| ViewColumnList ',' ColumnReference OptionalComment 'CURSOR' ',' ViewColumnList -> $4
|
||||
;
|
||||
|
||||
RoleDefinition
|
||||
: 'CREATE' 'ROLE' RegularIdentifier
|
||||
;
|
184
src/jison/sql/elasticsearch/sql_drop.jison
Normal file
184
src/jison/sql/elasticsearch/sql_drop.jison
Normal file
@ -0,0 +1,184 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: DropStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: DropStatement_EDIT
|
||||
;
|
||||
|
||||
DropStatement
|
||||
: DropDatabaseStatement
|
||||
| DropRoleStatement
|
||||
| DropTableStatement
|
||||
| DropViewStatement
|
||||
| TruncateTableStatement
|
||||
;
|
||||
|
||||
DropStatement_EDIT
|
||||
: DropDatabaseStatement_EDIT
|
||||
| DropTableStatement_EDIT
|
||||
| DropViewStatement_EDIT
|
||||
| TruncateTableStatement_EDIT
|
||||
| 'DROP' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['DATABASE', 'ROLE', 'SCHEMA', 'TABLE', 'VIEW']);
|
||||
}
|
||||
;
|
||||
|
||||
DropDatabaseStatement
|
||||
: 'DROP' DatabaseOrSchema OptionalIfExists RegularOrBacktickedIdentifier OptionalCascade
|
||||
;
|
||||
|
||||
DropDatabaseStatement_EDIT
|
||||
: 'DROP' DatabaseOrSchema OptionalIfExists
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists_EDIT
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
parser.suggestDatabases();
|
||||
}
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists RegularOrBacktickedIdentifier 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['CASCADE']);
|
||||
}
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists_EDIT RegularOrBacktickedIdentifier OptionalCascade
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists 'CURSOR' RegularOrBacktickedIdentifier OptionalCascade
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
;
|
||||
DropRoleStatement
|
||||
: 'DROP' 'ROLE' RegularIdentifier
|
||||
;
|
||||
|
||||
DropTableStatement
|
||||
: 'DROP' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier OptionalPurge
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
DropTableStatement_EDIT
|
||||
: 'DROP' 'TABLE' OptionalIfExists_EDIT
|
||||
| 'DROP' 'TABLE' OptionalIfExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
parser.suggestTables({ onlyTables: true });
|
||||
parser.suggestDatabases({
|
||||
appendDot: true
|
||||
});
|
||||
}
|
||||
| 'DROP' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier_EDIT OptionalPurge
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyTables = true;
|
||||
}
|
||||
}
|
||||
| 'DROP' 'TABLE' OptionalIfExists_EDIT SchemaQualifiedTableIdentifier OptionalPurge
|
||||
| 'DROP' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier OptionalPurge 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
if (!$5) {
|
||||
parser.suggestKeywords(['PURGE']);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
OptionalPurge
|
||||
:
|
||||
| 'PURGE'
|
||||
;
|
||||
|
||||
DropViewStatement
|
||||
: 'DROP' 'VIEW' OptionalIfExists SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
DropViewStatement_EDIT
|
||||
: 'DROP' 'VIEW' OptionalIfExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
parser.suggestTables({ onlyViews: true });
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'DROP' 'VIEW' OptionalIfExists 'CURSOR' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($5);
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'DROP' 'VIEW' OptionalIfExists_EDIT
|
||||
| 'DROP' 'VIEW' OptionalIfExists_EDIT SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
| 'DROP' 'VIEW' OptionalIfExists SchemaQualifiedTableIdentifier_EDIT
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyViews = true;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
TruncateTableStatement
|
||||
: 'TRUNCATE' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
TruncateTableStatement_EDIT
|
||||
: 'TRUNCATE' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['TABLE']);
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists_EDIT
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier_EDIT
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists 'CURSOR' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists_EDIT SchemaQualifiedTableIdentifier OptionalPartitionSpec
|
||||
;
|
132
src/jison/sql/elasticsearch/sql_error.jison
Normal file
132
src/jison/sql/elasticsearch/sql_error.jison
Normal file
@ -0,0 +1,132 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
SqlStatements
|
||||
: error
|
||||
| NonStartingToken error // Having just ': error' does not work for some reason, jison bug?
|
||||
;
|
||||
|
||||
SqlStatement_EDIT
|
||||
: AnyCursor error
|
||||
{
|
||||
parser.suggestDdlAndDmlKeywords();
|
||||
}
|
||||
;
|
||||
|
||||
SelectStatement
|
||||
: 'SELECT' OptionalAllOrDistinct SelectList_ERROR TableExpression
|
||||
| 'SELECT' OptionalAllOrDistinct SelectList TableExpression_ERROR
|
||||
;
|
||||
|
||||
SelectStatement_EDIT
|
||||
: 'SELECT' OptionalAllOrDistinct SelectList_ERROR_EDIT TableExpression
|
||||
{
|
||||
parser.selectListNoTableSuggest($3, $2);
|
||||
}
|
||||
| 'SELECT' OptionalAllOrDistinct SelectList_ERROR TableExpression_EDIT
|
||||
;
|
||||
|
||||
SelectList_ERROR
|
||||
: ErrorList
|
||||
| SelectList ',' ErrorList
|
||||
| ErrorList ',' SelectList ',' ErrorList
|
||||
| ErrorList ',' SelectList
|
||||
| SelectList ',' ErrorList ',' SelectList
|
||||
;
|
||||
|
||||
SelectList_ERROR_EDIT
|
||||
: ErrorList ',' SelectList_EDIT -> $3
|
||||
| SelectList ',' ErrorList ',' SelectList_EDIT -> $5
|
||||
| ErrorList ',' SelectList ',' ErrorList ',' SelectList_EDIT -> $7
|
||||
| ErrorList ',' AnyCursor
|
||||
{
|
||||
$$ = { cursorAtStart : false, suggestFunctions: true, suggestColumns: true, suggestAggregateFunctions: true };
|
||||
}
|
||||
| SelectList ',' ErrorList ',' AnyCursor
|
||||
{
|
||||
$$ = { cursorAtStart : false, suggestFunctions: true, suggestColumns: true, suggestAggregateFunctions: true };
|
||||
}
|
||||
| ErrorList ',' SelectList ',' Errors ',' AnyCursor
|
||||
{
|
||||
$$ = { cursorAtStart : true, suggestFunctions: true, suggestColumns: true, suggestAggregateFunctions: true };
|
||||
}
|
||||
;
|
||||
|
||||
SetSpecification
|
||||
: 'SET' SetOption '=' error
|
||||
;
|
||||
|
||||
ErrorList
|
||||
: error
|
||||
| Errors ',' error
|
||||
;
|
||||
|
||||
JoinType_EDIT
|
||||
: 'FULL' 'CURSOR' error
|
||||
{
|
||||
parser.suggestKeywords(['JOIN', 'OUTER JOIN']);
|
||||
}
|
||||
| 'LEFT' 'CURSOR' error
|
||||
{
|
||||
parser.suggestKeywords(['JOIN', 'OUTER JOIN']);
|
||||
}
|
||||
| 'RIGHT' 'CURSOR' error
|
||||
{
|
||||
parser.suggestKeywords(['JOIN', 'OUTER JOIN']);
|
||||
}
|
||||
;
|
||||
|
||||
OptionalSelectConditions_EDIT
|
||||
: WhereClause error 'CURSOR' OptionalGroupByClause OptionalHavingClause OptionalOrderByClause OptionalLimitClause
|
||||
{
|
||||
$$ = {
|
||||
suggestKeywords: parser.getKeywordsForOptionalsLR([$4, $5, $6, $7], [{ value: 'GROUP BY', weight: 8 }, { value: 'HAVING', weight: 7 }, { value: 'ORDER BY', weight: 5 }, { value: 'LIMIT', weight: 3 }], [true, true, true, true]),
|
||||
cursorAtEnd: !$4 && !$5 && !$6 && !$7
|
||||
};
|
||||
}
|
||||
| OptionalWhereClause OptionalGroupByClause HavingClause error 'CURSOR' OptionalOrderByClause OptionalLimitClause
|
||||
{
|
||||
$$ = {
|
||||
suggestKeywords: parser.getKeywordsForOptionalsLR([$6, $7], [{ value: 'ORDER BY', weight: 5 }, { value: 'LIMIT', weight: 3 }], [true, true]),
|
||||
cursorAtEnd: !$6 && !$7
|
||||
}
|
||||
}
|
||||
| OptionalWhereClause OptionalGroupByClause OptionalHavingClause OrderByClause error 'CURSOR' OptionalLimitClause
|
||||
{
|
||||
$$ = {
|
||||
suggestKeywords: parser.getKeywordsForOptionalsLR([$7], [{ value: 'LIMIT', weight: 3 }], [true]),
|
||||
cursorAtEnd: !$7
|
||||
}
|
||||
}
|
||||
| OptionalWhereClause OptionalGroupByClause OptionalHavingClause OptionalOrderByClause LimitClause error 'CURSOR'
|
||||
;
|
||||
|
||||
OptionalSelectConditions_EDIT
|
||||
: WhereClause error GroupByClause_EDIT OptionalHavingClause OptionalOrderByClause OptionalLimitClause
|
||||
| WhereClause error OptionalGroupByClause HavingClause_EDIT OptionalOrderByClause OptionalLimitClause
|
||||
| WhereClause error OptionalGroupByClause OptionalHavingClause OrderByClause_EDIT OptionalLimitClause
|
||||
| WhereClause error OptionalGroupByClause OptionalHavingClause OptionalOrderByClause LimitClause_EDIT
|
||||
| OptionalWhereClause GroupByClause error HavingClause_EDIT OptionalOrderByClause OptionalLimitClause
|
||||
| OptionalWhereClause GroupByClause error OptionalHavingClause OrderByClause_EDIT OptionalLimitClause
|
||||
| OptionalWhereClause GroupByClause error OptionalHavingClause OptionalOrderByClause LimitClause_EDIT
|
||||
| OptionalWhereClause OptionalGroupByClause HavingClause error OrderByClause_EDIT OptionalLimitClause
|
||||
| OptionalWhereClause OptionalGroupByClause HavingClause error OptionalOrderByClause LimitClause_EDIT
|
||||
| OptionalWhereClause OptionalGroupByClause OptionalHavingClause OrderByClause error LimitClause_EDIT
|
||||
;
|
||||
|
||||
DatabaseDefinition_EDIT
|
||||
: 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals_EDIT error
|
||||
;
|
72
src/jison/sql/elasticsearch/sql_insert.jison
Normal file
72
src/jison/sql/elasticsearch/sql_insert.jison
Normal file
@ -0,0 +1,72 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataManipulation
|
||||
: InsertStatement
|
||||
;
|
||||
|
||||
InsertStatement
|
||||
: InsertValuesStatement
|
||||
;
|
||||
|
||||
DataManipulation_EDIT
|
||||
: InsertValuesStatement_EDIT
|
||||
;
|
||||
|
||||
InsertValuesStatement
|
||||
: 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier 'VALUES' InsertValuesList
|
||||
{
|
||||
$4.owner = 'insert';
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
InsertValuesStatement_EDIT
|
||||
: 'INSERT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['INTO']);
|
||||
}
|
||||
| 'INSERT' 'INTO' OptionalTable 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['TABLE']);
|
||||
}
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier_EDIT
|
||||
| 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier 'CURSOR'
|
||||
{
|
||||
$4.owner = 'insert';
|
||||
parser.addTablePrimary($4);
|
||||
parser.suggestKeywords(['VALUES']);
|
||||
}
|
||||
| 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier_EDIT 'VALUES' InsertValuesList
|
||||
;
|
||||
|
||||
InsertValuesList
|
||||
: ParenthesizedRowValuesList
|
||||
| RowValuesList ',' ParenthesizedRowValuesList
|
||||
;
|
||||
|
||||
ParenthesizedRowValuesList
|
||||
: '(' InValueList ')'
|
||||
;
|
||||
|
||||
OptionalTable
|
||||
:
|
||||
| 'TABLE'
|
||||
;
|
2762
src/jison/sql/elasticsearch/sql_main.jison
Normal file
2762
src/jison/sql/elasticsearch/sql_main.jison
Normal file
File diff suppressed because it is too large
Load Diff
46
src/jison/sql/elasticsearch/sql_set.jison
Normal file
46
src/jison/sql/elasticsearch/sql_set.jison
Normal file
@ -0,0 +1,46 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: SetSpecification
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: 'SET' 'CURSOR'
|
||||
{
|
||||
parser.suggestSetOptions();
|
||||
}
|
||||
;
|
||||
|
||||
SetSpecification
|
||||
: 'SET' SetOption '=' SetValue
|
||||
| 'SET' 'ALL'
|
||||
;
|
||||
|
||||
SetOption
|
||||
: RegularIdentifier
|
||||
| SetOption '.' RegularIdentifier
|
||||
;
|
||||
|
||||
SetValue
|
||||
: RegularIdentifier
|
||||
| SignedInteger
|
||||
| SignedInteger RegularIdentifier
|
||||
| QuotedValue
|
||||
| 'TRUE'
|
||||
| 'FALSE'
|
||||
| 'NULL'
|
||||
;
|
122
src/jison/sql/elasticsearch/sql_update.jison
Normal file
122
src/jison/sql/elasticsearch/sql_update.jison
Normal file
@ -0,0 +1,122 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataManipulation
|
||||
: UpdateStatement
|
||||
;
|
||||
|
||||
DataManipulation_EDIT
|
||||
: UpdateStatement_EDIT
|
||||
;
|
||||
|
||||
UpdateStatement
|
||||
: 'UPDATE' TargetTable 'SET' SetClauseList OptionalFromJoinedTable OptionalWhereClause
|
||||
;
|
||||
|
||||
UpdateStatement_EDIT
|
||||
: 'UPDATE' TargetTable_EDIT 'SET' SetClauseList OptionalFromJoinedTable OptionalWhereClause
|
||||
| 'UPDATE' TargetTable 'SET' SetClauseList_EDIT OptionalFromJoinedTable OptionalWhereClause
|
||||
| 'UPDATE' TargetTable 'SET' SetClauseList FromJoinedTable_EDIT OptionalWhereClause
|
||||
| 'UPDATE' TargetTable 'SET' SetClauseList OptionalFromJoinedTable WhereClause_EDIT
|
||||
| 'UPDATE' TargetTable 'SET' SetClauseList OptionalFromJoinedTable OptionalWhereClause 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords([ 'WHERE' ]);
|
||||
}
|
||||
| 'UPDATE' TargetTable 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords([ 'SET' ]);
|
||||
}
|
||||
| 'UPDATE' TargetTable_EDIT
|
||||
| 'UPDATE' TargetTable
|
||||
| 'UPDATE' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
;
|
||||
|
||||
TargetTable
|
||||
: TableName
|
||||
;
|
||||
|
||||
TargetTable_EDIT
|
||||
: TableName_EDIT
|
||||
;
|
||||
|
||||
TableName
|
||||
: LocalOrSchemaQualifiedName
|
||||
{
|
||||
parser.addTablePrimary($1);
|
||||
}
|
||||
;
|
||||
|
||||
TableName_EDIT
|
||||
: LocalOrSchemaQualifiedName_EDIT
|
||||
;
|
||||
|
||||
SetClauseList
|
||||
: SetClause
|
||||
| SetClauseList ',' SetClause
|
||||
;
|
||||
|
||||
SetClauseList_EDIT
|
||||
: SetClause_EDIT
|
||||
| SetClauseList ',' SetClause_EDIT
|
||||
| SetClause_EDIT ',' SetClauseList
|
||||
| SetClauseList ',' SetClause_EDIT ',' SetClauseList
|
||||
;
|
||||
|
||||
SetClause
|
||||
: SetTarget '=' UpdateSource
|
||||
;
|
||||
|
||||
SetClause_EDIT
|
||||
: SetTarget '=' UpdateSource_EDIT
|
||||
| SetTarget 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords([ '=' ]);
|
||||
}
|
||||
| 'CURSOR'
|
||||
{
|
||||
parser.suggestColumns();
|
||||
}
|
||||
;
|
||||
|
||||
SetTarget
|
||||
: ColumnReference
|
||||
;
|
||||
|
||||
UpdateSource
|
||||
: ValueExpression
|
||||
;
|
||||
|
||||
UpdateSource_EDIT
|
||||
: ValueExpression_EDIT
|
||||
;
|
||||
|
||||
OptionalFromJoinedTable
|
||||
:
|
||||
| 'FROM' TableReference -> $2
|
||||
;
|
||||
|
||||
FromJoinedTable_EDIT
|
||||
: 'FROM' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'FROM' TableReference_EDIT
|
||||
;
|
39
src/jison/sql/elasticsearch/sql_use.jison
Normal file
39
src/jison/sql/elasticsearch/sql_use.jison
Normal file
@ -0,0 +1,39 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: UseStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: UseStatement_EDIT
|
||||
;
|
||||
|
||||
UseStatement
|
||||
: 'USE' RegularIdentifier
|
||||
{
|
||||
if (! parser.yy.cursorFound) {
|
||||
parser.yy.result.useDatabase = $2;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
UseStatement_EDIT
|
||||
: 'USE' 'CURSOR'
|
||||
{
|
||||
parser.suggestDatabases();
|
||||
}
|
||||
;
|
839
src/jison/sql/elasticsearch/sql_valueExpression.jison
Normal file
839
src/jison/sql/elasticsearch/sql_valueExpression.jison
Normal file
@ -0,0 +1,839 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
ValueExpression
|
||||
: 'NOT' ValueExpression
|
||||
{
|
||||
// verifyType($2, 'BOOLEAN');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| '!' ValueExpression
|
||||
{
|
||||
// verifyType($2, 'BOOLEAN');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| '~' ValueExpression -> $2
|
||||
| '-' ValueExpression %prec NEGATION
|
||||
{
|
||||
// verifyType($2, 'NUMBER');
|
||||
$$ = $2;
|
||||
$2.types = ['NUMBER'];
|
||||
}
|
||||
| ValueExpression 'IS' OptionalNot 'NULL' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IS' OptionalNot 'TRUE' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IS' OptionalNot 'FALSE' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IS' OptionalNot 'DISTINCT' 'FROM' ValueExpression -> { types: [ 'BOOLEAN' ] }
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'NOT' ValueExpression_EDIT -> { types: [ 'BOOLEAN' ], suggestFilters: $2.suggestFilters }
|
||||
| 'NOT' 'CURSOR'
|
||||
{
|
||||
parser.suggestFunctions();
|
||||
parser.suggestColumns();
|
||||
parser.suggestKeywords(['EXISTS']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| '!' ValueExpression_EDIT -> { types: [ 'BOOLEAN' ], suggestFilters: $2.suggestFilters }
|
||||
| '!' AnyCursor
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'BOOLEAN' ] });
|
||||
parser.suggestColumns({ types: [ 'BOOLEAN' ] });
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| '~' ValueExpression_EDIT -> { types: [ 'T' ], suggestFilters: $2.suggestFilters }
|
||||
| '~' 'PARTIAL_CURSOR'
|
||||
{
|
||||
parser.suggestFunctions();
|
||||
parser.suggestColumns();
|
||||
$$ = { types: [ 'T' ] };
|
||||
}
|
||||
| '-' ValueExpression_EDIT %prec NEGATION
|
||||
{
|
||||
if (!$2.typeSet) {
|
||||
parser.applyTypeToSuggestions('NUMBER');
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $2.suggestFilters };
|
||||
}
|
||||
| '-' 'PARTIAL_CURSOR' %prec NEGATION
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'NUMBER' ] });
|
||||
parser.suggestColumns({ types: [ 'NUMBER' ] });
|
||||
$$ = { types: [ 'NUMBER' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['FALSE', 'NOT NULL', 'NOT TRUE', 'NOT FALSE', 'NULL', 'TRUE']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'NOT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['FALSE', 'NULL', 'TRUE']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' OptionalNot 'DISTINCT' 'CURSOR'
|
||||
{
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'CURSOR' 'NULL'
|
||||
{
|
||||
parser.suggestKeywords(['NOT']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'CURSOR' 'FALSE'
|
||||
{
|
||||
parser.suggestKeywords(['NOT']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'CURSOR' 'TRUE'
|
||||
{
|
||||
parser.suggestKeywords(['NOT']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' OptionalNot 'DISTINCT' 'FROM' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $3 ? 'IS NOT DISTINCT FROM' : 'IS DISTINCT FROM');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' OptionalNot 'DISTINCT' 'FROM' ValueExpression_EDIT
|
||||
{
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $6.suggestFilters }
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ EXISTS and parenthesized ------------------
|
||||
ValueExpression
|
||||
: 'EXISTS' TableSubQuery
|
||||
{
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
// clear correlated flag after completed sub-query (set by lexer)
|
||||
parser.yy.correlatedSubQuery = false;
|
||||
}
|
||||
| '(' ValueExpression ')' -> $2
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'EXISTS' TableSubQuery_EDIT -> { types: [ 'BOOLEAN' ] }
|
||||
| '(' ValueExpression_EDIT RightParenthesisOrError
|
||||
{
|
||||
$$ = $2;
|
||||
}
|
||||
| '(' 'CURSOR' RightParenthesisOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { types: ['T'], typeSet: true };
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ COMPARISON ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression '=' ValueExpression
|
||||
{
|
||||
parser.addColRefToVariableIfExists($1, $3);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression '<' ValueExpression
|
||||
{
|
||||
parser.addColRefToVariableIfExists($1, $3);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression '>' ValueExpression
|
||||
{
|
||||
parser.addColRefToVariableIfExists($1, $3);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'COMPARISON_OPERATOR' ValueExpression
|
||||
{
|
||||
parser.addColRefToVariableIfExists($1, $3);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'CURSOR' '=' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest($3, $2);
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' '<' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest($3, $2);
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' '>' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest($3, $2);
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' 'COMPARISON_OPERATOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest($3, $2);
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression_EDIT '=' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT '<' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT '>' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT 'COMPARISON_OPERATOR' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression '=' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression '<' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ] , typeSet: true, endsWithLessThanOrEqual: true };
|
||||
}
|
||||
| ValueExpression '>' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'COMPARISON_OPERATOR' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, endsWithLessThanOrEqual: $2 === '<=' };
|
||||
}
|
||||
| ValueExpression '=' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
| ValueExpression '<' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
| ValueExpression '>' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
| ValueExpression 'COMPARISON_OPERATOR' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
// ------------------ IN ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression 'NOT' 'IN' '(' TableSubQueryInner ')' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'NOT' 'IN' '(' ValueExpressionList ')' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IN' '(' TableSubQueryInner ')' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IN' '(' ValueExpressionList ')' -> { types: [ 'BOOLEAN' ] }
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: ValueExpression 'NOT' 'IN' ValueExpressionInSecondPart_EDIT
|
||||
{
|
||||
if ($4.inValueEdit) {
|
||||
parser.valueExpressionSuggest($1, $2 + ' ' + $3);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
}
|
||||
if ($4.cursorAtStart) {
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'IN' ValueExpressionInSecondPart_EDIT
|
||||
{
|
||||
if ($3.inValueEdit) {
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
}
|
||||
if ($3.cursorAtStart) {
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression_EDIT 'NOT' 'IN' '(' ValueExpressionList RightParenthesisOrError -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression_EDIT 'NOT' 'IN' '(' TableSubQueryInner RightParenthesisOrError -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression_EDIT 'IN' '(' ValueExpressionList RightParenthesisOrError -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression_EDIT 'IN' '(' TableSubQueryInner RightParenthesisOrError -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
;
|
||||
|
||||
ValueExpressionInSecondPart_EDIT
|
||||
: '(' TableSubQueryInner_EDIT RightParenthesisOrError
|
||||
| '(' ValueExpressionList_EDIT RightParenthesisOrError -> { inValueEdit: true }
|
||||
| '(' AnyCursor RightParenthesisOrError -> { inValueEdit: true, cursorAtStart: true }
|
||||
;
|
||||
|
||||
// ------------------ BETWEEN ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression 'NOT' 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression -> { types: [ 'BOOLEAN' ] }
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: ValueExpression_EDIT 'NOT' 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression
|
||||
{
|
||||
if ($4.types[0] === $6.types[0] && !$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($4.types);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' ValueExpression_EDIT 'BETWEEN_AND' ValueExpression
|
||||
{
|
||||
if ($1.types[0] === $6.types[0] && !$4.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $4.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression_EDIT
|
||||
{
|
||||
if ($1.types[0] === $4.types[0] && !$6.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $6.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' ValueExpression 'BETWEEN_AND' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $5);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($4, ['AND']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2 + ' ' + $3);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression_EDIT 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression
|
||||
{
|
||||
if ($1.types[0] === $3.types[0] && !$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types)
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' ValueExpression_EDIT 'BETWEEN_AND' ValueExpression
|
||||
{
|
||||
if ($1.types[0] === $3.types[0] && !$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types)
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression_EDIT
|
||||
{
|
||||
if ($1.types[0] === $3.types[0] && !$5.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types)
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $5.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' ValueExpression 'BETWEEN_AND' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $4);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($3, ['AND']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ BOOLEAN ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression 'OR' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'BOOLEAN');
|
||||
// verifyType($3, 'BOOLEAN');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'AND' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'BOOLEAN');
|
||||
// verifyType($3, 'BOOLEAN');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'CURSOR' 'OR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, suggestFilters: true };
|
||||
}
|
||||
| ValueExpression_EDIT 'OR' ValueExpression
|
||||
{
|
||||
parser.addColRefIfExists($3);
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression 'OR' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, suggestFilters: true };
|
||||
}
|
||||
| ValueExpression 'OR' ValueExpression_EDIT
|
||||
{
|
||||
parser.addColRefIfExists($1);
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
| 'CURSOR' 'AND' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, suggestFilters: true };
|
||||
}
|
||||
| ValueExpression_EDIT 'AND' ValueExpression
|
||||
{
|
||||
parser.addColRefIfExists($3);
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression 'AND' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, suggestFilters: true };
|
||||
}
|
||||
| ValueExpression 'AND' ValueExpression_EDIT
|
||||
{
|
||||
parser.addColRefIfExists($1);
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ ARITHMETIC ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression '-' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'NUMBER');
|
||||
// verifyType($3, 'NUMBER');
|
||||
$$ = { types: [ 'NUMBER' ] };
|
||||
}
|
||||
| ValueExpression '*' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'NUMBER');
|
||||
// verifyType($3, 'NUMBER');
|
||||
$$ = { types: [ 'NUMBER' ] };
|
||||
}
|
||||
| ValueExpression 'ARITHMETIC_OPERATOR' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'NUMBER');
|
||||
// verifyType($3, 'NUMBER');
|
||||
$$ = { types: [ 'NUMBER' ] };
|
||||
}
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'CURSOR' '*' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions([ 'NUMBER' ]);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' 'ARITHMETIC_OPERATOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions([ 'NUMBER' ]);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression_EDIT '-' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT '*' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT 'ARITHMETIC_OPERATOR' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression '-' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression '*' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'ARITHMETIC_OPERATOR' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression '-' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $3.suggestFilters };
|
||||
}
|
||||
| ValueExpression '*' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $3.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'ARITHMETIC_OPERATOR' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $3.suggestFilters };
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ LIKE, RLIKE and REGEXP ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression LikeRightPart -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'NOT' LikeRightPart -> { types: [ 'BOOLEAN' ] }
|
||||
;
|
||||
|
||||
LikeRightPart
|
||||
: 'LIKE' ValueExpression -> { suggestKeywords: ['NOT'] }
|
||||
| 'RLIKE' ValueExpression -> { suggestKeywords: ['NOT'] }
|
||||
| 'REGEXP' ValueExpression -> { suggestKeywords: ['NOT'] }
|
||||
;
|
||||
|
||||
LikeRightPart_EDIT
|
||||
: 'LIKE' ValueExpression_EDIT
|
||||
| 'RLIKE' ValueExpression_EDIT
|
||||
| 'REGEXP' ValueExpression_EDIT
|
||||
| 'LIKE' PartialBacktickedOrCursor
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'STRING' ] });
|
||||
parser.suggestColumns({ types: [ 'STRING' ] });
|
||||
$$ = { types: ['BOOLEAN'] }
|
||||
}
|
||||
| 'RLIKE' PartialBacktickedOrCursor
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'STRING' ] });
|
||||
parser.suggestColumns({ types: [ 'STRING' ] });
|
||||
$$ = { types: ['BOOLEAN'] }
|
||||
}
|
||||
| 'REGEXP' PartialBacktickedOrCursor
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'STRING' ] });
|
||||
parser.suggestColumns({ types: [ 'STRING' ] });
|
||||
$$ = { types: ['BOOLEAN'] }
|
||||
}
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: ValueExpression_EDIT LikeRightPart -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression_EDIT 'NOT' LikeRightPart -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression LikeRightPart_EDIT -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'NOT' LikeRightPart_EDIT -> { types: [ 'BOOLEAN' ] }
|
||||
| 'CURSOR' LikeRightPart
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions([ 'STRING' ]);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' 'NOT' LikeRightPart
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2 + ' ' + $3);
|
||||
parser.applyTypeToSuggestions([ 'STRING' ]);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ CASE, WHEN, THEN ------------------
|
||||
|
||||
ValueExpression
|
||||
: 'CASE' CaseRightPart -> $2
|
||||
| 'CASE' ValueExpression CaseRightPart -> $3
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'CASE' CaseRightPart_EDIT -> $2
|
||||
| 'CASE' 'CURSOR' EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { types: [ 'T' ], typeSet: true };
|
||||
}
|
||||
| 'CASE' ValueExpression CaseRightPart_EDIT -> $3
|
||||
| 'CASE' ValueExpression 'CURSOR' EndOrError
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($2, ['WHEN']);
|
||||
$$ = { types: [ 'T' ], typeSet: true };
|
||||
}
|
||||
| 'CASE' ValueExpression_EDIT CaseRightPart
|
||||
{
|
||||
$$ = $3;
|
||||
$$.suggestFilters = $2.suggestFilters;
|
||||
}
|
||||
| 'CASE' ValueExpression_EDIT EndOrError -> { types: [ 'T' ], suggestFilters: $2.suggestFilters }
|
||||
| 'CASE' 'CURSOR' CaseRightPart -> { types: [ 'T' ] }
|
||||
;
|
||||
|
||||
CaseRightPart
|
||||
: CaseWhenThenList 'END' -> parser.findCaseType($1)
|
||||
| CaseWhenThenList 'ELSE' ValueExpression 'END'
|
||||
{
|
||||
$1.caseTypes.push($3);
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
;
|
||||
|
||||
CaseRightPart_EDIT
|
||||
: CaseWhenThenList_EDIT EndOrError -> parser.findCaseType($1)
|
||||
| CaseWhenThenList 'ELSE' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($3, ['END']);
|
||||
$1.caseTypes.push($3);
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| CaseWhenThenList_EDIT 'ELSE' ValueExpression EndOrError
|
||||
{
|
||||
$1.caseTypes.push($3);
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| CaseWhenThenList_EDIT 'ELSE' EndOrError -> parser.findCaseType($1)
|
||||
| CaseWhenThenList 'CURSOR' ValueExpression EndOrError
|
||||
{
|
||||
if ($4.toLowerCase() !== 'end') {
|
||||
parser.suggestValueExpressionKeywords($1, [{ value: 'END', weight: 3 }, { value: 'ELSE', weight: 2 }, { value: 'WHEN', weight: 1 }]);
|
||||
} else {
|
||||
parser.suggestValueExpressionKeywords($1, [{ value: 'ELSE', weight: 2 }, { value: 'WHEN', weight: 1 }]);
|
||||
}
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| CaseWhenThenList 'CURSOR' EndOrError
|
||||
{
|
||||
if ($3.toLowerCase() !== 'end') {
|
||||
parser.suggestValueExpressionKeywords($1, [{ value: 'END', weight: 3 }, { value: 'ELSE', weight: 2 }, { value: 'WHEN', weight: 1 }]);
|
||||
} else {
|
||||
parser.suggestValueExpressionKeywords($1, [{ value: 'ELSE', weight: 2 }, { value: 'WHEN', weight: 1 }]);
|
||||
}
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| CaseWhenThenList 'ELSE' ValueExpression_EDIT EndOrError
|
||||
{
|
||||
$1.caseTypes.push($3);
|
||||
$$ = parser.findCaseType($1);
|
||||
$$.suggestFilters = $3.suggestFilters
|
||||
}
|
||||
| CaseWhenThenList 'ELSE' 'CURSOR' EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| 'ELSE' 'CURSOR' EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { types: [ 'T' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' 'ELSE' ValueExpression EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = $3;
|
||||
}
|
||||
| 'CURSOR' 'ELSE' EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { types: [ 'T' ] };
|
||||
}
|
||||
;
|
||||
|
||||
EndOrError
|
||||
: 'END'
|
||||
| error
|
||||
;
|
||||
|
||||
CaseWhenThenList
|
||||
: CaseWhenThenListPartTwo -> { caseTypes: [ $1 ], lastType: $1 }
|
||||
| CaseWhenThenList CaseWhenThenListPartTwo
|
||||
{
|
||||
$1.caseTypes.push($2);
|
||||
$$ = { caseTypes: $1.caseTypes, lastType: $2 };
|
||||
}
|
||||
;
|
||||
|
||||
CaseWhenThenList_EDIT
|
||||
: CaseWhenThenListPartTwo_EDIT
|
||||
| CaseWhenThenList CaseWhenThenListPartTwo_EDIT
|
||||
| CaseWhenThenList CaseWhenThenListPartTwo_EDIT CaseWhenThenList
|
||||
| CaseWhenThenList 'CURSOR' CaseWhenThenList
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($1, ['WHEN']);
|
||||
}
|
||||
| CaseWhenThenListPartTwo_EDIT CaseWhenThenList -> $2
|
||||
;
|
||||
|
||||
CaseWhenThenListPartTwo
|
||||
: 'WHEN' ValueExpression 'THEN' ValueExpression -> $4
|
||||
;
|
||||
|
||||
CaseWhenThenListPartTwo_EDIT
|
||||
: 'WHEN' ValueExpression_EDIT -> { caseTypes: [{ types: ['T'] }], suggestFilters: $2.suggestFilters }
|
||||
| 'WHEN' ValueExpression_EDIT 'THEN' -> { caseTypes: [{ types: ['T'] }], suggestFilters: $2.suggestFilters }
|
||||
| 'WHEN' ValueExpression_EDIT 'THEN' ValueExpression -> { caseTypes: [$4], suggestFilters: $2.suggestFilters }
|
||||
| 'WHEN' ValueExpression 'THEN' ValueExpression_EDIT -> { caseTypes: [$4], suggestFilters: $4.suggestFilters }
|
||||
| 'WHEN' 'THEN' ValueExpression_EDIT -> { caseTypes: [$3], suggestFilters: $3.suggestFilters }
|
||||
| 'CURSOR' ValueExpression 'THEN'
|
||||
{
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'CURSOR' ValueExpression 'THEN' ValueExpression
|
||||
{
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { caseTypes: [$4] };
|
||||
}
|
||||
| 'CURSOR' 'THEN'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'CURSOR' 'THEN' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }], suggestFilters: true };
|
||||
}
|
||||
| 'WHEN' 'CURSOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['THEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }], suggestFilters: true };
|
||||
}
|
||||
| 'WHEN' 'CURSOR' 'THEN'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }], suggestFilters: true };
|
||||
}
|
||||
| 'WHEN' 'CURSOR' 'THEN' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [$4], suggestFilters: true };
|
||||
}
|
||||
| 'WHEN' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($2, ['THEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' ValueExpression 'CURSOR' ValueExpression
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($2, ['THEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' ValueExpression 'THEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' ValueExpression 'THEN' 'CURSOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' 'THEN' 'CURSOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' 'THEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
;
|
19
src/jison/sql/elasticsearch/syntax_footer.jison
Normal file
19
src/jison/sql/elasticsearch/syntax_footer.jison
Normal file
@ -0,0 +1,19 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%%
|
||||
|
||||
SqlParseSupport.initSyntaxParser(parser);
|
28
src/jison/sql/elasticsearch/syntax_header.jison
Normal file
28
src/jison/sql/elasticsearch/syntax_header.jison
Normal file
@ -0,0 +1,28 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%left 'AND' 'OR'
|
||||
%left 'BETWEEN'
|
||||
%left 'NOT' '!' '~'
|
||||
%left '=' '<' '>' 'COMPARISON_OPERATOR'
|
||||
%left '-' '*' 'ARITHMETIC_OPERATOR'
|
||||
|
||||
%left ';' ','
|
||||
%nonassoc 'IN' 'IS' 'LIKE' 'RLIKE' 'REGEXP' 'EXISTS' NEGATION
|
||||
|
||||
%start SqlSyntax
|
||||
|
||||
%%
|
19
src/jison/sql/flink/autocomplete_footer.jison
Normal file
19
src/jison/sql/flink/autocomplete_footer.jison
Normal file
@ -0,0 +1,19 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%%
|
||||
|
||||
SqlParseSupport.initSqlParser(parser);
|
29
src/jison/sql/flink/autocomplete_header.jison
Normal file
29
src/jison/sql/flink/autocomplete_header.jison
Normal file
@ -0,0 +1,29 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%left 'AND' 'OR'
|
||||
%left 'BETWEEN'
|
||||
%left 'NOT' '!' '~'
|
||||
%left '=' '<' '>' 'COMPARISON_OPERATOR'
|
||||
%left '-' '*' 'ARITHMETIC_OPERATOR'
|
||||
|
||||
%left ';' ','
|
||||
%nonassoc 'CURSOR' 'PARTIAL_CURSOR'
|
||||
%nonassoc 'IN' 'IS' 'LIKE' 'RLIKE' 'REGEXP' 'EXISTS' NEGATION
|
||||
|
||||
%start SqlAutocomplete
|
||||
|
||||
%%
|
279
src/jison/sql/flink/sql.jisonlex
Normal file
279
src/jison/sql/flink/sql.jisonlex
Normal file
@ -0,0 +1,279 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%options case-insensitive flex
|
||||
%s between
|
||||
%x hdfs doubleQuotedValue singleQuotedValue backtickedValue
|
||||
%%
|
||||
|
||||
\s { /* skip whitespace */ }
|
||||
'--'.* { /* skip comments */ }
|
||||
[/][*][^*]*[*]+([^/*][^*]*[*]+)*[/] { /* skip comments */ }
|
||||
|
||||
'\u2020' { parser.yy.partialCursor = false; parser.yy.cursorFound = yylloc; return 'CURSOR'; }
|
||||
'\u2021' { parser.yy.partialCursor = true; parser.yy.cursorFound = yylloc; return 'PARTIAL_CURSOR'; }
|
||||
|
||||
<between>'AND' { this.popState(); return 'BETWEEN_AND'; }
|
||||
|
||||
// Reserved Keywords
|
||||
'ADVANCE' { return 'ADVANCE'; }
|
||||
'ANALYZE' { return 'ANALYZE'; }
|
||||
'AND' { return 'AND'; }
|
||||
'ARRAY' { return 'ARRAY'; }
|
||||
'AS' { return 'AS'; }
|
||||
'AT' { return 'AT'; }
|
||||
'BEGINNING' { return 'BEGINNING' }
|
||||
'BETWEEN' { this.begin('between'); return 'BETWEEN'; }
|
||||
'BIGINT' { return 'BIGINT'; }
|
||||
'BOOLEAN' { return 'BOOLEAN'; }
|
||||
'BY' { return 'BY'; }
|
||||
'CASE' { return 'CASE'; }
|
||||
'CAST' { return 'CAST'; }
|
||||
'CATALOG' { return 'CATALOG'; }
|
||||
'CHANGES' { return 'CHANGES'; }
|
||||
'COLUMN' { return 'COLUMN'; }
|
||||
'COLUMNS' { return 'COLUMNS'; }
|
||||
'CONNECTOR' { return 'CONNECTOR'; }
|
||||
'CONNECTORS' { return 'CONNECTORS'; }
|
||||
'CREATE' { parser.determineCase(yytext); return 'CREATE'; }
|
||||
'DATE' { return 'DATE'; }
|
||||
'DAY' { return 'DAY'; }
|
||||
'DECIMAL' { return 'DECIMAL'; }
|
||||
'DELETE' { return 'DELETE'; }
|
||||
'DESCRIBE' { return 'DESCRIBE'; }
|
||||
'DISTINCT' { return 'DISTINCT'; }
|
||||
'DOUBLE' { return 'DOUBLE'; }
|
||||
'DROP' { parser.determineCase(yytext); parser.addStatementTypeLocation('DROP', yylloc, yy.lexer.upcomingInput()); return 'DROP'; }
|
||||
'ELSE' { return 'ELSE'; }
|
||||
'EMIT' { return 'EMIT'; }
|
||||
'END' { return 'END'; }
|
||||
'EXISTS' { parser.yy.correlatedSubQuery = true; return 'EXISTS'; }
|
||||
'EXPLAIN' { parser.determineCase(yytext); return 'EXPLAIN'; }
|
||||
'EXPORT' { return 'EXPORT'; }
|
||||
'EXTENDED' { return 'EXTENDED'; }
|
||||
'FROM' { parser.determineCase(yytext); return 'FROM'; }
|
||||
'FULL' { return 'FULL'; }
|
||||
'FUNCTION' { return 'FUNCTION'; }
|
||||
'FUNCTIONS' { return 'FUNCTIONS'; }
|
||||
'GROUP' { return 'GROUP'; }
|
||||
'HAVING' { return 'HAVING'; }
|
||||
'HOPPING' { return 'HOPPING'; }
|
||||
'HOUR' { return 'HOUR'; }
|
||||
'HOURS' { return 'HOURS'; }
|
||||
'IF' { return 'IF'; }
|
||||
'IN' { return 'IN'; }
|
||||
'INNER' { return 'INNER'; }
|
||||
'INSERT' { return 'INSERT'; }
|
||||
'INT' { return 'INT'; }
|
||||
'INTEGER' { return 'INTEGER'; }
|
||||
'INTO' { return 'INTO'; }
|
||||
'IS' { return 'IS'; }
|
||||
'JOIN' { return 'JOIN'; }
|
||||
'KEY' { return 'KEY'; }
|
||||
'LEFT' { return 'LEFT'; }
|
||||
'LIKE' { return 'LIKE'; }
|
||||
'LIMIT' { return 'LIMIT'; }
|
||||
'LIST' { return 'LIST'; }
|
||||
'LOAD' { return 'LOAD'; }
|
||||
'MAP' { return 'MAP'; }
|
||||
'MILLISECOND' { return 'MILLISECOND'; }
|
||||
'MILLISECONDS' { return 'MILLISECONDS'; }
|
||||
'MINUTE' { return 'MINUTE'; }
|
||||
'MINUTES' { return 'MINUTES'; }
|
||||
'MONTH' { return 'MONTH'; }
|
||||
'MONTHS' { return 'MONTHS'; }
|
||||
'NOT' { return 'NOT'; }
|
||||
'NULL' { return 'NULL'; }
|
||||
'ON' { return 'ON'; }
|
||||
'OR' { return 'OR'; }
|
||||
'OUTER' { return 'OUTER'; }
|
||||
'PARTITION' { return 'PARTITION'; }
|
||||
'PARTITIONS' { return 'PARTITIONS'; }
|
||||
'PRINT' { return 'PRINT'; }
|
||||
'PROPERTIES' { return 'PROPERTIES'; }
|
||||
'QUERIES' { return 'QUERIES'; }
|
||||
'QUERY' { return 'QUERY'; }
|
||||
'RENAME' { return 'RENAME'; }
|
||||
'RESET' { return 'RESET'; }
|
||||
'RIGHT' { return 'RIGHT'; }
|
||||
'RUN' { return 'RUN'; }
|
||||
'SAMPLE' { return 'SAMPLE'; }
|
||||
'SCRIPT' { return 'SCRIPT'; }
|
||||
'SECOND' { return 'SECOND'; }
|
||||
'SECOND' { return 'SECOND'; }
|
||||
'SELECT' { parser.determineCase(yytext); parser.addStatementTypeLocation('SELECT', yylloc); return 'SELECT'; }
|
||||
'SESSION' { return 'SESSION'; }
|
||||
'SET' { parser.determineCase(yytext); parser.addStatementTypeLocation('SET', yylloc); return 'SET'; }
|
||||
'SHOW' { parser.determineCase(yytext); parser.addStatementTypeLocation('SHOW', yylloc); return 'SHOW'; }
|
||||
'SINK' { return 'SINK'; }
|
||||
'SOURCE' { return 'SOURCE'; }
|
||||
'STREAM' { return 'STREAM'; }
|
||||
'STREAMS' { return 'STREAMS'; }
|
||||
'STRING' { return 'STRING'; }
|
||||
'STRUCT' { return 'STRUCT'; }
|
||||
'TABLE' { return 'TABLE'; }
|
||||
'TABLES' { return 'TABLES'; }
|
||||
'TERMINATE' { return 'TERMINATE'; }
|
||||
'THEN' { return 'THEN'; }
|
||||
'TIME' { return 'TIME'; }
|
||||
'TIMESTAMP' { return 'TIMESTAMP'; }
|
||||
'TO' { return 'TO'; }
|
||||
'TRUE' { return 'TRUE'; }
|
||||
'TOPIC' { return 'TOPIC'; }
|
||||
'TOPICS' { return 'TOPICS'; }
|
||||
'TUMBLING' { return 'TUMBLING'; }
|
||||
'TYPE' { return 'TYPE'; }
|
||||
'TYPES' { return 'TYPES'; }
|
||||
'UNSET' { return 'UNSET'; }
|
||||
'VALUES' { return 'VALUES'; }
|
||||
'VARCHAR' { return 'VARCHAR'; }
|
||||
'WHEN' { return 'WHEN'; }
|
||||
'WHERE' { return 'WHERE'; }
|
||||
'WITH' { parser.determineCase(yytext); parser.addStatementTypeLocation('WITH', yylloc); return 'WITH'; }
|
||||
'WITHIN' { return 'WITHIN'; }
|
||||
'YEAR' { return 'YEAR'; }
|
||||
'YEARS' { return 'YEARS'; }
|
||||
'ZONE' { return 'ZONE'; }
|
||||
|
||||
// --- UDFs ---
|
||||
ABS\s*\( { yy.lexer.unput('('); yytext = 'abs'; parser.addFunctionLocation(yylloc, yytext); return 'ABS'; }
|
||||
ARRAYCONTAINS\s*\( { yy.lexer.unput('('); yytext = 'arraycontains'; parser.addFunctionLocation(yylloc, yytext); return 'ARRAYCONTAINS'; }
|
||||
CEIL\s*\( { yy.lexer.unput('('); yytext = 'ceil'; parser.addFunctionLocation(yylloc, yytext); return 'CEIL'; }
|
||||
CONCAT\s*\( { yy.lexer.unput('('); yytext = 'concat'; parser.addFunctionLocation(yylloc, yytext); return 'CONCAT'; }
|
||||
DATETOSTRING\s*\( { yy.lexer.unput('('); yytext = 'datetostring'; parser.addFunctionLocation(yylloc, yytext); return 'DATETOSTRING'; }
|
||||
ELT\s*\( { yy.lexer.unput('('); yytext = 'elt'; parser.addFunctionLocation(yylloc, yytext); return 'ELT'; }
|
||||
EXTRACTJSONFIELD\s*\( { yy.lexer.unput('('); yytext = 'extractjsonfield'; parser.addFunctionLocation(yylloc, yytext); return 'EXTRACTJSONFIELD'; }
|
||||
FIELD\s*\( { yy.lexer.unput('('); yytext = 'field'; parser.addFunctionLocation(yylloc, yytext); return 'FIELD'; }
|
||||
FLOOR\s*\( { yy.lexer.unput('('); yytext = 'floor'; parser.addFunctionLocation(yylloc, yytext); return 'FLOOR'; }
|
||||
GEO_DISTANCE\s*\( { yy.lexer.unput('('); yytext = 'geo_distance'; parser.addFunctionLocation(yylloc, yytext); return 'GEO_DISTANCE'; }
|
||||
IFNULL\s*\( { yy.lexer.unput('('); yytext = 'ifnull'; parser.addFunctionLocation(yylloc, yytext); return 'IFNULL'; }
|
||||
LCASE\s*\( { yy.lexer.unput('('); yytext = 'lcase'; parser.addFunctionLocation(yylloc, yytext); return 'LCASE'; }
|
||||
LEN\s*\( { yy.lexer.unput('('); yytext = 'len'; parser.addFunctionLocation(yylloc, yytext); return 'LEN'; }
|
||||
MASK\s*\( { yy.lexer.unput('('); yytext = 'msk'; parser.addFunctionLocation(yylloc, yytext); return 'MASK'; }
|
||||
MASK_KEEP_LEFT\s*\( { yy.lexer.unput('('); yytext = 'mask_keep_left'; parser.addFunctionLocation(yylloc, yytext); return 'MASK_KEEP_LEFT'; }
|
||||
MASK_KEEP_RIGHT\s*\( { yy.lexer.unput('('); yytext = 'mask_keep_right'; parser.addFunctionLocation(yylloc, yytext); return 'MASK_KEEP_RIGHT'; }
|
||||
MASK_LEFT\s*\( { yy.lexer.unput('('); yytext = 'mask_left'; parser.addFunctionLocation(yylloc, yytext); return 'MASK_LEFT'; }
|
||||
MASK_RIGHT\s*\( { yy.lexer.unput('('); yytext = 'mask_right'; parser.addFunctionLocation(yylloc, yytext); return 'MASK_RIGHT'; }
|
||||
RANDOM\s*\( { yy.lexer.unput('('); yytext = 'random'; parser.addFunctionLocation(yylloc, yytext); return 'RANDOM'; }
|
||||
ROUND\s*\( { yy.lexer.unput('('); yytext = 'round'; parser.addFunctionLocation(yylloc, yytext); return 'ROUND'; }
|
||||
SPLIT\s*\( { yy.lexer.unput('('); yytext = 'split'; parser.addFunctionLocation(yylloc, yytext); return 'SPLIT'; }
|
||||
STRINGTODATE\s*\( { yy.lexer.unput('('); yytext = 'stringtodate'; parser.addFunctionLocation(yylloc, yytext); return 'STRINGTODATE'; }
|
||||
STRINGTOTIMESTAMP\s*\( { yy.lexer.unput('('); yytext = 'stringtotimestamp'; parser.addFunctionLocation(yylloc, yytext); return 'STRINGTOTIMESTAMP'; }
|
||||
SUBSTRING\s*\( { yy.lexer.unput('('); yytext = 'substring'; parser.addFunctionLocation(yylloc, yytext); return 'SUBSTRING'; }
|
||||
TIMESTAMPTOSTRING\s*\( { yy.lexer.unput('('); yytext = 'timestamptostring'; parser.addFunctionLocation(yylloc, yytext); return 'TIMESTAMPTOSTRING'; }
|
||||
TRIM\s*\( { yy.lexer.unput('('); yytext = 'trim'; parser.addFunctionLocation(yylloc, yytext); return 'TRIM'; }
|
||||
UCASE\s*\( { yy.lexer.unput('('); yytext = 'ucase'; parser.addFunctionLocation(yylloc, yytext); return 'UCASE'; }
|
||||
URL_DECODE_PARAM\s*\( { yy.lexer.unput('('); yytext = 'url_decode_param'; parser.addFunctionLocation(yylloc, yytext); return 'URL_DECODE_PARAM'; }
|
||||
URL_ENCODE_PARAM\s*\( { yy.lexer.unput('('); yytext = 'urel_encode_param'; parser.addFunctionLocation(yylloc, yytext); return 'URL_ENCODE_PARAM'; }
|
||||
URL_EXTRACT_FRAGMENT\s*\( { yy.lexer.unput('('); yytext = 'url_extract_fragment'; parser.addFunctionLocation(yylloc, yytext); return 'URL_EXTRACT_FRAGMENT'; }
|
||||
URL_EXTRACT_HOST\s*\( { yy.lexer.unput('('); yytext = 'url_extract_host'; parser.addFunctionLocation(yylloc, yytext); return 'URL_EXTRACT_HOST'; }
|
||||
URL_EXTRACT_PARAMETER\s*\( { yy.lexer.unput('('); yytext = 'url_extract_parameter'; parser.addFunctionLocation(yylloc, yytext); return 'URL_EXTRACT_PARAMETER'; }
|
||||
URL_EXTRACT_PATH\s*\( { yy.lexer.unput('('); yytext = 'url_extrct_path'; parser.addFunctionLocation(yylloc, yytext); return 'URL_EXTRACT_PATH'; }
|
||||
URL_EXTRACT_PORT\s*\( { yy.lexer.unput('('); yytext = 'url_extract_port'; parser.addFunctionLocation(yylloc, yytext); return 'URL_EXTRACT_PORT'; }
|
||||
URL_EXTRACT_PROTOCOL\s*\( { yy.lexer.unput('('); yytext = 'url_extract_protocol'; parser.addFunctionLocation(yylloc, yytext); return 'URL_EXTRACT_PROTOCOL'; }
|
||||
URL_EXTRACT_QUERY\s*\( { yy.lexer.unput('('); yytext = 'url_extract_query'; parser.addFunctionLocation(yylloc, yytext); return 'URL_EXTRACT_QUERY'; }
|
||||
|
||||
|
||||
// Analytical functions
|
||||
COLLECT_LIST\s*\( { yy.lexer.unput('('); yytext = 'collect_list'; parser.addFunctionLocation(yylloc, yytext); return 'COLLECT_LIST'; }
|
||||
COLLECT_SET\s*\( { yy.lexer.unput('('); yytext = 'collect_set'; parser.addFunctionLocation(yylloc, yytext); return 'COLLECT_SET'; }
|
||||
COUNT\s*\( { yy.lexer.unput('('); yytext = 'count'; parser.addFunctionLocation(yylloc, yytext); return 'COUNT'; }
|
||||
HISTOGRAM\s*\( { yy.lexer.unput('('); yytext = 'historgram'; parser.addFunctionLocation(yylloc, yytext); return 'HISTOGRAM'; }
|
||||
MAX\s*\( { yy.lexer.unput('('); yytext = 'max'; parser.addFunctionLocation(yylloc, yytext); return 'MAX'; }
|
||||
MIN\s*\( { yy.lexer.unput('('); yytext = 'min'; parser.addFunctionLocation(yylloc, yytext); return 'MIN'; }
|
||||
SUM\s*\( { yy.lexer.unput('('); yytext = 'sum'; parser.addFunctionLocation(yylloc, yytext); return 'SUM'; }
|
||||
TOPK\s*\( { yy.lexer.unput('('); yytext = 'topk'; parser.addFunctionLocation(yylloc, yytext); return 'TOPK'; }
|
||||
TOPKDISTINCT\s*\( { yy.lexer.unput('('); yytext = 'topkdistinct'; parser.addFunctionLocation(yylloc, yytext); return 'TOPKDISTINCT'; }
|
||||
WindowStart\s*\( { yy.lexer.unput('('); yytext = 'windowstart'; parser.addFunctionLocation(yylloc, yytext); return 'WindowStart'; }
|
||||
WindowEnd\s*\( { yy.lexer.unput('('); yytext = 'windowend'; parser.addFunctionLocation(yylloc, yytext); return 'WindowEnd'; }
|
||||
|
||||
|
||||
[0-9]+ { return 'UNSIGNED_INTEGER'; }
|
||||
[0-9]+(?:[YSL]|BD)? { return 'UNSIGNED_INTEGER'; }
|
||||
[0-9]+E { return 'UNSIGNED_INTEGER_E'; }
|
||||
[A-Za-z0-9_]+ { return 'REGULAR_IDENTIFIER'; }
|
||||
|
||||
|
||||
'&&' { return 'AND'; }
|
||||
'||' { return 'OR'; }
|
||||
|
||||
'=' { return '='; }
|
||||
'<' { return '<'; }
|
||||
'>' { return '>'; }
|
||||
'!=' { return 'COMPARISON_OPERATOR'; }
|
||||
'<=' { return 'COMPARISON_OPERATOR'; }
|
||||
'>=' { return 'COMPARISON_OPERATOR'; }
|
||||
'<>' { return 'COMPARISON_OPERATOR'; }
|
||||
'<=>' { return 'COMPARISON_OPERATOR'; }
|
||||
|
||||
'-' { return '-'; }
|
||||
'*' { return '*'; }
|
||||
'+' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'/' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'%' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'|' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'^' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'&' { return 'ARITHMETIC_OPERATOR'; }
|
||||
|
||||
',' { return ','; }
|
||||
'.' { return '.'; }
|
||||
':' { return ':'; }
|
||||
';' { return ';'; }
|
||||
'~' { return '~'; }
|
||||
'!' { return '!'; }
|
||||
|
||||
'(' { return '('; }
|
||||
')' { return ')'; }
|
||||
'[' { return '['; }
|
||||
']' { return ']'; }
|
||||
|
||||
\$\{[^}]*\} { return 'VARIABLE_REFERENCE'; }
|
||||
|
||||
\` { this.begin('backtickedValue'); return 'BACKTICK'; }
|
||||
<backtickedValue>[^`]+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '`')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<backtickedValue>\` { this.popState(); return 'BACKTICK'; }
|
||||
|
||||
\' { this.begin('singleQuotedValue'); return 'SINGLE_QUOTE'; }
|
||||
<singleQuotedValue>(?:\\\\|\\[']|[^'])+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '\'')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<singleQuotedValue>\' { this.popState(); return 'SINGLE_QUOTE'; }
|
||||
|
||||
\" { this.begin('doubleQuotedValue'); return 'DOUBLE_QUOTE'; }
|
||||
<doubleQuotedValue>(?:\\\\|\\["]|[^"])+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '"')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<doubleQuotedValue>\" { this.popState(); return 'DOUBLE_QUOTE'; }
|
||||
|
||||
<<EOF>> { return 'EOF'; }
|
||||
|
||||
. { /* To prevent console logging of unknown chars */ }
|
||||
<between>. { }
|
||||
<hdfs>. { }
|
||||
<backtickedValue>. { }
|
||||
<singleQuotedValue>. { }
|
||||
<doubleQuotedValue>. { }
|
615
src/jison/sql/flink/sql_create.jison
Normal file
615
src/jison/sql/flink/sql_create.jison
Normal file
@ -0,0 +1,615 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: CreateStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: CreateStatement_EDIT
|
||||
;
|
||||
|
||||
CreateStatement
|
||||
: DatabaseDefinition
|
||||
| TableDefinition
|
||||
| ViewDefinition
|
||||
| RoleDefinition
|
||||
;
|
||||
|
||||
CreateStatement_EDIT
|
||||
: DatabaseDefinition_EDIT
|
||||
| TableDefinition_EDIT
|
||||
| ViewDefinition_EDIT
|
||||
| 'CREATE' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['DATABASE', 'ROLE', 'SCHEMA', 'TABLE', 'VIEW']);
|
||||
}
|
||||
;
|
||||
|
||||
DatabaseDefinition
|
||||
: 'CREATE' DatabaseOrSchema OptionalIfNotExists
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals
|
||||
{
|
||||
parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
|
||||
}
|
||||
;
|
||||
|
||||
DatabaseDefinition_EDIT
|
||||
: 'CREATE' DatabaseOrSchema OptionalIfNotExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists_EDIT
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists 'CURSOR' RegularIdentifier
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
parser.addNewDatabaseLocation(@5, [{ name: $5 }]);
|
||||
}
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists_EDIT RegularIdentifier
|
||||
{
|
||||
parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
|
||||
}
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals 'CURSOR'
|
||||
{
|
||||
parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
|
||||
}
|
||||
;
|
||||
|
||||
DatabaseDefinitionOptionals
|
||||
: OptionalComment
|
||||
{
|
||||
if (!$1) {
|
||||
parser.suggestKeywords(['COMMENT']);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
DatabaseDefinitionOptionals_EDIT
|
||||
: OptionalComment_INVALID
|
||||
;
|
||||
|
||||
OptionalComment
|
||||
:
|
||||
| Comment
|
||||
;
|
||||
|
||||
Comment
|
||||
: 'COMMENT' QuotedValue
|
||||
;
|
||||
|
||||
OptionalComment_INVALID
|
||||
: Comment_INVALID
|
||||
;
|
||||
|
||||
Comment_INVALID
|
||||
: 'COMMENT' SINGLE_QUOTE
|
||||
| 'COMMENT' DOUBLE_QUOTE
|
||||
| 'COMMENT' SINGLE_QUOTE VALUE
|
||||
| 'COMMENT' DOUBLE_QUOTE VALUE
|
||||
;
|
||||
|
||||
TableDefinition
|
||||
: 'CREATE' 'TABLE' OptionalIfNotExists TableDefinitionRightPart
|
||||
;
|
||||
|
||||
TableDefinition_EDIT
|
||||
: 'CREATE' 'TABLE' OptionalIfNotExists TableDefinitionRightPart_EDIT
|
||||
| 'CREATE' 'TABLE' OptionalIfNotExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'CREATE' 'TABLE' OptionalIfNotExists_EDIT
|
||||
;
|
||||
|
||||
TableDefinitionRightPart
|
||||
: TableIdentifierAndOptionalColumnSpecification OptionalPartitionedBy OptionalAsSelectStatement
|
||||
;
|
||||
|
||||
TableDefinitionRightPart_EDIT
|
||||
: TableIdentifierAndOptionalColumnSpecification_EDIT OptionalPartitionedBy OptionalAsSelectStatement
|
||||
| TableIdentifierAndOptionalColumnSpecification PartitionedBy_EDIT OptionalAsSelectStatement
|
||||
| TableIdentifierAndOptionalColumnSpecification OptionalPartitionedBy OptionalAsSelectStatement_EDIT
|
||||
| TableIdentifierAndOptionalColumnSpecification OptionalPartitionedBy 'CURSOR'
|
||||
{
|
||||
var keywords = [];
|
||||
if (!$1 && !$2) {
|
||||
keywords.push({ value: 'LIKE', weight: 1 });
|
||||
} else {
|
||||
if (!$2) {
|
||||
keywords.push({ value: 'PARTITIONED BY', weight: 12 });
|
||||
}
|
||||
keywords.push({ value: 'AS', weight: 1 });
|
||||
}
|
||||
|
||||
if (keywords.length > 0) {
|
||||
parser.suggestKeywords(keywords);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
TableIdentifierAndOptionalColumnSpecification
|
||||
: SchemaQualifiedIdentifier OptionalColumnSpecificationsOrLike
|
||||
{
|
||||
parser.addNewTableLocation(@1, $1, $2);
|
||||
$$ = $2;
|
||||
}
|
||||
;
|
||||
|
||||
TableIdentifierAndOptionalColumnSpecification_EDIT
|
||||
: SchemaQualifiedIdentifier OptionalColumnSpecificationsOrLike_EDIT
|
||||
| SchemaQualifiedIdentifier_EDIT OptionalColumnSpecificationsOrLike
|
||||
;
|
||||
|
||||
OptionalColumnSpecificationsOrLike
|
||||
:
|
||||
| ParenthesizedColumnSpecificationList
|
||||
| 'LIKE' SchemaQualifiedTableIdentifier -> []
|
||||
;
|
||||
|
||||
OptionalColumnSpecificationsOrLike_EDIT
|
||||
: ParenthesizedColumnSpecificationList_EDIT
|
||||
| 'LIKE' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'LIKE' SchemaQualifiedTableIdentifier_EDIT
|
||||
;
|
||||
|
||||
ParenthesizedColumnSpecificationList
|
||||
: '(' ColumnSpecificationList ')' -> $2
|
||||
;
|
||||
|
||||
ParenthesizedColumnSpecificationList_EDIT
|
||||
: '(' ColumnSpecificationList_EDIT RightParenthesisOrError
|
||||
;
|
||||
|
||||
ColumnSpecificationList
|
||||
: ColumnSpecification -> [$1]
|
||||
| ColumnSpecificationList ',' ColumnSpecification -> $1.concat($3)
|
||||
;
|
||||
|
||||
ColumnSpecificationList_EDIT
|
||||
: ColumnSpecification_EDIT
|
||||
| ColumnSpecification_EDIT ',' ColumnSpecificationList
|
||||
| ColumnSpecificationList ',' ColumnSpecification_EDIT
|
||||
| ColumnSpecificationList ',' ColumnSpecification_EDIT ',' ColumnSpecificationList
|
||||
| ColumnSpecification 'CURSOR'
|
||||
{
|
||||
parser.checkForKeywords($1);
|
||||
}
|
||||
| ColumnSpecification 'CURSOR' ',' ColumnSpecificationList
|
||||
{
|
||||
parser.checkForKeywords($1);
|
||||
}
|
||||
| ColumnSpecificationList ',' ColumnSpecification 'CURSOR'
|
||||
{
|
||||
parser.checkForKeywords($3);
|
||||
}
|
||||
| ColumnSpecificationList ',' ColumnSpecification 'CURSOR' ',' ColumnSpecificationList
|
||||
{
|
||||
parser.checkForKeywords($3);
|
||||
}
|
||||
;
|
||||
|
||||
ColumnSpecification
|
||||
: ColumnIdentifier ColumnDataType OptionalColumnOptions
|
||||
{
|
||||
$$ = $1;
|
||||
$$.type = $2;
|
||||
var keywords = [];
|
||||
if (!$3['comment']) {
|
||||
keywords.push('COMMENT');
|
||||
}
|
||||
if (keywords.length > 0) {
|
||||
$$.suggestKeywords = keywords;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
ColumnSpecification_EDIT
|
||||
: ColumnIdentifier 'CURSOR' OptionalColumnOptions
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| ColumnIdentifier ColumnDataType_EDIT OptionalColumnOptions
|
||||
| ColumnIdentifier ColumnDataType ColumnOptions_EDIT
|
||||
;
|
||||
|
||||
OptionalColumnOptions
|
||||
: -> {}
|
||||
| ColumnOptions
|
||||
;
|
||||
|
||||
ColumnOptions
|
||||
: ColumnOption
|
||||
{
|
||||
$$ = {};
|
||||
$$[$1] = true;
|
||||
}
|
||||
| ColumnOptions ColumnOption
|
||||
{
|
||||
$1[$2] = true;
|
||||
}
|
||||
;
|
||||
|
||||
ColumnOptions_EDIT
|
||||
: ColumnOption_EDIT
|
||||
| ColumnOption_EDIT ColumnOptions
|
||||
| ColumnOptions ColumnOption_EDIT
|
||||
| ColumnOptions ColumnOption_EDIT ColumnOptions
|
||||
;
|
||||
|
||||
ColumnOption
|
||||
: 'NOT' 'NULL' -> 'null'
|
||||
| 'NULL' -> 'null'
|
||||
| Comment -> 'comment'
|
||||
;
|
||||
|
||||
ColumnOption_EDIT
|
||||
: 'NOT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['NULL']);
|
||||
}
|
||||
;
|
||||
|
||||
ColumnDataType
|
||||
: PrimitiveType
|
||||
| ArrayType
|
||||
| MapType
|
||||
| StructType
|
||||
| ArrayType_INVALID
|
||||
| MapType_INVALID
|
||||
| StructType_INVALID
|
||||
;
|
||||
|
||||
ColumnDataType_EDIT
|
||||
: ArrayType_EDIT
|
||||
| MapType_EDIT
|
||||
| StructType_EDIT
|
||||
;
|
||||
|
||||
ArrayType
|
||||
: 'ARRAY' '<' ColumnDataType '>'
|
||||
;
|
||||
|
||||
ArrayType_INVALID
|
||||
: 'ARRAY' '<' '>'
|
||||
;
|
||||
|
||||
ArrayType_EDIT
|
||||
: 'ARRAY' '<' AnyCursor GreaterThanOrError
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| 'ARRAY' '<' ColumnDataType_EDIT GreaterThanOrError
|
||||
;
|
||||
|
||||
MapType
|
||||
: 'MAP' '<' PrimitiveType ',' ColumnDataType '>'
|
||||
;
|
||||
|
||||
MapType_INVALID
|
||||
: 'MAP' '<' '>'
|
||||
;
|
||||
|
||||
MapType_EDIT
|
||||
: 'MAP' '<' PrimitiveType ',' ColumnDataType_EDIT GreaterThanOrError
|
||||
| 'MAP' '<' AnyCursor GreaterThanOrError
|
||||
{
|
||||
parser.suggestKeywords(parser.getTypeKeywords());
|
||||
}
|
||||
| 'MAP' '<' PrimitiveType ',' AnyCursor GreaterThanOrError
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| 'MAP' '<' ',' AnyCursor GreaterThanOrError
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
;
|
||||
|
||||
StructType
|
||||
: 'STRUCT' '<' StructDefinitionList '>'
|
||||
;
|
||||
|
||||
StructType_INVALID
|
||||
: 'STRUCT' '<' '>'
|
||||
;
|
||||
|
||||
StructType_EDIT
|
||||
: 'STRUCT' '<' StructDefinitionList_EDIT GreaterThanOrError
|
||||
;
|
||||
|
||||
StructDefinitionList
|
||||
: StructDefinition
|
||||
| StructDefinitionList ',' StructDefinition
|
||||
;
|
||||
|
||||
StructDefinitionList_EDIT
|
||||
: StructDefinition_EDIT
|
||||
| StructDefinition_EDIT Commas
|
||||
| StructDefinition_EDIT Commas StructDefinitionList
|
||||
| StructDefinitionList ',' StructDefinition_EDIT
|
||||
| StructDefinitionList ',' StructDefinition_EDIT Commas StructDefinitionList
|
||||
;
|
||||
|
||||
StructDefinition
|
||||
: RegularOrBacktickedIdentifier ':' ColumnDataType OptionalComment
|
||||
;
|
||||
|
||||
StructDefinition_EDIT
|
||||
: Commas RegularOrBacktickedIdentifier ':' ColumnDataType 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['COMMENT']);
|
||||
}
|
||||
| Commas RegularOrBacktickedIdentifier ':' AnyCursor
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| Commas RegularOrBacktickedIdentifier ':' ColumnDataType_EDIT
|
||||
| RegularOrBacktickedIdentifier ':' ColumnDataType 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['COMMENT']);
|
||||
}
|
||||
| RegularOrBacktickedIdentifier ':' AnyCursor
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| RegularOrBacktickedIdentifier ':' ColumnDataType_EDIT
|
||||
;
|
||||
|
||||
ColumnDataTypeList
|
||||
: ColumnDataType
|
||||
| ColumnDataTypeList ',' ColumnDataType
|
||||
;
|
||||
|
||||
ColumnDataTypeList_EDIT
|
||||
: ColumnDataTypeListInner_EDIT
|
||||
| ColumnDataTypeListInner_EDIT Commas
|
||||
| ColumnDataTypeList ',' ColumnDataTypeListInner_EDIT
|
||||
| ColumnDataTypeListInner_EDIT Commas ColumnDataTypeList
|
||||
| ColumnDataTypeList ',' ColumnDataTypeListInner_EDIT Commas ColumnDataTypeList
|
||||
;
|
||||
|
||||
ColumnDataTypeListInner_EDIT
|
||||
: Commas AnyCursor
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| Commas ColumnDataType_EDIT
|
||||
| AnyCursor
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| ColumnDataType_EDIT
|
||||
;
|
||||
|
||||
GreaterThanOrError
|
||||
: '>'
|
||||
| error
|
||||
;
|
||||
|
||||
OptionalPartitionedBy
|
||||
:
|
||||
| PartitionedBy
|
||||
;
|
||||
|
||||
PartitionedBy
|
||||
: 'PARTITION' 'BY' RangeClause
|
||||
;
|
||||
|
||||
PartitionedBy_EDIT
|
||||
: 'PARTITION' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['BY']);
|
||||
}
|
||||
| 'PARTITION' 'BY' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['RANGE']);
|
||||
}
|
||||
| 'PARTITION' 'BY' RangeClause_EDIT
|
||||
;
|
||||
|
||||
RangeClause
|
||||
: 'RANGE' ParenthesizedColumnList ParenthesizedPartitionValuesList
|
||||
;
|
||||
|
||||
RangeClause_EDIT
|
||||
: 'RANGE' 'CURSOR'
|
||||
| 'RANGE' ParenthesizedColumnList_EDIT
|
||||
| 'RANGE' ParenthesizedColumnList 'CURSOR'
|
||||
| 'RANGE' ParenthesizedColumnList ParenthesizedPartitionValuesList_EDIT
|
||||
| 'RANGE' ParenthesizedColumnList_EDIT ParenthesizedPartitionValuesList
|
||||
;
|
||||
|
||||
ParenthesizedPartitionValuesList
|
||||
: '(' PartitionValueList ')'
|
||||
;
|
||||
|
||||
ParenthesizedPartitionValuesList_EDIT
|
||||
: '(' 'CURSOR' RightParenthesisOrError
|
||||
{
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
|'(' PartitionValueList_EDIT RightParenthesisOrError
|
||||
;
|
||||
|
||||
PartitionValueList
|
||||
: PartitionValue
|
||||
| PartitionValueList ',' PartitionValue
|
||||
;
|
||||
|
||||
PartitionValueList_EDIT
|
||||
: PartitionValue_EDIT
|
||||
| PartitionValueList ',' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
| PartitionValueList ',' 'CURSOR' ',' PartitionValueList
|
||||
{
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
| PartitionValueList ',' PartitionValue_EDIT
|
||||
| PartitionValueList ',' PartitionValue_EDIT ',' PartitionValueList
|
||||
;
|
||||
|
||||
PartitionValue
|
||||
: 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' LessThanOrEqualTo ValueExpression
|
||||
| 'PARTITION' 'VALUES' LessThanOrEqualTo ValueExpression
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES'
|
||||
;
|
||||
|
||||
PartitionValue_EDIT
|
||||
: 'PARTITION' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['VALUE', 'VALUES']);
|
||||
}
|
||||
| 'PARTITION' ValueExpression_EDIT
|
||||
{
|
||||
if ($2.endsWithLessThanOrEqual) {
|
||||
parser.suggestKeywords(['VALUES']);
|
||||
}
|
||||
}
|
||||
| 'PARTITION' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['<', '<=']);
|
||||
}
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['VALUES']);
|
||||
}
|
||||
| 'PARTITION' ValueExpression_EDIT LessThanOrEqualTo 'VALUES'
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['<', '<=']);
|
||||
}
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' LessThanOrEqualTo 'CURSOR'
|
||||
{
|
||||
parser.suggestFunctions();
|
||||
}
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' LessThanOrEqualTo ValueExpression_EDIT
|
||||
| 'PARTITION' 'VALUES' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['<', '<=']);
|
||||
}
|
||||
| 'PARTITION' 'VALUES' LessThanOrEqualTo 'CURSOR'
|
||||
{
|
||||
parser.suggestFunctions();
|
||||
}
|
||||
| 'PARTITION' 'VALUES' LessThanOrEqualTo ValueExpression_EDIT
|
||||
;
|
||||
|
||||
LessThanOrEqualTo
|
||||
: '<'
|
||||
| 'COMPARISON_OPERATOR' // This is fine for autocompletion
|
||||
;
|
||||
|
||||
OptionalAsSelectStatement
|
||||
:
|
||||
| 'AS' CommitLocations QuerySpecification
|
||||
;
|
||||
|
||||
OptionalAsSelectStatement_EDIT
|
||||
: 'AS' CommitLocations 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
| 'AS' CommitLocations QuerySpecification_EDIT
|
||||
;
|
||||
|
||||
CommitLocations
|
||||
: /* empty */
|
||||
{
|
||||
parser.commitLocations();
|
||||
}
|
||||
;
|
||||
|
||||
ViewDefinition
|
||||
: 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'AS' QuerySpecification
|
||||
;
|
||||
|
||||
ViewDefinition_EDIT
|
||||
: 'CREATE' 'VIEW' OptionalIfNotExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists 'CURSOR' SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'AS' QuerySpecification
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists_EDIT
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedViewColumnList_EDIT OptionalComment
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'CURSOR'
|
||||
{
|
||||
var keywords = [{value: 'AS', weight: 1 }];
|
||||
if (!$6) {
|
||||
keywords.push({ value: 'COMMENT', weight: 3 });
|
||||
}
|
||||
parser.suggestKeywords(keywords);
|
||||
}
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'AS' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'AS' QuerySpecification_EDIT
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier_EDIT OptionalParenthesizedViewColumnList OptionalComment 'AS' QuerySpecification
|
||||
;
|
||||
|
||||
OptionalParenthesizedViewColumnList
|
||||
:
|
||||
| ParenthesizedViewColumnList
|
||||
;
|
||||
|
||||
ParenthesizedViewColumnList
|
||||
: '(' ViewColumnList ')'
|
||||
;
|
||||
|
||||
ParenthesizedViewColumnList_EDIT
|
||||
: '(' ViewColumnList_EDIT RightParenthesisOrError
|
||||
{
|
||||
if (!$2) {
|
||||
parser.suggestKeywords(['COMMENT']);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
ViewColumnList
|
||||
: ColumnReference OptionalComment
|
||||
| ViewColumnList ',' ColumnReference OptionalComment
|
||||
;
|
||||
|
||||
ViewColumnList_EDIT
|
||||
: ColumnReference OptionalComment 'CURSOR' -> $2
|
||||
| ColumnReference OptionalComment 'CURSOR' ',' ViewColumnList -> $2
|
||||
| ViewColumnList ',' ColumnReference OptionalComment 'CURSOR' -> $4
|
||||
| ViewColumnList ',' ColumnReference OptionalComment 'CURSOR' ',' ViewColumnList -> $4
|
||||
;
|
||||
|
||||
RoleDefinition
|
||||
: 'CREATE' 'ROLE' RegularIdentifier
|
||||
;
|
184
src/jison/sql/flink/sql_drop.jison
Normal file
184
src/jison/sql/flink/sql_drop.jison
Normal file
@ -0,0 +1,184 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: DropStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: DropStatement_EDIT
|
||||
;
|
||||
|
||||
DropStatement
|
||||
: DropDatabaseStatement
|
||||
| DropRoleStatement
|
||||
| DropTableStatement
|
||||
| DropViewStatement
|
||||
| TruncateTableStatement
|
||||
;
|
||||
|
||||
DropStatement_EDIT
|
||||
: DropDatabaseStatement_EDIT
|
||||
| DropTableStatement_EDIT
|
||||
| DropViewStatement_EDIT
|
||||
| TruncateTableStatement_EDIT
|
||||
| 'DROP' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['DATABASE', 'ROLE', 'SCHEMA', 'TABLE', 'VIEW']);
|
||||
}
|
||||
;
|
||||
|
||||
DropDatabaseStatement
|
||||
: 'DROP' DatabaseOrSchema OptionalIfExists RegularOrBacktickedIdentifier OptionalCascade
|
||||
;
|
||||
|
||||
DropDatabaseStatement_EDIT
|
||||
: 'DROP' DatabaseOrSchema OptionalIfExists
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists_EDIT
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
parser.suggestDatabases();
|
||||
}
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists RegularOrBacktickedIdentifier 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['CASCADE']);
|
||||
}
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists_EDIT RegularOrBacktickedIdentifier OptionalCascade
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists 'CURSOR' RegularOrBacktickedIdentifier OptionalCascade
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
;
|
||||
DropRoleStatement
|
||||
: 'DROP' 'ROLE' RegularIdentifier
|
||||
;
|
||||
|
||||
DropTableStatement
|
||||
: 'DROP' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier OptionalPurge
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
DropTableStatement_EDIT
|
||||
: 'DROP' 'TABLE' OptionalIfExists_EDIT
|
||||
| 'DROP' 'TABLE' OptionalIfExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
parser.suggestTables({ onlyTables: true });
|
||||
parser.suggestDatabases({
|
||||
appendDot: true
|
||||
});
|
||||
}
|
||||
| 'DROP' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier_EDIT OptionalPurge
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyTables = true;
|
||||
}
|
||||
}
|
||||
| 'DROP' 'TABLE' OptionalIfExists_EDIT SchemaQualifiedTableIdentifier OptionalPurge
|
||||
| 'DROP' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier OptionalPurge 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
if (!$5) {
|
||||
parser.suggestKeywords(['PURGE']);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
OptionalPurge
|
||||
:
|
||||
| 'PURGE'
|
||||
;
|
||||
|
||||
DropViewStatement
|
||||
: 'DROP' 'VIEW' OptionalIfExists SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
DropViewStatement_EDIT
|
||||
: 'DROP' 'VIEW' OptionalIfExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
parser.suggestTables({ onlyViews: true });
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'DROP' 'VIEW' OptionalIfExists 'CURSOR' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($5);
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'DROP' 'VIEW' OptionalIfExists_EDIT
|
||||
| 'DROP' 'VIEW' OptionalIfExists_EDIT SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
| 'DROP' 'VIEW' OptionalIfExists SchemaQualifiedTableIdentifier_EDIT
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyViews = true;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
TruncateTableStatement
|
||||
: 'TRUNCATE' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
TruncateTableStatement_EDIT
|
||||
: 'TRUNCATE' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['TABLE']);
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists_EDIT
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier_EDIT
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists 'CURSOR' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists_EDIT SchemaQualifiedTableIdentifier OptionalPartitionSpec
|
||||
;
|
132
src/jison/sql/flink/sql_error.jison
Normal file
132
src/jison/sql/flink/sql_error.jison
Normal file
@ -0,0 +1,132 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
SqlStatements
|
||||
: error
|
||||
| NonStartingToken error // Having just ': error' does not work for some reason, jison bug?
|
||||
;
|
||||
|
||||
SqlStatement_EDIT
|
||||
: AnyCursor error
|
||||
{
|
||||
parser.suggestDdlAndDmlKeywords();
|
||||
}
|
||||
;
|
||||
|
||||
SelectStatement
|
||||
: 'SELECT' OptionalAllOrDistinct SelectList_ERROR TableExpression
|
||||
| 'SELECT' OptionalAllOrDistinct SelectList TableExpression_ERROR
|
||||
;
|
||||
|
||||
SelectStatement_EDIT
|
||||
: 'SELECT' OptionalAllOrDistinct SelectList_ERROR_EDIT TableExpression
|
||||
{
|
||||
parser.selectListNoTableSuggest($3, $2);
|
||||
}
|
||||
| 'SELECT' OptionalAllOrDistinct SelectList_ERROR TableExpression_EDIT
|
||||
;
|
||||
|
||||
SelectList_ERROR
|
||||
: ErrorList
|
||||
| SelectList ',' ErrorList
|
||||
| ErrorList ',' SelectList ',' ErrorList
|
||||
| ErrorList ',' SelectList
|
||||
| SelectList ',' ErrorList ',' SelectList
|
||||
;
|
||||
|
||||
SelectList_ERROR_EDIT
|
||||
: ErrorList ',' SelectList_EDIT -> $3
|
||||
| SelectList ',' ErrorList ',' SelectList_EDIT -> $5
|
||||
| ErrorList ',' SelectList ',' ErrorList ',' SelectList_EDIT -> $7
|
||||
| ErrorList ',' AnyCursor
|
||||
{
|
||||
$$ = { cursorAtStart : false, suggestFunctions: true, suggestColumns: true, suggestAggregateFunctions: true };
|
||||
}
|
||||
| SelectList ',' ErrorList ',' AnyCursor
|
||||
{
|
||||
$$ = { cursorAtStart : false, suggestFunctions: true, suggestColumns: true, suggestAggregateFunctions: true };
|
||||
}
|
||||
| ErrorList ',' SelectList ',' Errors ',' AnyCursor
|
||||
{
|
||||
$$ = { cursorAtStart : true, suggestFunctions: true, suggestColumns: true, suggestAggregateFunctions: true };
|
||||
}
|
||||
;
|
||||
|
||||
SetSpecification
|
||||
: 'SET' SetOption '=' error
|
||||
;
|
||||
|
||||
ErrorList
|
||||
: error
|
||||
| Errors ',' error
|
||||
;
|
||||
|
||||
JoinType_EDIT
|
||||
: 'FULL' 'CURSOR' error
|
||||
{
|
||||
parser.suggestKeywords(['JOIN', 'OUTER JOIN']);
|
||||
}
|
||||
| 'LEFT' 'CURSOR' error
|
||||
{
|
||||
parser.suggestKeywords(['JOIN', 'OUTER JOIN']);
|
||||
}
|
||||
| 'RIGHT' 'CURSOR' error
|
||||
{
|
||||
parser.suggestKeywords(['JOIN', 'OUTER JOIN']);
|
||||
}
|
||||
;
|
||||
|
||||
OptionalSelectConditions_EDIT
|
||||
: WhereClause error 'CURSOR' OptionalGroupByClause OptionalHavingClause OptionalOrderByClause OptionalLimitClause
|
||||
{
|
||||
$$ = {
|
||||
suggestKeywords: parser.getKeywordsForOptionalsLR([$4, $5, $6, $7], [{ value: 'GROUP BY', weight: 8 }, { value: 'HAVING', weight: 7 }, { value: 'ORDER BY', weight: 5 }, { value: 'LIMIT', weight: 3 }], [true, true, true, true]),
|
||||
cursorAtEnd: !$4 && !$5 && !$6 && !$7
|
||||
};
|
||||
}
|
||||
| OptionalWhereClause OptionalGroupByClause HavingClause error 'CURSOR' OptionalOrderByClause OptionalLimitClause
|
||||
{
|
||||
$$ = {
|
||||
suggestKeywords: parser.getKeywordsForOptionalsLR([$6, $7], [{ value: 'ORDER BY', weight: 5 }, { value: 'LIMIT', weight: 3 }], [true, true]),
|
||||
cursorAtEnd: !$6 && !$7
|
||||
}
|
||||
}
|
||||
| OptionalWhereClause OptionalGroupByClause OptionalHavingClause OrderByClause error 'CURSOR' OptionalLimitClause
|
||||
{
|
||||
$$ = {
|
||||
suggestKeywords: parser.getKeywordsForOptionalsLR([$7], [{ value: 'LIMIT', weight: 3 }], [true]),
|
||||
cursorAtEnd: !$7
|
||||
}
|
||||
}
|
||||
| OptionalWhereClause OptionalGroupByClause OptionalHavingClause OptionalOrderByClause LimitClause error 'CURSOR'
|
||||
;
|
||||
|
||||
OptionalSelectConditions_EDIT
|
||||
: WhereClause error GroupByClause_EDIT OptionalHavingClause OptionalOrderByClause OptionalLimitClause
|
||||
| WhereClause error OptionalGroupByClause HavingClause_EDIT OptionalOrderByClause OptionalLimitClause
|
||||
| WhereClause error OptionalGroupByClause OptionalHavingClause OrderByClause_EDIT OptionalLimitClause
|
||||
| WhereClause error OptionalGroupByClause OptionalHavingClause OptionalOrderByClause LimitClause_EDIT
|
||||
| OptionalWhereClause GroupByClause error HavingClause_EDIT OptionalOrderByClause OptionalLimitClause
|
||||
| OptionalWhereClause GroupByClause error OptionalHavingClause OrderByClause_EDIT OptionalLimitClause
|
||||
| OptionalWhereClause GroupByClause error OptionalHavingClause OptionalOrderByClause LimitClause_EDIT
|
||||
| OptionalWhereClause OptionalGroupByClause HavingClause error OrderByClause_EDIT OptionalLimitClause
|
||||
| OptionalWhereClause OptionalGroupByClause HavingClause error OptionalOrderByClause LimitClause_EDIT
|
||||
| OptionalWhereClause OptionalGroupByClause OptionalHavingClause OrderByClause error LimitClause_EDIT
|
||||
;
|
||||
|
||||
DatabaseDefinition_EDIT
|
||||
: 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals_EDIT error
|
||||
;
|
72
src/jison/sql/flink/sql_insert.jison
Normal file
72
src/jison/sql/flink/sql_insert.jison
Normal file
@ -0,0 +1,72 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataManipulation
|
||||
: InsertStatement
|
||||
;
|
||||
|
||||
InsertStatement
|
||||
: InsertValuesStatement
|
||||
;
|
||||
|
||||
DataManipulation_EDIT
|
||||
: InsertValuesStatement_EDIT
|
||||
;
|
||||
|
||||
InsertValuesStatement
|
||||
: 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier 'VALUES' InsertValuesList
|
||||
{
|
||||
$4.owner = 'insert';
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
InsertValuesStatement_EDIT
|
||||
: 'INSERT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['INTO']);
|
||||
}
|
||||
| 'INSERT' 'INTO' OptionalTable 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['TABLE']);
|
||||
}
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier_EDIT
|
||||
| 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier 'CURSOR'
|
||||
{
|
||||
$4.owner = 'insert';
|
||||
parser.addTablePrimary($4);
|
||||
parser.suggestKeywords(['VALUES']);
|
||||
}
|
||||
| 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier_EDIT 'VALUES' InsertValuesList
|
||||
;
|
||||
|
||||
InsertValuesList
|
||||
: ParenthesizedRowValuesList
|
||||
| RowValuesList ',' ParenthesizedRowValuesList
|
||||
;
|
||||
|
||||
ParenthesizedRowValuesList
|
||||
: '(' InValueList ')'
|
||||
;
|
||||
|
||||
OptionalTable
|
||||
:
|
||||
| 'TABLE'
|
||||
;
|
37
src/jison/sql/flink/sql_list.jison
Normal file
37
src/jison/sql/flink/sql_list.jison
Normal file
@ -0,0 +1,37 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: 'LIST' ListStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: ListStatement_EDIT
|
||||
;
|
||||
|
||||
ListStatement
|
||||
: 'TABLES'
|
||||
| 'STREAMS'
|
||||
| 'TOPICS'
|
||||
;
|
||||
|
||||
|
||||
ListStatement_EDIT
|
||||
: 'LIST' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['TABLES', 'STREAMS', 'TOPICS']);
|
||||
}
|
||||
;
|
2762
src/jison/sql/flink/sql_main.jison
Normal file
2762
src/jison/sql/flink/sql_main.jison
Normal file
File diff suppressed because it is too large
Load Diff
46
src/jison/sql/flink/sql_set.jison
Normal file
46
src/jison/sql/flink/sql_set.jison
Normal file
@ -0,0 +1,46 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: SetSpecification
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: 'SET' 'CURSOR'
|
||||
{
|
||||
parser.suggestSetOptions();
|
||||
}
|
||||
;
|
||||
|
||||
SetSpecification
|
||||
: 'SET' SetOption '=' SetValue
|
||||
| 'SET' 'ALL'
|
||||
;
|
||||
|
||||
SetOption
|
||||
: RegularIdentifier
|
||||
| SetOption '.' RegularIdentifier
|
||||
;
|
||||
|
||||
SetValue
|
||||
: RegularIdentifier
|
||||
| SignedInteger
|
||||
| SignedInteger RegularIdentifier
|
||||
| QuotedValue
|
||||
| 'TRUE'
|
||||
| 'FALSE'
|
||||
| 'NULL'
|
||||
;
|
39
src/jison/sql/flink/sql_show.jison
Normal file
39
src/jison/sql/flink/sql_show.jison
Normal file
@ -0,0 +1,39 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: 'SHOW' ShowStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: ShowStatement_EDIT
|
||||
;
|
||||
|
||||
ShowStatement
|
||||
: 'TABLES'
|
||||
| 'STREAMS'
|
||||
| 'TOPICS'
|
||||
| 'QUERIES'
|
||||
| 'PROPERTIES'
|
||||
;
|
||||
|
||||
|
||||
ShowStatement_EDIT
|
||||
: 'SHOW' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['TABLES', 'STREAMS', 'TOPICS', 'QUERIES', 'PROPERTIES']);
|
||||
}
|
||||
;
|
839
src/jison/sql/flink/sql_valueExpression.jison
Normal file
839
src/jison/sql/flink/sql_valueExpression.jison
Normal file
@ -0,0 +1,839 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
ValueExpression
|
||||
: 'NOT' ValueExpression
|
||||
{
|
||||
// verifyType($2, 'BOOLEAN');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| '!' ValueExpression
|
||||
{
|
||||
// verifyType($2, 'BOOLEAN');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| '~' ValueExpression -> $2
|
||||
| '-' ValueExpression %prec NEGATION
|
||||
{
|
||||
// verifyType($2, 'NUMBER');
|
||||
$$ = $2;
|
||||
$2.types = ['NUMBER'];
|
||||
}
|
||||
| ValueExpression 'IS' OptionalNot 'NULL' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IS' OptionalNot 'TRUE' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IS' OptionalNot 'FALSE' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IS' OptionalNot 'DISTINCT' 'FROM' ValueExpression -> { types: [ 'BOOLEAN' ] }
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'NOT' ValueExpression_EDIT -> { types: [ 'BOOLEAN' ], suggestFilters: $2.suggestFilters }
|
||||
| 'NOT' 'CURSOR'
|
||||
{
|
||||
parser.suggestFunctions();
|
||||
parser.suggestColumns();
|
||||
parser.suggestKeywords(['EXISTS']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| '!' ValueExpression_EDIT -> { types: [ 'BOOLEAN' ], suggestFilters: $2.suggestFilters }
|
||||
| '!' AnyCursor
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'BOOLEAN' ] });
|
||||
parser.suggestColumns({ types: [ 'BOOLEAN' ] });
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| '~' ValueExpression_EDIT -> { types: [ 'T' ], suggestFilters: $2.suggestFilters }
|
||||
| '~' 'PARTIAL_CURSOR'
|
||||
{
|
||||
parser.suggestFunctions();
|
||||
parser.suggestColumns();
|
||||
$$ = { types: [ 'T' ] };
|
||||
}
|
||||
| '-' ValueExpression_EDIT %prec NEGATION
|
||||
{
|
||||
if (!$2.typeSet) {
|
||||
parser.applyTypeToSuggestions('NUMBER');
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $2.suggestFilters };
|
||||
}
|
||||
| '-' 'PARTIAL_CURSOR' %prec NEGATION
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'NUMBER' ] });
|
||||
parser.suggestColumns({ types: [ 'NUMBER' ] });
|
||||
$$ = { types: [ 'NUMBER' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['FALSE', 'NOT NULL', 'NOT TRUE', 'NOT FALSE', 'NULL', 'TRUE']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'NOT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['FALSE', 'NULL', 'TRUE']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' OptionalNot 'DISTINCT' 'CURSOR'
|
||||
{
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'CURSOR' 'NULL'
|
||||
{
|
||||
parser.suggestKeywords(['NOT']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'CURSOR' 'FALSE'
|
||||
{
|
||||
parser.suggestKeywords(['NOT']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'CURSOR' 'TRUE'
|
||||
{
|
||||
parser.suggestKeywords(['NOT']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' OptionalNot 'DISTINCT' 'FROM' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $3 ? 'IS NOT DISTINCT FROM' : 'IS DISTINCT FROM');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' OptionalNot 'DISTINCT' 'FROM' ValueExpression_EDIT
|
||||
{
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $6.suggestFilters }
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ EXISTS and parenthesized ------------------
|
||||
ValueExpression
|
||||
: 'EXISTS' TableSubQuery
|
||||
{
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
// clear correlated flag after completed sub-query (set by lexer)
|
||||
parser.yy.correlatedSubQuery = false;
|
||||
}
|
||||
| '(' ValueExpression ')' -> $2
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'EXISTS' TableSubQuery_EDIT -> { types: [ 'BOOLEAN' ] }
|
||||
| '(' ValueExpression_EDIT RightParenthesisOrError
|
||||
{
|
||||
$$ = $2;
|
||||
}
|
||||
| '(' 'CURSOR' RightParenthesisOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { types: ['T'], typeSet: true };
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ COMPARISON ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression '=' ValueExpression
|
||||
{
|
||||
parser.addColRefToVariableIfExists($1, $3);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression '<' ValueExpression
|
||||
{
|
||||
parser.addColRefToVariableIfExists($1, $3);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression '>' ValueExpression
|
||||
{
|
||||
parser.addColRefToVariableIfExists($1, $3);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'COMPARISON_OPERATOR' ValueExpression
|
||||
{
|
||||
parser.addColRefToVariableIfExists($1, $3);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'CURSOR' '=' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest($3, $2);
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' '<' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest($3, $2);
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' '>' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest($3, $2);
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' 'COMPARISON_OPERATOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest($3, $2);
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression_EDIT '=' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT '<' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT '>' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT 'COMPARISON_OPERATOR' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression '=' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression '<' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ] , typeSet: true, endsWithLessThanOrEqual: true };
|
||||
}
|
||||
| ValueExpression '>' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'COMPARISON_OPERATOR' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, endsWithLessThanOrEqual: $2 === '<=' };
|
||||
}
|
||||
| ValueExpression '=' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
| ValueExpression '<' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
| ValueExpression '>' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
| ValueExpression 'COMPARISON_OPERATOR' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
// ------------------ IN ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression 'NOT' 'IN' '(' TableSubQueryInner ')' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'NOT' 'IN' '(' ValueExpressionList ')' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IN' '(' TableSubQueryInner ')' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IN' '(' ValueExpressionList ')' -> { types: [ 'BOOLEAN' ] }
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: ValueExpression 'NOT' 'IN' ValueExpressionInSecondPart_EDIT
|
||||
{
|
||||
if ($4.inValueEdit) {
|
||||
parser.valueExpressionSuggest($1, $2 + ' ' + $3);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
}
|
||||
if ($4.cursorAtStart) {
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'IN' ValueExpressionInSecondPart_EDIT
|
||||
{
|
||||
if ($3.inValueEdit) {
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
}
|
||||
if ($3.cursorAtStart) {
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression_EDIT 'NOT' 'IN' '(' ValueExpressionList RightParenthesisOrError -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression_EDIT 'NOT' 'IN' '(' TableSubQueryInner RightParenthesisOrError -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression_EDIT 'IN' '(' ValueExpressionList RightParenthesisOrError -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression_EDIT 'IN' '(' TableSubQueryInner RightParenthesisOrError -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
;
|
||||
|
||||
ValueExpressionInSecondPart_EDIT
|
||||
: '(' TableSubQueryInner_EDIT RightParenthesisOrError
|
||||
| '(' ValueExpressionList_EDIT RightParenthesisOrError -> { inValueEdit: true }
|
||||
| '(' AnyCursor RightParenthesisOrError -> { inValueEdit: true, cursorAtStart: true }
|
||||
;
|
||||
|
||||
// ------------------ BETWEEN ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression 'NOT' 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression -> { types: [ 'BOOLEAN' ] }
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: ValueExpression_EDIT 'NOT' 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression
|
||||
{
|
||||
if ($4.types[0] === $6.types[0] && !$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($4.types);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' ValueExpression_EDIT 'BETWEEN_AND' ValueExpression
|
||||
{
|
||||
if ($1.types[0] === $6.types[0] && !$4.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $4.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression_EDIT
|
||||
{
|
||||
if ($1.types[0] === $4.types[0] && !$6.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $6.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' ValueExpression 'BETWEEN_AND' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $5);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($4, ['AND']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2 + ' ' + $3);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression_EDIT 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression
|
||||
{
|
||||
if ($1.types[0] === $3.types[0] && !$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types)
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' ValueExpression_EDIT 'BETWEEN_AND' ValueExpression
|
||||
{
|
||||
if ($1.types[0] === $3.types[0] && !$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types)
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression_EDIT
|
||||
{
|
||||
if ($1.types[0] === $3.types[0] && !$5.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types)
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $5.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' ValueExpression 'BETWEEN_AND' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $4);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($3, ['AND']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ BOOLEAN ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression 'OR' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'BOOLEAN');
|
||||
// verifyType($3, 'BOOLEAN');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'AND' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'BOOLEAN');
|
||||
// verifyType($3, 'BOOLEAN');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'CURSOR' 'OR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, suggestFilters: true };
|
||||
}
|
||||
| ValueExpression_EDIT 'OR' ValueExpression
|
||||
{
|
||||
parser.addColRefIfExists($3);
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression 'OR' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, suggestFilters: true };
|
||||
}
|
||||
| ValueExpression 'OR' ValueExpression_EDIT
|
||||
{
|
||||
parser.addColRefIfExists($1);
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
| 'CURSOR' 'AND' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, suggestFilters: true };
|
||||
}
|
||||
| ValueExpression_EDIT 'AND' ValueExpression
|
||||
{
|
||||
parser.addColRefIfExists($3);
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression 'AND' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, suggestFilters: true };
|
||||
}
|
||||
| ValueExpression 'AND' ValueExpression_EDIT
|
||||
{
|
||||
parser.addColRefIfExists($1);
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ ARITHMETIC ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression '-' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'NUMBER');
|
||||
// verifyType($3, 'NUMBER');
|
||||
$$ = { types: [ 'NUMBER' ] };
|
||||
}
|
||||
| ValueExpression '*' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'NUMBER');
|
||||
// verifyType($3, 'NUMBER');
|
||||
$$ = { types: [ 'NUMBER' ] };
|
||||
}
|
||||
| ValueExpression 'ARITHMETIC_OPERATOR' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'NUMBER');
|
||||
// verifyType($3, 'NUMBER');
|
||||
$$ = { types: [ 'NUMBER' ] };
|
||||
}
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'CURSOR' '*' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions([ 'NUMBER' ]);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' 'ARITHMETIC_OPERATOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions([ 'NUMBER' ]);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression_EDIT '-' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT '*' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT 'ARITHMETIC_OPERATOR' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression '-' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression '*' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'ARITHMETIC_OPERATOR' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression '-' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $3.suggestFilters };
|
||||
}
|
||||
| ValueExpression '*' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $3.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'ARITHMETIC_OPERATOR' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $3.suggestFilters };
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ LIKE, RLIKE and REGEXP ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression LikeRightPart -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'NOT' LikeRightPart -> { types: [ 'BOOLEAN' ] }
|
||||
;
|
||||
|
||||
LikeRightPart
|
||||
: 'LIKE' ValueExpression -> { suggestKeywords: ['NOT'] }
|
||||
| 'RLIKE' ValueExpression -> { suggestKeywords: ['NOT'] }
|
||||
| 'REGEXP' ValueExpression -> { suggestKeywords: ['NOT'] }
|
||||
;
|
||||
|
||||
LikeRightPart_EDIT
|
||||
: 'LIKE' ValueExpression_EDIT
|
||||
| 'RLIKE' ValueExpression_EDIT
|
||||
| 'REGEXP' ValueExpression_EDIT
|
||||
| 'LIKE' PartialBacktickedOrCursor
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'STRING' ] });
|
||||
parser.suggestColumns({ types: [ 'STRING' ] });
|
||||
$$ = { types: ['BOOLEAN'] }
|
||||
}
|
||||
| 'RLIKE' PartialBacktickedOrCursor
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'STRING' ] });
|
||||
parser.suggestColumns({ types: [ 'STRING' ] });
|
||||
$$ = { types: ['BOOLEAN'] }
|
||||
}
|
||||
| 'REGEXP' PartialBacktickedOrCursor
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'STRING' ] });
|
||||
parser.suggestColumns({ types: [ 'STRING' ] });
|
||||
$$ = { types: ['BOOLEAN'] }
|
||||
}
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: ValueExpression_EDIT LikeRightPart -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression_EDIT 'NOT' LikeRightPart -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression LikeRightPart_EDIT -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'NOT' LikeRightPart_EDIT -> { types: [ 'BOOLEAN' ] }
|
||||
| 'CURSOR' LikeRightPart
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions([ 'STRING' ]);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' 'NOT' LikeRightPart
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2 + ' ' + $3);
|
||||
parser.applyTypeToSuggestions([ 'STRING' ]);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ CASE, WHEN, THEN ------------------
|
||||
|
||||
ValueExpression
|
||||
: 'CASE' CaseRightPart -> $2
|
||||
| 'CASE' ValueExpression CaseRightPart -> $3
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'CASE' CaseRightPart_EDIT -> $2
|
||||
| 'CASE' 'CURSOR' EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { types: [ 'T' ], typeSet: true };
|
||||
}
|
||||
| 'CASE' ValueExpression CaseRightPart_EDIT -> $3
|
||||
| 'CASE' ValueExpression 'CURSOR' EndOrError
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($2, ['WHEN']);
|
||||
$$ = { types: [ 'T' ], typeSet: true };
|
||||
}
|
||||
| 'CASE' ValueExpression_EDIT CaseRightPart
|
||||
{
|
||||
$$ = $3;
|
||||
$$.suggestFilters = $2.suggestFilters;
|
||||
}
|
||||
| 'CASE' ValueExpression_EDIT EndOrError -> { types: [ 'T' ], suggestFilters: $2.suggestFilters }
|
||||
| 'CASE' 'CURSOR' CaseRightPart -> { types: [ 'T' ] }
|
||||
;
|
||||
|
||||
CaseRightPart
|
||||
: CaseWhenThenList 'END' -> parser.findCaseType($1)
|
||||
| CaseWhenThenList 'ELSE' ValueExpression 'END'
|
||||
{
|
||||
$1.caseTypes.push($3);
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
;
|
||||
|
||||
CaseRightPart_EDIT
|
||||
: CaseWhenThenList_EDIT EndOrError -> parser.findCaseType($1)
|
||||
| CaseWhenThenList 'ELSE' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($3, ['END']);
|
||||
$1.caseTypes.push($3);
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| CaseWhenThenList_EDIT 'ELSE' ValueExpression EndOrError
|
||||
{
|
||||
$1.caseTypes.push($3);
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| CaseWhenThenList_EDIT 'ELSE' EndOrError -> parser.findCaseType($1)
|
||||
| CaseWhenThenList 'CURSOR' ValueExpression EndOrError
|
||||
{
|
||||
if ($4.toLowerCase() !== 'end') {
|
||||
parser.suggestValueExpressionKeywords($1, [{ value: 'END', weight: 3 }, { value: 'ELSE', weight: 2 }, { value: 'WHEN', weight: 1 }]);
|
||||
} else {
|
||||
parser.suggestValueExpressionKeywords($1, [{ value: 'ELSE', weight: 2 }, { value: 'WHEN', weight: 1 }]);
|
||||
}
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| CaseWhenThenList 'CURSOR' EndOrError
|
||||
{
|
||||
if ($3.toLowerCase() !== 'end') {
|
||||
parser.suggestValueExpressionKeywords($1, [{ value: 'END', weight: 3 }, { value: 'ELSE', weight: 2 }, { value: 'WHEN', weight: 1 }]);
|
||||
} else {
|
||||
parser.suggestValueExpressionKeywords($1, [{ value: 'ELSE', weight: 2 }, { value: 'WHEN', weight: 1 }]);
|
||||
}
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| CaseWhenThenList 'ELSE' ValueExpression_EDIT EndOrError
|
||||
{
|
||||
$1.caseTypes.push($3);
|
||||
$$ = parser.findCaseType($1);
|
||||
$$.suggestFilters = $3.suggestFilters
|
||||
}
|
||||
| CaseWhenThenList 'ELSE' 'CURSOR' EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| 'ELSE' 'CURSOR' EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { types: [ 'T' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' 'ELSE' ValueExpression EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = $3;
|
||||
}
|
||||
| 'CURSOR' 'ELSE' EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { types: [ 'T' ] };
|
||||
}
|
||||
;
|
||||
|
||||
EndOrError
|
||||
: 'END'
|
||||
| error
|
||||
;
|
||||
|
||||
CaseWhenThenList
|
||||
: CaseWhenThenListPartTwo -> { caseTypes: [ $1 ], lastType: $1 }
|
||||
| CaseWhenThenList CaseWhenThenListPartTwo
|
||||
{
|
||||
$1.caseTypes.push($2);
|
||||
$$ = { caseTypes: $1.caseTypes, lastType: $2 };
|
||||
}
|
||||
;
|
||||
|
||||
CaseWhenThenList_EDIT
|
||||
: CaseWhenThenListPartTwo_EDIT
|
||||
| CaseWhenThenList CaseWhenThenListPartTwo_EDIT
|
||||
| CaseWhenThenList CaseWhenThenListPartTwo_EDIT CaseWhenThenList
|
||||
| CaseWhenThenList 'CURSOR' CaseWhenThenList
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($1, ['WHEN']);
|
||||
}
|
||||
| CaseWhenThenListPartTwo_EDIT CaseWhenThenList -> $2
|
||||
;
|
||||
|
||||
CaseWhenThenListPartTwo
|
||||
: 'WHEN' ValueExpression 'THEN' ValueExpression -> $4
|
||||
;
|
||||
|
||||
CaseWhenThenListPartTwo_EDIT
|
||||
: 'WHEN' ValueExpression_EDIT -> { caseTypes: [{ types: ['T'] }], suggestFilters: $2.suggestFilters }
|
||||
| 'WHEN' ValueExpression_EDIT 'THEN' -> { caseTypes: [{ types: ['T'] }], suggestFilters: $2.suggestFilters }
|
||||
| 'WHEN' ValueExpression_EDIT 'THEN' ValueExpression -> { caseTypes: [$4], suggestFilters: $2.suggestFilters }
|
||||
| 'WHEN' ValueExpression 'THEN' ValueExpression_EDIT -> { caseTypes: [$4], suggestFilters: $4.suggestFilters }
|
||||
| 'WHEN' 'THEN' ValueExpression_EDIT -> { caseTypes: [$3], suggestFilters: $3.suggestFilters }
|
||||
| 'CURSOR' ValueExpression 'THEN'
|
||||
{
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'CURSOR' ValueExpression 'THEN' ValueExpression
|
||||
{
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { caseTypes: [$4] };
|
||||
}
|
||||
| 'CURSOR' 'THEN'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'CURSOR' 'THEN' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }], suggestFilters: true };
|
||||
}
|
||||
| 'WHEN' 'CURSOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['THEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }], suggestFilters: true };
|
||||
}
|
||||
| 'WHEN' 'CURSOR' 'THEN'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }], suggestFilters: true };
|
||||
}
|
||||
| 'WHEN' 'CURSOR' 'THEN' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [$4], suggestFilters: true };
|
||||
}
|
||||
| 'WHEN' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($2, ['THEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' ValueExpression 'CURSOR' ValueExpression
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($2, ['THEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' ValueExpression 'THEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' ValueExpression 'THEN' 'CURSOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' 'THEN' 'CURSOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' 'THEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
;
|
19
src/jison/sql/flink/syntax_footer.jison
Normal file
19
src/jison/sql/flink/syntax_footer.jison
Normal file
@ -0,0 +1,19 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%%
|
||||
|
||||
SqlParseSupport.initSyntaxParser(parser);
|
28
src/jison/sql/flink/syntax_header.jison
Normal file
28
src/jison/sql/flink/syntax_header.jison
Normal file
@ -0,0 +1,28 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%left 'AND' 'OR'
|
||||
%left 'BETWEEN'
|
||||
%left 'NOT' '!' '~'
|
||||
%left '=' '<' '>' 'COMPARISON_OPERATOR'
|
||||
%left '-' '*' 'ARITHMETIC_OPERATOR'
|
||||
|
||||
%left ';' ','
|
||||
%nonassoc 'IN' 'IS' 'LIKE' 'RLIKE' 'REGEXP' 'EXISTS' NEGATION
|
||||
|
||||
%start SqlSyntax
|
||||
|
||||
%%
|
19
src/jison/sql/generic/autocomplete_footer.jison
Normal file
19
src/jison/sql/generic/autocomplete_footer.jison
Normal file
@ -0,0 +1,19 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%%
|
||||
|
||||
SqlParseSupport.initSqlParser(parser);
|
29
src/jison/sql/generic/autocomplete_header.jison
Normal file
29
src/jison/sql/generic/autocomplete_header.jison
Normal file
@ -0,0 +1,29 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%left 'AND' 'OR'
|
||||
%left 'BETWEEN'
|
||||
%left 'NOT' '!' '~'
|
||||
%left '=' '<' '>' 'COMPARISON_OPERATOR'
|
||||
%left '-' '*' 'ARITHMETIC_OPERATOR'
|
||||
|
||||
%left ';' ','
|
||||
%nonassoc 'CURSOR' 'PARTIAL_CURSOR'
|
||||
%nonassoc 'IN' 'IS' 'LIKE' 'RLIKE' 'REGEXP' 'EXISTS' NEGATION
|
||||
|
||||
%start SqlAutocomplete
|
||||
|
||||
%%
|
226
src/jison/sql/generic/sql.jisonlex
Normal file
226
src/jison/sql/generic/sql.jisonlex
Normal file
@ -0,0 +1,226 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%options case-insensitive flex
|
||||
%s between
|
||||
%x hdfs doubleQuotedValue singleQuotedValue backtickedValue
|
||||
%%
|
||||
|
||||
\s { /* skip whitespace */ }
|
||||
'--'.* { /* skip comments */ }
|
||||
[/][*][^*]*[*]+([^/*][^*]*[*]+)*[/] { /* skip comments */ }
|
||||
|
||||
'\u2020' { parser.yy.partialCursor = false; parser.yy.cursorFound = yylloc; return 'CURSOR'; }
|
||||
'\u2021' { parser.yy.partialCursor = true; parser.yy.cursorFound = yylloc; return 'PARTIAL_CURSOR'; }
|
||||
|
||||
<between>'AND' { this.popState(); return 'BETWEEN_AND'; }
|
||||
|
||||
// Reserved Keywords
|
||||
'ALL' { return 'ALL'; }
|
||||
'ALTER' { parser.determineCase(yytext); parser.addStatementTypeLocation('ALTER', yylloc, yy.lexer.upcomingInput()); return 'ALTER'; }
|
||||
'AND' { return 'AND'; }
|
||||
'AS' { return 'AS'; }
|
||||
'ASC' { return 'ASC'; }
|
||||
'BETWEEN' { this.begin('between'); return 'BETWEEN'; }
|
||||
'BIGINT' { return 'BIGINT'; }
|
||||
'BOOLEAN' { return 'BOOLEAN'; }
|
||||
'BY' { return 'BY'; }
|
||||
'CASCADE' { return 'CASCADE'; }
|
||||
'CASE' { return 'CASE'; }
|
||||
'CHAR' { return 'CHAR'; }
|
||||
'COMMENT' { return 'COMMENT'; }
|
||||
'CREATE' { parser.determineCase(yytext); return 'CREATE'; }
|
||||
'CROSS' { return 'CROSS'; }
|
||||
'CURRENT' { return 'CURRENT'; }
|
||||
'DATABASE' { return 'DATABASE'; }
|
||||
'DECIMAL' { return 'DECIMAL'; }
|
||||
'DESC' { return 'DESC'; }
|
||||
'DISTINCT' { return 'DISTINCT'; }
|
||||
'DIV' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'DOUBLE' { return 'DOUBLE'; }
|
||||
'DROP' { parser.determineCase(yytext); parser.addStatementTypeLocation('DROP', yylloc, yy.lexer.upcomingInput()); return 'DROP'; }
|
||||
'ELSE' { return 'ELSE'; }
|
||||
'END' { return 'END'; }
|
||||
'EXISTS' { parser.yy.correlatedSubQuery = true; return 'EXISTS'; }
|
||||
'FALSE' { return 'FALSE'; }
|
||||
'FLOAT' { return 'FLOAT'; }
|
||||
'FOLLOWING' { return 'FOLLOWING'; }
|
||||
'FROM' { parser.determineCase(yytext); return 'FROM'; }
|
||||
'FULL' { return 'FULL'; }
|
||||
'GROUP' { return 'GROUP'; }
|
||||
'HAVING' { return 'HAVING'; }
|
||||
'IF' { return 'IF'; }
|
||||
'IN' { return 'IN'; }
|
||||
'INNER' { return 'INNER'; }
|
||||
'INSERT' { return 'INSERT'; }
|
||||
'INT' { return 'INT'; }
|
||||
'INTO' { return 'INTO'; }
|
||||
'IS' { return 'IS'; }
|
||||
'JOIN' { return 'JOIN'; }
|
||||
'LEFT' { return 'LEFT'; }
|
||||
'LIKE' { return 'LIKE'; }
|
||||
'LIMIT' { return 'LIMIT'; }
|
||||
'NOT' { return 'NOT'; }
|
||||
'NULL' { return 'NULL'; }
|
||||
'ON' { return 'ON'; }
|
||||
'OPTION' { return 'OPTION'; }
|
||||
'OR' { return 'OR'; }
|
||||
'ORDER' { return 'ORDER'; }
|
||||
'OUTER' { return 'OUTER'; }
|
||||
'PARTITION' { return 'PARTITION'; }
|
||||
'PRECEDING' { return 'PRECEDING'; }
|
||||
'PURGE' { return 'PURGE'; }
|
||||
'RANGE' { return 'RANGE'; }
|
||||
'REGEXP' { return 'REGEXP'; }
|
||||
'RIGHT' { return 'RIGHT'; }
|
||||
'RLIKE' { return 'RLIKE'; }
|
||||
'ROW' { return 'ROW'; }
|
||||
'ROLE' { return 'ROLE'; }
|
||||
'ROWS' { return 'ROWS'; }
|
||||
'SCHEMA' { return 'SCHEMA'; }
|
||||
'SELECT' { parser.determineCase(yytext); parser.addStatementTypeLocation('SELECT', yylloc); return 'SELECT'; }
|
||||
'SEMI' { return 'SEMI'; }
|
||||
'SET' { parser.determineCase(yytext); parser.addStatementTypeLocation('SET', yylloc); return 'SET'; }
|
||||
'SHOW' { parser.determineCase(yytext); parser.addStatementTypeLocation('SHOW', yylloc); return 'SHOW'; }
|
||||
'SMALLINT' { return 'SMALLINT'; }
|
||||
'STRING' { return 'STRING'; }
|
||||
'TABLE' { return 'TABLE'; }
|
||||
'THEN' { return 'THEN'; }
|
||||
'TIMESTAMP' { return 'TIMESTAMP'; }
|
||||
'TINYINT' { return 'TINYINT'; }
|
||||
'TO' { return 'TO'; }
|
||||
'TRUE' { return 'TRUE'; }
|
||||
'TRUNCATE' { parser.determineCase(yytext); parser.addStatementTypeLocation('TRUNCATE', yylloc, yy.lexer.upcomingInput()); return 'TRUNCATE'; }
|
||||
'UNBOUNDED' { return 'UNBOUNDED'; }
|
||||
'UNION' { return 'UNION'; }
|
||||
'UPDATE' { parser.determineCase(yytext); return 'UPDATE'; }
|
||||
'USE' { parser.determineCase(yytext); parser.addStatementTypeLocation('USE', yylloc); return 'USE'; }
|
||||
'VALUES' { return 'VALUES'; }
|
||||
'VARCHAR' { return 'VARCHAR'; }
|
||||
'VIEW' { return 'VIEW'; }
|
||||
'WHEN' { return 'WHEN'; }
|
||||
'WHERE' { return 'WHERE'; }
|
||||
'WITH' { parser.determineCase(yytext); parser.addStatementTypeLocation('WITH', yylloc); return 'WITH'; }
|
||||
|
||||
// Non-reserved Keywords
|
||||
'OVER' { return 'OVER'; }
|
||||
'ROLE' { return 'ROLE'; }
|
||||
|
||||
// --- UDFs ---
|
||||
AVG\s*\( { yy.lexer.unput('('); yytext = 'avg'; parser.addFunctionLocation(yylloc, yytext); return 'AVG'; }
|
||||
CAST\s*\( { yy.lexer.unput('('); yytext = 'cast'; parser.addFunctionLocation(yylloc, yytext); return 'CAST'; }
|
||||
COUNT\s*\( { yy.lexer.unput('('); yytext = 'count'; parser.addFunctionLocation(yylloc, yytext); return 'COUNT'; }
|
||||
MAX\s*\( { yy.lexer.unput('('); yytext = 'max'; parser.addFunctionLocation(yylloc, yytext); return 'MAX'; }
|
||||
MIN\s*\( { yy.lexer.unput('('); yytext = 'min'; parser.addFunctionLocation(yylloc, yytext); return 'MIN'; }
|
||||
STDDEV_POP\s*\( { yy.lexer.unput('('); yytext = 'stddev_pop'; parser.addFunctionLocation(yylloc, yytext); return 'STDDEV_POP'; }
|
||||
STDDEV_SAMP\s*\( { yy.lexer.unput('('); yytext = 'stddev_samp'; parser.addFunctionLocation(yylloc, yytext); return 'STDDEV_SAMP'; }
|
||||
SUM\s*\( { yy.lexer.unput('('); yytext = 'sum'; parser.addFunctionLocation(yylloc, yytext); return 'SUM'; }
|
||||
VAR_POP\s*\( { yy.lexer.unput('('); yytext = 'var_pop'; parser.addFunctionLocation(yylloc, yytext); return 'VAR_POP'; }
|
||||
VAR_SAMP\s*\( { yy.lexer.unput('('); yytext = 'var_samp'; parser.addFunctionLocation(yylloc, yytext); return 'VAR_SAMP'; }
|
||||
VARIANCE\s*\( { yy.lexer.unput('('); yytext = 'variance'; parser.addFunctionLocation(yylloc, yytext); return 'VARIANCE'; }
|
||||
|
||||
// Analytical functions
|
||||
CUME_DIST\s*\( { yy.lexer.unput('('); yytext = 'cume_dist'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
DENSE_RANK\s*\( { yy.lexer.unput('('); yytext = 'dense_rank'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
FIRST_VALUE\s*\( { yy.lexer.unput('('); yytext = 'first_value'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
LAG\s*\( { yy.lexer.unput('('); yytext = 'lag'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
LAST_VALUE\s*\( { yy.lexer.unput('('); yytext = 'last_value'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
LEAD\s*\( { yy.lexer.unput('('); yytext = 'lead'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
RANK\s*\( { yy.lexer.unput('('); yytext = 'rank'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
ROW_NUMBER\s*\( { yy.lexer.unput('('); yytext = 'row_number'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
|
||||
[0-9]+ { return 'UNSIGNED_INTEGER'; }
|
||||
[0-9]+(?:[YSL]|BD)? { return 'UNSIGNED_INTEGER'; }
|
||||
[0-9]+E { return 'UNSIGNED_INTEGER_E'; }
|
||||
[A-Za-z0-9_]+ { return 'REGULAR_IDENTIFIER'; }
|
||||
|
||||
<hdfs>'\u2020' { parser.yy.cursorFound = true; return 'CURSOR'; }
|
||||
<hdfs>'\u2021' { parser.yy.cursorFound = true; return 'PARTIAL_CURSOR'; }
|
||||
<hdfs>\s+['"] { return 'HDFS_START_QUOTE'; }
|
||||
<hdfs>[^'"\u2020\u2021]+ { parser.addFileLocation(yylloc, yytext); return 'HDFS_PATH'; }
|
||||
<hdfs>['"] { this.popState(); return 'HDFS_END_QUOTE'; }
|
||||
<hdfs><<EOF>> { return 'EOF'; }
|
||||
|
||||
'&&' { return 'AND'; }
|
||||
'||' { return 'OR'; }
|
||||
|
||||
'=' { return '='; }
|
||||
'<' { return '<'; }
|
||||
'>' { return '>'; }
|
||||
'!=' { return 'COMPARISON_OPERATOR'; }
|
||||
'<=' { return 'COMPARISON_OPERATOR'; }
|
||||
'>=' { return 'COMPARISON_OPERATOR'; }
|
||||
'<>' { return 'COMPARISON_OPERATOR'; }
|
||||
'<=>' { return 'COMPARISON_OPERATOR'; }
|
||||
|
||||
'-' { return '-'; }
|
||||
'*' { return '*'; }
|
||||
'+' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'/' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'%' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'|' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'^' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'&' { return 'ARITHMETIC_OPERATOR'; }
|
||||
|
||||
',' { return ','; }
|
||||
'.' { return '.'; }
|
||||
':' { return ':'; }
|
||||
';' { return ';'; }
|
||||
'~' { return '~'; }
|
||||
'!' { return '!'; }
|
||||
|
||||
'(' { return '('; }
|
||||
')' { return ')'; }
|
||||
'[' { return '['; }
|
||||
']' { return ']'; }
|
||||
|
||||
\$\{[^}]*\} { return 'VARIABLE_REFERENCE'; }
|
||||
|
||||
\` { this.begin('backtickedValue'); return 'BACKTICK'; }
|
||||
<backtickedValue>[^`]+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '`')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<backtickedValue>\` { this.popState(); return 'BACKTICK'; }
|
||||
|
||||
\' { this.begin('singleQuotedValue'); return 'SINGLE_QUOTE'; }
|
||||
<singleQuotedValue>(?:\\\\|\\[']|[^'])+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '\'')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<singleQuotedValue>\' { this.popState(); return 'SINGLE_QUOTE'; }
|
||||
|
||||
\" { this.begin('doubleQuotedValue'); return 'DOUBLE_QUOTE'; }
|
||||
<doubleQuotedValue>(?:\\\\|\\["]|[^"])+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '"')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<doubleQuotedValue>\" { this.popState(); return 'DOUBLE_QUOTE'; }
|
||||
|
||||
<<EOF>> { return 'EOF'; }
|
||||
|
||||
. { /* To prevent console logging of unknown chars */ }
|
||||
<between>. { }
|
||||
<hdfs>. { }
|
||||
<backtickedValue>. { }
|
||||
<singleQuotedValue>. { }
|
||||
<doubleQuotedValue>. { }
|
109
src/jison/sql/generic/sql_alter.jison
Normal file
109
src/jison/sql/generic/sql_alter.jison
Normal file
@ -0,0 +1,109 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: AlterStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: AlterStatement_EDIT
|
||||
;
|
||||
|
||||
AlterStatement
|
||||
: AlterTable
|
||||
| AlterView
|
||||
;
|
||||
|
||||
AlterStatement_EDIT
|
||||
: AlterTable_EDIT
|
||||
| AlterView_EDIT
|
||||
| 'ALTER' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['TABLE', 'VIEW']);
|
||||
}
|
||||
;
|
||||
|
||||
AlterTable
|
||||
: AlterTableLeftSide PartitionSpec
|
||||
;
|
||||
|
||||
AlterTable_EDIT
|
||||
: AlterTableLeftSide_EDIT
|
||||
| AlterTableLeftSide_EDIT PartitionSpec
|
||||
| AlterTableLeftSide 'CURSOR'
|
||||
| AlterTableLeftSide PartitionSpec 'CURSOR'
|
||||
;
|
||||
|
||||
AlterTableLeftSide
|
||||
: 'ALTER' 'TABLE' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
;
|
||||
|
||||
AlterTableLeftSide_EDIT
|
||||
: 'ALTER' 'TABLE' SchemaQualifiedTableIdentifier_EDIT
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyTables = true;
|
||||
}
|
||||
}
|
||||
| 'ALTER' 'TABLE' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables({ onlyTables: true });
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
;
|
||||
|
||||
AlterView
|
||||
: AlterViewLeftSide 'AS' QuerySpecification
|
||||
;
|
||||
|
||||
AlterView_EDIT
|
||||
: AlterViewLeftSide_EDIT
|
||||
| AlterViewLeftSide 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['AS']);
|
||||
}
|
||||
| AlterViewLeftSide 'SET' 'CURSOR'
|
||||
| AlterViewLeftSide 'AS' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
| AlterViewLeftSide 'AS' QuerySpecification_EDIT
|
||||
;
|
||||
|
||||
|
||||
AlterViewLeftSide
|
||||
: 'ALTER' 'VIEW' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
;
|
||||
|
||||
AlterViewLeftSide_EDIT
|
||||
: 'ALTER' 'VIEW' SchemaQualifiedTableIdentifier_EDIT
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyViews = true;
|
||||
}
|
||||
}
|
||||
| 'ALTER' 'VIEW' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables({ onlyViews: true });
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
;
|
615
src/jison/sql/generic/sql_create.jison
Normal file
615
src/jison/sql/generic/sql_create.jison
Normal file
@ -0,0 +1,615 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: CreateStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: CreateStatement_EDIT
|
||||
;
|
||||
|
||||
CreateStatement
|
||||
: DatabaseDefinition
|
||||
| TableDefinition
|
||||
| ViewDefinition
|
||||
| RoleDefinition
|
||||
;
|
||||
|
||||
CreateStatement_EDIT
|
||||
: DatabaseDefinition_EDIT
|
||||
| TableDefinition_EDIT
|
||||
| ViewDefinition_EDIT
|
||||
| 'CREATE' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['DATABASE', 'ROLE', 'SCHEMA', 'TABLE', 'VIEW']);
|
||||
}
|
||||
;
|
||||
|
||||
DatabaseDefinition
|
||||
: 'CREATE' DatabaseOrSchema OptionalIfNotExists
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals
|
||||
{
|
||||
parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
|
||||
}
|
||||
;
|
||||
|
||||
DatabaseDefinition_EDIT
|
||||
: 'CREATE' DatabaseOrSchema OptionalIfNotExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists_EDIT
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists 'CURSOR' RegularIdentifier
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
parser.addNewDatabaseLocation(@5, [{ name: $5 }]);
|
||||
}
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists_EDIT RegularIdentifier
|
||||
{
|
||||
parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
|
||||
}
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals 'CURSOR'
|
||||
{
|
||||
parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
|
||||
}
|
||||
;
|
||||
|
||||
DatabaseDefinitionOptionals
|
||||
: OptionalComment
|
||||
{
|
||||
if (!$1) {
|
||||
parser.suggestKeywords(['COMMENT']);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
DatabaseDefinitionOptionals_EDIT
|
||||
: OptionalComment_INVALID
|
||||
;
|
||||
|
||||
OptionalComment
|
||||
:
|
||||
| Comment
|
||||
;
|
||||
|
||||
Comment
|
||||
: 'COMMENT' QuotedValue
|
||||
;
|
||||
|
||||
OptionalComment_INVALID
|
||||
: Comment_INVALID
|
||||
;
|
||||
|
||||
Comment_INVALID
|
||||
: 'COMMENT' SINGLE_QUOTE
|
||||
| 'COMMENT' DOUBLE_QUOTE
|
||||
| 'COMMENT' SINGLE_QUOTE VALUE
|
||||
| 'COMMENT' DOUBLE_QUOTE VALUE
|
||||
;
|
||||
|
||||
TableDefinition
|
||||
: 'CREATE' 'TABLE' OptionalIfNotExists TableDefinitionRightPart
|
||||
;
|
||||
|
||||
TableDefinition_EDIT
|
||||
: 'CREATE' 'TABLE' OptionalIfNotExists TableDefinitionRightPart_EDIT
|
||||
| 'CREATE' 'TABLE' OptionalIfNotExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'CREATE' 'TABLE' OptionalIfNotExists_EDIT
|
||||
;
|
||||
|
||||
TableDefinitionRightPart
|
||||
: TableIdentifierAndOptionalColumnSpecification OptionalPartitionedBy OptionalAsSelectStatement
|
||||
;
|
||||
|
||||
TableDefinitionRightPart_EDIT
|
||||
: TableIdentifierAndOptionalColumnSpecification_EDIT OptionalPartitionedBy OptionalAsSelectStatement
|
||||
| TableIdentifierAndOptionalColumnSpecification PartitionedBy_EDIT OptionalAsSelectStatement
|
||||
| TableIdentifierAndOptionalColumnSpecification OptionalPartitionedBy OptionalAsSelectStatement_EDIT
|
||||
| TableIdentifierAndOptionalColumnSpecification OptionalPartitionedBy 'CURSOR'
|
||||
{
|
||||
var keywords = [];
|
||||
if (!$1 && !$2) {
|
||||
keywords.push({ value: 'LIKE', weight: 1 });
|
||||
} else {
|
||||
if (!$2) {
|
||||
keywords.push({ value: 'PARTITIONED BY', weight: 12 });
|
||||
}
|
||||
keywords.push({ value: 'AS', weight: 1 });
|
||||
}
|
||||
|
||||
if (keywords.length > 0) {
|
||||
parser.suggestKeywords(keywords);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
TableIdentifierAndOptionalColumnSpecification
|
||||
: SchemaQualifiedIdentifier OptionalColumnSpecificationsOrLike
|
||||
{
|
||||
parser.addNewTableLocation(@1, $1, $2);
|
||||
$$ = $2;
|
||||
}
|
||||
;
|
||||
|
||||
TableIdentifierAndOptionalColumnSpecification_EDIT
|
||||
: SchemaQualifiedIdentifier OptionalColumnSpecificationsOrLike_EDIT
|
||||
| SchemaQualifiedIdentifier_EDIT OptionalColumnSpecificationsOrLike
|
||||
;
|
||||
|
||||
OptionalColumnSpecificationsOrLike
|
||||
:
|
||||
| ParenthesizedColumnSpecificationList
|
||||
| 'LIKE' SchemaQualifiedTableIdentifier -> []
|
||||
;
|
||||
|
||||
OptionalColumnSpecificationsOrLike_EDIT
|
||||
: ParenthesizedColumnSpecificationList_EDIT
|
||||
| 'LIKE' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'LIKE' SchemaQualifiedTableIdentifier_EDIT
|
||||
;
|
||||
|
||||
ParenthesizedColumnSpecificationList
|
||||
: '(' ColumnSpecificationList ')' -> $2
|
||||
;
|
||||
|
||||
ParenthesizedColumnSpecificationList_EDIT
|
||||
: '(' ColumnSpecificationList_EDIT RightParenthesisOrError
|
||||
;
|
||||
|
||||
ColumnSpecificationList
|
||||
: ColumnSpecification -> [$1]
|
||||
| ColumnSpecificationList ',' ColumnSpecification -> $1.concat($3)
|
||||
;
|
||||
|
||||
ColumnSpecificationList_EDIT
|
||||
: ColumnSpecification_EDIT
|
||||
| ColumnSpecification_EDIT ',' ColumnSpecificationList
|
||||
| ColumnSpecificationList ',' ColumnSpecification_EDIT
|
||||
| ColumnSpecificationList ',' ColumnSpecification_EDIT ',' ColumnSpecificationList
|
||||
| ColumnSpecification 'CURSOR'
|
||||
{
|
||||
parser.checkForKeywords($1);
|
||||
}
|
||||
| ColumnSpecification 'CURSOR' ',' ColumnSpecificationList
|
||||
{
|
||||
parser.checkForKeywords($1);
|
||||
}
|
||||
| ColumnSpecificationList ',' ColumnSpecification 'CURSOR'
|
||||
{
|
||||
parser.checkForKeywords($3);
|
||||
}
|
||||
| ColumnSpecificationList ',' ColumnSpecification 'CURSOR' ',' ColumnSpecificationList
|
||||
{
|
||||
parser.checkForKeywords($3);
|
||||
}
|
||||
;
|
||||
|
||||
ColumnSpecification
|
||||
: ColumnIdentifier ColumnDataType OptionalColumnOptions
|
||||
{
|
||||
$$ = $1;
|
||||
$$.type = $2;
|
||||
var keywords = [];
|
||||
if (!$3['comment']) {
|
||||
keywords.push('COMMENT');
|
||||
}
|
||||
if (keywords.length > 0) {
|
||||
$$.suggestKeywords = keywords;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
ColumnSpecification_EDIT
|
||||
: ColumnIdentifier 'CURSOR' OptionalColumnOptions
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| ColumnIdentifier ColumnDataType_EDIT OptionalColumnOptions
|
||||
| ColumnIdentifier ColumnDataType ColumnOptions_EDIT
|
||||
;
|
||||
|
||||
OptionalColumnOptions
|
||||
: -> {}
|
||||
| ColumnOptions
|
||||
;
|
||||
|
||||
ColumnOptions
|
||||
: ColumnOption
|
||||
{
|
||||
$$ = {};
|
||||
$$[$1] = true;
|
||||
}
|
||||
| ColumnOptions ColumnOption
|
||||
{
|
||||
$1[$2] = true;
|
||||
}
|
||||
;
|
||||
|
||||
ColumnOptions_EDIT
|
||||
: ColumnOption_EDIT
|
||||
| ColumnOption_EDIT ColumnOptions
|
||||
| ColumnOptions ColumnOption_EDIT
|
||||
| ColumnOptions ColumnOption_EDIT ColumnOptions
|
||||
;
|
||||
|
||||
ColumnOption
|
||||
: 'NOT' 'NULL' -> 'null'
|
||||
| 'NULL' -> 'null'
|
||||
| Comment -> 'comment'
|
||||
;
|
||||
|
||||
ColumnOption_EDIT
|
||||
: 'NOT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['NULL']);
|
||||
}
|
||||
;
|
||||
|
||||
ColumnDataType
|
||||
: PrimitiveType
|
||||
| ArrayType
|
||||
| MapType
|
||||
| StructType
|
||||
| ArrayType_INVALID
|
||||
| MapType_INVALID
|
||||
| StructType_INVALID
|
||||
;
|
||||
|
||||
ColumnDataType_EDIT
|
||||
: ArrayType_EDIT
|
||||
| MapType_EDIT
|
||||
| StructType_EDIT
|
||||
;
|
||||
|
||||
ArrayType
|
||||
: 'ARRAY' '<' ColumnDataType '>'
|
||||
;
|
||||
|
||||
ArrayType_INVALID
|
||||
: 'ARRAY' '<' '>'
|
||||
;
|
||||
|
||||
ArrayType_EDIT
|
||||
: 'ARRAY' '<' AnyCursor GreaterThanOrError
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| 'ARRAY' '<' ColumnDataType_EDIT GreaterThanOrError
|
||||
;
|
||||
|
||||
MapType
|
||||
: 'MAP' '<' PrimitiveType ',' ColumnDataType '>'
|
||||
;
|
||||
|
||||
MapType_INVALID
|
||||
: 'MAP' '<' '>'
|
||||
;
|
||||
|
||||
MapType_EDIT
|
||||
: 'MAP' '<' PrimitiveType ',' ColumnDataType_EDIT GreaterThanOrError
|
||||
| 'MAP' '<' AnyCursor GreaterThanOrError
|
||||
{
|
||||
parser.suggestKeywords(parser.getTypeKeywords());
|
||||
}
|
||||
| 'MAP' '<' PrimitiveType ',' AnyCursor GreaterThanOrError
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| 'MAP' '<' ',' AnyCursor GreaterThanOrError
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
;
|
||||
|
||||
StructType
|
||||
: 'STRUCT' '<' StructDefinitionList '>'
|
||||
;
|
||||
|
||||
StructType_INVALID
|
||||
: 'STRUCT' '<' '>'
|
||||
;
|
||||
|
||||
StructType_EDIT
|
||||
: 'STRUCT' '<' StructDefinitionList_EDIT GreaterThanOrError
|
||||
;
|
||||
|
||||
StructDefinitionList
|
||||
: StructDefinition
|
||||
| StructDefinitionList ',' StructDefinition
|
||||
;
|
||||
|
||||
StructDefinitionList_EDIT
|
||||
: StructDefinition_EDIT
|
||||
| StructDefinition_EDIT Commas
|
||||
| StructDefinition_EDIT Commas StructDefinitionList
|
||||
| StructDefinitionList ',' StructDefinition_EDIT
|
||||
| StructDefinitionList ',' StructDefinition_EDIT Commas StructDefinitionList
|
||||
;
|
||||
|
||||
StructDefinition
|
||||
: RegularOrBacktickedIdentifier ':' ColumnDataType OptionalComment
|
||||
;
|
||||
|
||||
StructDefinition_EDIT
|
||||
: Commas RegularOrBacktickedIdentifier ':' ColumnDataType 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['COMMENT']);
|
||||
}
|
||||
| Commas RegularOrBacktickedIdentifier ':' AnyCursor
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| Commas RegularOrBacktickedIdentifier ':' ColumnDataType_EDIT
|
||||
| RegularOrBacktickedIdentifier ':' ColumnDataType 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['COMMENT']);
|
||||
}
|
||||
| RegularOrBacktickedIdentifier ':' AnyCursor
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| RegularOrBacktickedIdentifier ':' ColumnDataType_EDIT
|
||||
;
|
||||
|
||||
ColumnDataTypeList
|
||||
: ColumnDataType
|
||||
| ColumnDataTypeList ',' ColumnDataType
|
||||
;
|
||||
|
||||
ColumnDataTypeList_EDIT
|
||||
: ColumnDataTypeListInner_EDIT
|
||||
| ColumnDataTypeListInner_EDIT Commas
|
||||
| ColumnDataTypeList ',' ColumnDataTypeListInner_EDIT
|
||||
| ColumnDataTypeListInner_EDIT Commas ColumnDataTypeList
|
||||
| ColumnDataTypeList ',' ColumnDataTypeListInner_EDIT Commas ColumnDataTypeList
|
||||
;
|
||||
|
||||
ColumnDataTypeListInner_EDIT
|
||||
: Commas AnyCursor
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| Commas ColumnDataType_EDIT
|
||||
| AnyCursor
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| ColumnDataType_EDIT
|
||||
;
|
||||
|
||||
GreaterThanOrError
|
||||
: '>'
|
||||
| error
|
||||
;
|
||||
|
||||
OptionalPartitionedBy
|
||||
:
|
||||
| PartitionedBy
|
||||
;
|
||||
|
||||
PartitionedBy
|
||||
: 'PARTITION' 'BY' RangeClause
|
||||
;
|
||||
|
||||
PartitionedBy_EDIT
|
||||
: 'PARTITION' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['BY']);
|
||||
}
|
||||
| 'PARTITION' 'BY' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['RANGE']);
|
||||
}
|
||||
| 'PARTITION' 'BY' RangeClause_EDIT
|
||||
;
|
||||
|
||||
RangeClause
|
||||
: 'RANGE' ParenthesizedColumnList ParenthesizedPartitionValuesList
|
||||
;
|
||||
|
||||
RangeClause_EDIT
|
||||
: 'RANGE' 'CURSOR'
|
||||
| 'RANGE' ParenthesizedColumnList_EDIT
|
||||
| 'RANGE' ParenthesizedColumnList 'CURSOR'
|
||||
| 'RANGE' ParenthesizedColumnList ParenthesizedPartitionValuesList_EDIT
|
||||
| 'RANGE' ParenthesizedColumnList_EDIT ParenthesizedPartitionValuesList
|
||||
;
|
||||
|
||||
ParenthesizedPartitionValuesList
|
||||
: '(' PartitionValueList ')'
|
||||
;
|
||||
|
||||
ParenthesizedPartitionValuesList_EDIT
|
||||
: '(' 'CURSOR' RightParenthesisOrError
|
||||
{
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
|'(' PartitionValueList_EDIT RightParenthesisOrError
|
||||
;
|
||||
|
||||
PartitionValueList
|
||||
: PartitionValue
|
||||
| PartitionValueList ',' PartitionValue
|
||||
;
|
||||
|
||||
PartitionValueList_EDIT
|
||||
: PartitionValue_EDIT
|
||||
| PartitionValueList ',' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
| PartitionValueList ',' 'CURSOR' ',' PartitionValueList
|
||||
{
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
| PartitionValueList ',' PartitionValue_EDIT
|
||||
| PartitionValueList ',' PartitionValue_EDIT ',' PartitionValueList
|
||||
;
|
||||
|
||||
PartitionValue
|
||||
: 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' LessThanOrEqualTo ValueExpression
|
||||
| 'PARTITION' 'VALUES' LessThanOrEqualTo ValueExpression
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES'
|
||||
;
|
||||
|
||||
PartitionValue_EDIT
|
||||
: 'PARTITION' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['VALUE', 'VALUES']);
|
||||
}
|
||||
| 'PARTITION' ValueExpression_EDIT
|
||||
{
|
||||
if ($2.endsWithLessThanOrEqual) {
|
||||
parser.suggestKeywords(['VALUES']);
|
||||
}
|
||||
}
|
||||
| 'PARTITION' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['<', '<=']);
|
||||
}
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['VALUES']);
|
||||
}
|
||||
| 'PARTITION' ValueExpression_EDIT LessThanOrEqualTo 'VALUES'
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['<', '<=']);
|
||||
}
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' LessThanOrEqualTo 'CURSOR'
|
||||
{
|
||||
parser.suggestFunctions();
|
||||
}
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' LessThanOrEqualTo ValueExpression_EDIT
|
||||
| 'PARTITION' 'VALUES' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['<', '<=']);
|
||||
}
|
||||
| 'PARTITION' 'VALUES' LessThanOrEqualTo 'CURSOR'
|
||||
{
|
||||
parser.suggestFunctions();
|
||||
}
|
||||
| 'PARTITION' 'VALUES' LessThanOrEqualTo ValueExpression_EDIT
|
||||
;
|
||||
|
||||
LessThanOrEqualTo
|
||||
: '<'
|
||||
| 'COMPARISON_OPERATOR' // This is fine for autocompletion
|
||||
;
|
||||
|
||||
OptionalAsSelectStatement
|
||||
:
|
||||
| 'AS' CommitLocations QuerySpecification
|
||||
;
|
||||
|
||||
OptionalAsSelectStatement_EDIT
|
||||
: 'AS' CommitLocations 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
| 'AS' CommitLocations QuerySpecification_EDIT
|
||||
;
|
||||
|
||||
CommitLocations
|
||||
: /* empty */
|
||||
{
|
||||
parser.commitLocations();
|
||||
}
|
||||
;
|
||||
|
||||
ViewDefinition
|
||||
: 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'AS' QuerySpecification
|
||||
;
|
||||
|
||||
ViewDefinition_EDIT
|
||||
: 'CREATE' 'VIEW' OptionalIfNotExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists 'CURSOR' SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'AS' QuerySpecification
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists_EDIT
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedViewColumnList_EDIT OptionalComment
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'CURSOR'
|
||||
{
|
||||
var keywords = [{value: 'AS', weight: 1 }];
|
||||
if (!$6) {
|
||||
keywords.push({ value: 'COMMENT', weight: 3 });
|
||||
}
|
||||
parser.suggestKeywords(keywords);
|
||||
}
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'AS' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'AS' QuerySpecification_EDIT
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier_EDIT OptionalParenthesizedViewColumnList OptionalComment 'AS' QuerySpecification
|
||||
;
|
||||
|
||||
OptionalParenthesizedViewColumnList
|
||||
:
|
||||
| ParenthesizedViewColumnList
|
||||
;
|
||||
|
||||
ParenthesizedViewColumnList
|
||||
: '(' ViewColumnList ')'
|
||||
;
|
||||
|
||||
ParenthesizedViewColumnList_EDIT
|
||||
: '(' ViewColumnList_EDIT RightParenthesisOrError
|
||||
{
|
||||
if (!$2) {
|
||||
parser.suggestKeywords(['COMMENT']);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
ViewColumnList
|
||||
: ColumnReference OptionalComment
|
||||
| ViewColumnList ',' ColumnReference OptionalComment
|
||||
;
|
||||
|
||||
ViewColumnList_EDIT
|
||||
: ColumnReference OptionalComment 'CURSOR' -> $2
|
||||
| ColumnReference OptionalComment 'CURSOR' ',' ViewColumnList -> $2
|
||||
| ViewColumnList ',' ColumnReference OptionalComment 'CURSOR' -> $4
|
||||
| ViewColumnList ',' ColumnReference OptionalComment 'CURSOR' ',' ViewColumnList -> $4
|
||||
;
|
||||
|
||||
RoleDefinition
|
||||
: 'CREATE' 'ROLE' RegularIdentifier
|
||||
;
|
184
src/jison/sql/generic/sql_drop.jison
Normal file
184
src/jison/sql/generic/sql_drop.jison
Normal file
@ -0,0 +1,184 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: DropStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: DropStatement_EDIT
|
||||
;
|
||||
|
||||
DropStatement
|
||||
: DropDatabaseStatement
|
||||
| DropRoleStatement
|
||||
| DropTableStatement
|
||||
| DropViewStatement
|
||||
| TruncateTableStatement
|
||||
;
|
||||
|
||||
DropStatement_EDIT
|
||||
: DropDatabaseStatement_EDIT
|
||||
| DropTableStatement_EDIT
|
||||
| DropViewStatement_EDIT
|
||||
| TruncateTableStatement_EDIT
|
||||
| 'DROP' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['DATABASE', 'ROLE', 'SCHEMA', 'TABLE', 'VIEW']);
|
||||
}
|
||||
;
|
||||
|
||||
DropDatabaseStatement
|
||||
: 'DROP' DatabaseOrSchema OptionalIfExists RegularOrBacktickedIdentifier OptionalCascade
|
||||
;
|
||||
|
||||
DropDatabaseStatement_EDIT
|
||||
: 'DROP' DatabaseOrSchema OptionalIfExists
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists_EDIT
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
parser.suggestDatabases();
|
||||
}
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists RegularOrBacktickedIdentifier 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['CASCADE']);
|
||||
}
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists_EDIT RegularOrBacktickedIdentifier OptionalCascade
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists 'CURSOR' RegularOrBacktickedIdentifier OptionalCascade
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
;
|
||||
DropRoleStatement
|
||||
: 'DROP' 'ROLE' RegularIdentifier
|
||||
;
|
||||
|
||||
DropTableStatement
|
||||
: 'DROP' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier OptionalPurge
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
DropTableStatement_EDIT
|
||||
: 'DROP' 'TABLE' OptionalIfExists_EDIT
|
||||
| 'DROP' 'TABLE' OptionalIfExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
parser.suggestTables({ onlyTables: true });
|
||||
parser.suggestDatabases({
|
||||
appendDot: true
|
||||
});
|
||||
}
|
||||
| 'DROP' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier_EDIT OptionalPurge
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyTables = true;
|
||||
}
|
||||
}
|
||||
| 'DROP' 'TABLE' OptionalIfExists_EDIT SchemaQualifiedTableIdentifier OptionalPurge
|
||||
| 'DROP' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier OptionalPurge 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
if (!$5) {
|
||||
parser.suggestKeywords(['PURGE']);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
OptionalPurge
|
||||
:
|
||||
| 'PURGE'
|
||||
;
|
||||
|
||||
DropViewStatement
|
||||
: 'DROP' 'VIEW' OptionalIfExists SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
DropViewStatement_EDIT
|
||||
: 'DROP' 'VIEW' OptionalIfExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
parser.suggestTables({ onlyViews: true });
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'DROP' 'VIEW' OptionalIfExists 'CURSOR' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($5);
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'DROP' 'VIEW' OptionalIfExists_EDIT
|
||||
| 'DROP' 'VIEW' OptionalIfExists_EDIT SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
| 'DROP' 'VIEW' OptionalIfExists SchemaQualifiedTableIdentifier_EDIT
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyViews = true;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
TruncateTableStatement
|
||||
: 'TRUNCATE' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
TruncateTableStatement_EDIT
|
||||
: 'TRUNCATE' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['TABLE']);
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists_EDIT
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier_EDIT
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists 'CURSOR' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists_EDIT SchemaQualifiedTableIdentifier OptionalPartitionSpec
|
||||
;
|
132
src/jison/sql/generic/sql_error.jison
Normal file
132
src/jison/sql/generic/sql_error.jison
Normal file
@ -0,0 +1,132 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
SqlStatements
|
||||
: error
|
||||
| NonStartingToken error // Having just ': error' does not work for some reason, jison bug?
|
||||
;
|
||||
|
||||
SqlStatement_EDIT
|
||||
: AnyCursor error
|
||||
{
|
||||
parser.suggestDdlAndDmlKeywords();
|
||||
}
|
||||
;
|
||||
|
||||
SelectStatement
|
||||
: 'SELECT' OptionalAllOrDistinct SelectList_ERROR TableExpression
|
||||
| 'SELECT' OptionalAllOrDistinct SelectList TableExpression_ERROR
|
||||
;
|
||||
|
||||
SelectStatement_EDIT
|
||||
: 'SELECT' OptionalAllOrDistinct SelectList_ERROR_EDIT TableExpression
|
||||
{
|
||||
parser.selectListNoTableSuggest($3, $2);
|
||||
}
|
||||
| 'SELECT' OptionalAllOrDistinct SelectList_ERROR TableExpression_EDIT
|
||||
;
|
||||
|
||||
SelectList_ERROR
|
||||
: ErrorList
|
||||
| SelectList ',' ErrorList
|
||||
| ErrorList ',' SelectList ',' ErrorList
|
||||
| ErrorList ',' SelectList
|
||||
| SelectList ',' ErrorList ',' SelectList
|
||||
;
|
||||
|
||||
SelectList_ERROR_EDIT
|
||||
: ErrorList ',' SelectList_EDIT -> $3
|
||||
| SelectList ',' ErrorList ',' SelectList_EDIT -> $5
|
||||
| ErrorList ',' SelectList ',' ErrorList ',' SelectList_EDIT -> $7
|
||||
| ErrorList ',' AnyCursor
|
||||
{
|
||||
$$ = { cursorAtStart : false, suggestFunctions: true, suggestColumns: true, suggestAggregateFunctions: true };
|
||||
}
|
||||
| SelectList ',' ErrorList ',' AnyCursor
|
||||
{
|
||||
$$ = { cursorAtStart : false, suggestFunctions: true, suggestColumns: true, suggestAggregateFunctions: true };
|
||||
}
|
||||
| ErrorList ',' SelectList ',' Errors ',' AnyCursor
|
||||
{
|
||||
$$ = { cursorAtStart : true, suggestFunctions: true, suggestColumns: true, suggestAggregateFunctions: true };
|
||||
}
|
||||
;
|
||||
|
||||
SetSpecification
|
||||
: 'SET' SetOption '=' error
|
||||
;
|
||||
|
||||
ErrorList
|
||||
: error
|
||||
| Errors ',' error
|
||||
;
|
||||
|
||||
JoinType_EDIT
|
||||
: 'FULL' 'CURSOR' error
|
||||
{
|
||||
parser.suggestKeywords(['JOIN', 'OUTER JOIN']);
|
||||
}
|
||||
| 'LEFT' 'CURSOR' error
|
||||
{
|
||||
parser.suggestKeywords(['JOIN', 'OUTER JOIN']);
|
||||
}
|
||||
| 'RIGHT' 'CURSOR' error
|
||||
{
|
||||
parser.suggestKeywords(['JOIN', 'OUTER JOIN']);
|
||||
}
|
||||
;
|
||||
|
||||
OptionalSelectConditions_EDIT
|
||||
: WhereClause error 'CURSOR' OptionalGroupByClause OptionalHavingClause OptionalOrderByClause OptionalLimitClause
|
||||
{
|
||||
$$ = {
|
||||
suggestKeywords: parser.getKeywordsForOptionalsLR([$4, $5, $6, $7], [{ value: 'GROUP BY', weight: 8 }, { value: 'HAVING', weight: 7 }, { value: 'ORDER BY', weight: 5 }, { value: 'LIMIT', weight: 3 }], [true, true, true, true]),
|
||||
cursorAtEnd: !$4 && !$5 && !$6 && !$7
|
||||
};
|
||||
}
|
||||
| OptionalWhereClause OptionalGroupByClause HavingClause error 'CURSOR' OptionalOrderByClause OptionalLimitClause
|
||||
{
|
||||
$$ = {
|
||||
suggestKeywords: parser.getKeywordsForOptionalsLR([$6, $7], [{ value: 'ORDER BY', weight: 5 }, { value: 'LIMIT', weight: 3 }], [true, true]),
|
||||
cursorAtEnd: !$6 && !$7
|
||||
}
|
||||
}
|
||||
| OptionalWhereClause OptionalGroupByClause OptionalHavingClause OrderByClause error 'CURSOR' OptionalLimitClause
|
||||
{
|
||||
$$ = {
|
||||
suggestKeywords: parser.getKeywordsForOptionalsLR([$7], [{ value: 'LIMIT', weight: 3 }], [true]),
|
||||
cursorAtEnd: !$7
|
||||
}
|
||||
}
|
||||
| OptionalWhereClause OptionalGroupByClause OptionalHavingClause OptionalOrderByClause LimitClause error 'CURSOR'
|
||||
;
|
||||
|
||||
OptionalSelectConditions_EDIT
|
||||
: WhereClause error GroupByClause_EDIT OptionalHavingClause OptionalOrderByClause OptionalLimitClause
|
||||
| WhereClause error OptionalGroupByClause HavingClause_EDIT OptionalOrderByClause OptionalLimitClause
|
||||
| WhereClause error OptionalGroupByClause OptionalHavingClause OrderByClause_EDIT OptionalLimitClause
|
||||
| WhereClause error OptionalGroupByClause OptionalHavingClause OptionalOrderByClause LimitClause_EDIT
|
||||
| OptionalWhereClause GroupByClause error HavingClause_EDIT OptionalOrderByClause OptionalLimitClause
|
||||
| OptionalWhereClause GroupByClause error OptionalHavingClause OrderByClause_EDIT OptionalLimitClause
|
||||
| OptionalWhereClause GroupByClause error OptionalHavingClause OptionalOrderByClause LimitClause_EDIT
|
||||
| OptionalWhereClause OptionalGroupByClause HavingClause error OrderByClause_EDIT OptionalLimitClause
|
||||
| OptionalWhereClause OptionalGroupByClause HavingClause error OptionalOrderByClause LimitClause_EDIT
|
||||
| OptionalWhereClause OptionalGroupByClause OptionalHavingClause OrderByClause error LimitClause_EDIT
|
||||
;
|
||||
|
||||
DatabaseDefinition_EDIT
|
||||
: 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals_EDIT error
|
||||
;
|
72
src/jison/sql/generic/sql_insert.jison
Normal file
72
src/jison/sql/generic/sql_insert.jison
Normal file
@ -0,0 +1,72 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataManipulation
|
||||
: InsertStatement
|
||||
;
|
||||
|
||||
InsertStatement
|
||||
: InsertValuesStatement
|
||||
;
|
||||
|
||||
DataManipulation_EDIT
|
||||
: InsertValuesStatement_EDIT
|
||||
;
|
||||
|
||||
InsertValuesStatement
|
||||
: 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier 'VALUES' InsertValuesList
|
||||
{
|
||||
$4.owner = 'insert';
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
InsertValuesStatement_EDIT
|
||||
: 'INSERT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['INTO']);
|
||||
}
|
||||
| 'INSERT' 'INTO' OptionalTable 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['TABLE']);
|
||||
}
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier_EDIT
|
||||
| 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier 'CURSOR'
|
||||
{
|
||||
$4.owner = 'insert';
|
||||
parser.addTablePrimary($4);
|
||||
parser.suggestKeywords(['VALUES']);
|
||||
}
|
||||
| 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier_EDIT 'VALUES' InsertValuesList
|
||||
;
|
||||
|
||||
InsertValuesList
|
||||
: ParenthesizedRowValuesList
|
||||
| RowValuesList ',' ParenthesizedRowValuesList
|
||||
;
|
||||
|
||||
ParenthesizedRowValuesList
|
||||
: '(' InValueList ')'
|
||||
;
|
||||
|
||||
OptionalTable
|
||||
:
|
||||
| 'TABLE'
|
||||
;
|
2762
src/jison/sql/generic/sql_main.jison
Normal file
2762
src/jison/sql/generic/sql_main.jison
Normal file
File diff suppressed because it is too large
Load Diff
46
src/jison/sql/generic/sql_set.jison
Normal file
46
src/jison/sql/generic/sql_set.jison
Normal file
@ -0,0 +1,46 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: SetSpecification
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: 'SET' 'CURSOR'
|
||||
{
|
||||
parser.suggestSetOptions();
|
||||
}
|
||||
;
|
||||
|
||||
SetSpecification
|
||||
: 'SET' SetOption '=' SetValue
|
||||
| 'SET' 'ALL'
|
||||
;
|
||||
|
||||
SetOption
|
||||
: RegularIdentifier
|
||||
| SetOption '.' RegularIdentifier
|
||||
;
|
||||
|
||||
SetValue
|
||||
: RegularIdentifier
|
||||
| SignedInteger
|
||||
| SignedInteger RegularIdentifier
|
||||
| QuotedValue
|
||||
| 'TRUE'
|
||||
| 'FALSE'
|
||||
| 'NULL'
|
||||
;
|
122
src/jison/sql/generic/sql_update.jison
Normal file
122
src/jison/sql/generic/sql_update.jison
Normal file
@ -0,0 +1,122 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataManipulation
|
||||
: UpdateStatement
|
||||
;
|
||||
|
||||
DataManipulation_EDIT
|
||||
: UpdateStatement_EDIT
|
||||
;
|
||||
|
||||
UpdateStatement
|
||||
: 'UPDATE' TargetTable 'SET' SetClauseList OptionalFromJoinedTable OptionalWhereClause
|
||||
;
|
||||
|
||||
UpdateStatement_EDIT
|
||||
: 'UPDATE' TargetTable_EDIT 'SET' SetClauseList OptionalFromJoinedTable OptionalWhereClause
|
||||
| 'UPDATE' TargetTable 'SET' SetClauseList_EDIT OptionalFromJoinedTable OptionalWhereClause
|
||||
| 'UPDATE' TargetTable 'SET' SetClauseList FromJoinedTable_EDIT OptionalWhereClause
|
||||
| 'UPDATE' TargetTable 'SET' SetClauseList OptionalFromJoinedTable WhereClause_EDIT
|
||||
| 'UPDATE' TargetTable 'SET' SetClauseList OptionalFromJoinedTable OptionalWhereClause 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords([ 'WHERE' ]);
|
||||
}
|
||||
| 'UPDATE' TargetTable 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords([ 'SET' ]);
|
||||
}
|
||||
| 'UPDATE' TargetTable_EDIT
|
||||
| 'UPDATE' TargetTable
|
||||
| 'UPDATE' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
;
|
||||
|
||||
TargetTable
|
||||
: TableName
|
||||
;
|
||||
|
||||
TargetTable_EDIT
|
||||
: TableName_EDIT
|
||||
;
|
||||
|
||||
TableName
|
||||
: LocalOrSchemaQualifiedName
|
||||
{
|
||||
parser.addTablePrimary($1);
|
||||
}
|
||||
;
|
||||
|
||||
TableName_EDIT
|
||||
: LocalOrSchemaQualifiedName_EDIT
|
||||
;
|
||||
|
||||
SetClauseList
|
||||
: SetClause
|
||||
| SetClauseList ',' SetClause
|
||||
;
|
||||
|
||||
SetClauseList_EDIT
|
||||
: SetClause_EDIT
|
||||
| SetClauseList ',' SetClause_EDIT
|
||||
| SetClause_EDIT ',' SetClauseList
|
||||
| SetClauseList ',' SetClause_EDIT ',' SetClauseList
|
||||
;
|
||||
|
||||
SetClause
|
||||
: SetTarget '=' UpdateSource
|
||||
;
|
||||
|
||||
SetClause_EDIT
|
||||
: SetTarget '=' UpdateSource_EDIT
|
||||
| SetTarget 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords([ '=' ]);
|
||||
}
|
||||
| 'CURSOR'
|
||||
{
|
||||
parser.suggestColumns();
|
||||
}
|
||||
;
|
||||
|
||||
SetTarget
|
||||
: ColumnReference
|
||||
;
|
||||
|
||||
UpdateSource
|
||||
: ValueExpression
|
||||
;
|
||||
|
||||
UpdateSource_EDIT
|
||||
: ValueExpression_EDIT
|
||||
;
|
||||
|
||||
OptionalFromJoinedTable
|
||||
:
|
||||
| 'FROM' TableReference -> $2
|
||||
;
|
||||
|
||||
FromJoinedTable_EDIT
|
||||
: 'FROM' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'FROM' TableReference_EDIT
|
||||
;
|
39
src/jison/sql/generic/sql_use.jison
Normal file
39
src/jison/sql/generic/sql_use.jison
Normal file
@ -0,0 +1,39 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: UseStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: UseStatement_EDIT
|
||||
;
|
||||
|
||||
UseStatement
|
||||
: 'USE' RegularIdentifier
|
||||
{
|
||||
if (! parser.yy.cursorFound) {
|
||||
parser.yy.result.useDatabase = $2;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
UseStatement_EDIT
|
||||
: 'USE' 'CURSOR'
|
||||
{
|
||||
parser.suggestDatabases();
|
||||
}
|
||||
;
|
839
src/jison/sql/generic/sql_valueExpression.jison
Normal file
839
src/jison/sql/generic/sql_valueExpression.jison
Normal file
@ -0,0 +1,839 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
ValueExpression
|
||||
: 'NOT' ValueExpression
|
||||
{
|
||||
// verifyType($2, 'BOOLEAN');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| '!' ValueExpression
|
||||
{
|
||||
// verifyType($2, 'BOOLEAN');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| '~' ValueExpression -> $2
|
||||
| '-' ValueExpression %prec NEGATION
|
||||
{
|
||||
// verifyType($2, 'NUMBER');
|
||||
$$ = $2;
|
||||
$2.types = ['NUMBER'];
|
||||
}
|
||||
| ValueExpression 'IS' OptionalNot 'NULL' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IS' OptionalNot 'TRUE' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IS' OptionalNot 'FALSE' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IS' OptionalNot 'DISTINCT' 'FROM' ValueExpression -> { types: [ 'BOOLEAN' ] }
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'NOT' ValueExpression_EDIT -> { types: [ 'BOOLEAN' ], suggestFilters: $2.suggestFilters }
|
||||
| 'NOT' 'CURSOR'
|
||||
{
|
||||
parser.suggestFunctions();
|
||||
parser.suggestColumns();
|
||||
parser.suggestKeywords(['EXISTS']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| '!' ValueExpression_EDIT -> { types: [ 'BOOLEAN' ], suggestFilters: $2.suggestFilters }
|
||||
| '!' AnyCursor
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'BOOLEAN' ] });
|
||||
parser.suggestColumns({ types: [ 'BOOLEAN' ] });
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| '~' ValueExpression_EDIT -> { types: [ 'T' ], suggestFilters: $2.suggestFilters }
|
||||
| '~' 'PARTIAL_CURSOR'
|
||||
{
|
||||
parser.suggestFunctions();
|
||||
parser.suggestColumns();
|
||||
$$ = { types: [ 'T' ] };
|
||||
}
|
||||
| '-' ValueExpression_EDIT %prec NEGATION
|
||||
{
|
||||
if (!$2.typeSet) {
|
||||
parser.applyTypeToSuggestions('NUMBER');
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $2.suggestFilters };
|
||||
}
|
||||
| '-' 'PARTIAL_CURSOR' %prec NEGATION
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'NUMBER' ] });
|
||||
parser.suggestColumns({ types: [ 'NUMBER' ] });
|
||||
$$ = { types: [ 'NUMBER' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['FALSE', 'NOT NULL', 'NOT TRUE', 'NOT FALSE', 'NULL', 'TRUE']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'NOT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['FALSE', 'NULL', 'TRUE']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' OptionalNot 'DISTINCT' 'CURSOR'
|
||||
{
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'CURSOR' 'NULL'
|
||||
{
|
||||
parser.suggestKeywords(['NOT']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'CURSOR' 'FALSE'
|
||||
{
|
||||
parser.suggestKeywords(['NOT']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'CURSOR' 'TRUE'
|
||||
{
|
||||
parser.suggestKeywords(['NOT']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' OptionalNot 'DISTINCT' 'FROM' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $3 ? 'IS NOT DISTINCT FROM' : 'IS DISTINCT FROM');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' OptionalNot 'DISTINCT' 'FROM' ValueExpression_EDIT
|
||||
{
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $6.suggestFilters }
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ EXISTS and parenthesized ------------------
|
||||
ValueExpression
|
||||
: 'EXISTS' TableSubQuery
|
||||
{
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
// clear correlated flag after completed sub-query (set by lexer)
|
||||
parser.yy.correlatedSubQuery = false;
|
||||
}
|
||||
| '(' ValueExpression ')' -> $2
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'EXISTS' TableSubQuery_EDIT -> { types: [ 'BOOLEAN' ] }
|
||||
| '(' ValueExpression_EDIT RightParenthesisOrError
|
||||
{
|
||||
$$ = $2;
|
||||
}
|
||||
| '(' 'CURSOR' RightParenthesisOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { types: ['T'], typeSet: true };
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ COMPARISON ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression '=' ValueExpression
|
||||
{
|
||||
parser.addColRefToVariableIfExists($1, $3);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression '<' ValueExpression
|
||||
{
|
||||
parser.addColRefToVariableIfExists($1, $3);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression '>' ValueExpression
|
||||
{
|
||||
parser.addColRefToVariableIfExists($1, $3);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'COMPARISON_OPERATOR' ValueExpression
|
||||
{
|
||||
parser.addColRefToVariableIfExists($1, $3);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'CURSOR' '=' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest($3, $2);
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' '<' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest($3, $2);
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' '>' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest($3, $2);
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' 'COMPARISON_OPERATOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest($3, $2);
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression_EDIT '=' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT '<' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT '>' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT 'COMPARISON_OPERATOR' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression '=' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression '<' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ] , typeSet: true, endsWithLessThanOrEqual: true };
|
||||
}
|
||||
| ValueExpression '>' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'COMPARISON_OPERATOR' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, endsWithLessThanOrEqual: $2 === '<=' };
|
||||
}
|
||||
| ValueExpression '=' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
| ValueExpression '<' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
| ValueExpression '>' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
| ValueExpression 'COMPARISON_OPERATOR' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
// ------------------ IN ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression 'NOT' 'IN' '(' TableSubQueryInner ')' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'NOT' 'IN' '(' ValueExpressionList ')' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IN' '(' TableSubQueryInner ')' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IN' '(' ValueExpressionList ')' -> { types: [ 'BOOLEAN' ] }
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: ValueExpression 'NOT' 'IN' ValueExpressionInSecondPart_EDIT
|
||||
{
|
||||
if ($4.inValueEdit) {
|
||||
parser.valueExpressionSuggest($1, $2 + ' ' + $3);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
}
|
||||
if ($4.cursorAtStart) {
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'IN' ValueExpressionInSecondPart_EDIT
|
||||
{
|
||||
if ($3.inValueEdit) {
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
}
|
||||
if ($3.cursorAtStart) {
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression_EDIT 'NOT' 'IN' '(' ValueExpressionList RightParenthesisOrError -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression_EDIT 'NOT' 'IN' '(' TableSubQueryInner RightParenthesisOrError -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression_EDIT 'IN' '(' ValueExpressionList RightParenthesisOrError -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression_EDIT 'IN' '(' TableSubQueryInner RightParenthesisOrError -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
;
|
||||
|
||||
ValueExpressionInSecondPart_EDIT
|
||||
: '(' TableSubQueryInner_EDIT RightParenthesisOrError
|
||||
| '(' ValueExpressionList_EDIT RightParenthesisOrError -> { inValueEdit: true }
|
||||
| '(' AnyCursor RightParenthesisOrError -> { inValueEdit: true, cursorAtStart: true }
|
||||
;
|
||||
|
||||
// ------------------ BETWEEN ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression 'NOT' 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression -> { types: [ 'BOOLEAN' ] }
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: ValueExpression_EDIT 'NOT' 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression
|
||||
{
|
||||
if ($4.types[0] === $6.types[0] && !$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($4.types);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' ValueExpression_EDIT 'BETWEEN_AND' ValueExpression
|
||||
{
|
||||
if ($1.types[0] === $6.types[0] && !$4.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $4.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression_EDIT
|
||||
{
|
||||
if ($1.types[0] === $4.types[0] && !$6.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $6.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' ValueExpression 'BETWEEN_AND' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $5);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($4, ['AND']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2 + ' ' + $3);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression_EDIT 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression
|
||||
{
|
||||
if ($1.types[0] === $3.types[0] && !$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types)
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' ValueExpression_EDIT 'BETWEEN_AND' ValueExpression
|
||||
{
|
||||
if ($1.types[0] === $3.types[0] && !$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types)
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression_EDIT
|
||||
{
|
||||
if ($1.types[0] === $3.types[0] && !$5.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types)
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $5.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' ValueExpression 'BETWEEN_AND' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $4);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($3, ['AND']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ BOOLEAN ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression 'OR' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'BOOLEAN');
|
||||
// verifyType($3, 'BOOLEAN');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'AND' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'BOOLEAN');
|
||||
// verifyType($3, 'BOOLEAN');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'CURSOR' 'OR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, suggestFilters: true };
|
||||
}
|
||||
| ValueExpression_EDIT 'OR' ValueExpression
|
||||
{
|
||||
parser.addColRefIfExists($3);
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression 'OR' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, suggestFilters: true };
|
||||
}
|
||||
| ValueExpression 'OR' ValueExpression_EDIT
|
||||
{
|
||||
parser.addColRefIfExists($1);
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
| 'CURSOR' 'AND' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, suggestFilters: true };
|
||||
}
|
||||
| ValueExpression_EDIT 'AND' ValueExpression
|
||||
{
|
||||
parser.addColRefIfExists($3);
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression 'AND' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, suggestFilters: true };
|
||||
}
|
||||
| ValueExpression 'AND' ValueExpression_EDIT
|
||||
{
|
||||
parser.addColRefIfExists($1);
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ ARITHMETIC ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression '-' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'NUMBER');
|
||||
// verifyType($3, 'NUMBER');
|
||||
$$ = { types: [ 'NUMBER' ] };
|
||||
}
|
||||
| ValueExpression '*' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'NUMBER');
|
||||
// verifyType($3, 'NUMBER');
|
||||
$$ = { types: [ 'NUMBER' ] };
|
||||
}
|
||||
| ValueExpression 'ARITHMETIC_OPERATOR' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'NUMBER');
|
||||
// verifyType($3, 'NUMBER');
|
||||
$$ = { types: [ 'NUMBER' ] };
|
||||
}
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'CURSOR' '*' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions([ 'NUMBER' ]);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' 'ARITHMETIC_OPERATOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions([ 'NUMBER' ]);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression_EDIT '-' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT '*' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT 'ARITHMETIC_OPERATOR' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression '-' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression '*' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'ARITHMETIC_OPERATOR' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression '-' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $3.suggestFilters };
|
||||
}
|
||||
| ValueExpression '*' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $3.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'ARITHMETIC_OPERATOR' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $3.suggestFilters };
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ LIKE, RLIKE and REGEXP ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression LikeRightPart -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'NOT' LikeRightPart -> { types: [ 'BOOLEAN' ] }
|
||||
;
|
||||
|
||||
LikeRightPart
|
||||
: 'LIKE' ValueExpression -> { suggestKeywords: ['NOT'] }
|
||||
| 'RLIKE' ValueExpression -> { suggestKeywords: ['NOT'] }
|
||||
| 'REGEXP' ValueExpression -> { suggestKeywords: ['NOT'] }
|
||||
;
|
||||
|
||||
LikeRightPart_EDIT
|
||||
: 'LIKE' ValueExpression_EDIT
|
||||
| 'RLIKE' ValueExpression_EDIT
|
||||
| 'REGEXP' ValueExpression_EDIT
|
||||
| 'LIKE' PartialBacktickedOrCursor
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'STRING' ] });
|
||||
parser.suggestColumns({ types: [ 'STRING' ] });
|
||||
$$ = { types: ['BOOLEAN'] }
|
||||
}
|
||||
| 'RLIKE' PartialBacktickedOrCursor
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'STRING' ] });
|
||||
parser.suggestColumns({ types: [ 'STRING' ] });
|
||||
$$ = { types: ['BOOLEAN'] }
|
||||
}
|
||||
| 'REGEXP' PartialBacktickedOrCursor
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'STRING' ] });
|
||||
parser.suggestColumns({ types: [ 'STRING' ] });
|
||||
$$ = { types: ['BOOLEAN'] }
|
||||
}
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: ValueExpression_EDIT LikeRightPart -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression_EDIT 'NOT' LikeRightPart -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression LikeRightPart_EDIT -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'NOT' LikeRightPart_EDIT -> { types: [ 'BOOLEAN' ] }
|
||||
| 'CURSOR' LikeRightPart
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions([ 'STRING' ]);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' 'NOT' LikeRightPart
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2 + ' ' + $3);
|
||||
parser.applyTypeToSuggestions([ 'STRING' ]);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ CASE, WHEN, THEN ------------------
|
||||
|
||||
ValueExpression
|
||||
: 'CASE' CaseRightPart -> $2
|
||||
| 'CASE' ValueExpression CaseRightPart -> $3
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'CASE' CaseRightPart_EDIT -> $2
|
||||
| 'CASE' 'CURSOR' EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { types: [ 'T' ], typeSet: true };
|
||||
}
|
||||
| 'CASE' ValueExpression CaseRightPart_EDIT -> $3
|
||||
| 'CASE' ValueExpression 'CURSOR' EndOrError
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($2, ['WHEN']);
|
||||
$$ = { types: [ 'T' ], typeSet: true };
|
||||
}
|
||||
| 'CASE' ValueExpression_EDIT CaseRightPart
|
||||
{
|
||||
$$ = $3;
|
||||
$$.suggestFilters = $2.suggestFilters;
|
||||
}
|
||||
| 'CASE' ValueExpression_EDIT EndOrError -> { types: [ 'T' ], suggestFilters: $2.suggestFilters }
|
||||
| 'CASE' 'CURSOR' CaseRightPart -> { types: [ 'T' ] }
|
||||
;
|
||||
|
||||
CaseRightPart
|
||||
: CaseWhenThenList 'END' -> parser.findCaseType($1)
|
||||
| CaseWhenThenList 'ELSE' ValueExpression 'END'
|
||||
{
|
||||
$1.caseTypes.push($3);
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
;
|
||||
|
||||
CaseRightPart_EDIT
|
||||
: CaseWhenThenList_EDIT EndOrError -> parser.findCaseType($1)
|
||||
| CaseWhenThenList 'ELSE' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($3, ['END']);
|
||||
$1.caseTypes.push($3);
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| CaseWhenThenList_EDIT 'ELSE' ValueExpression EndOrError
|
||||
{
|
||||
$1.caseTypes.push($3);
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| CaseWhenThenList_EDIT 'ELSE' EndOrError -> parser.findCaseType($1)
|
||||
| CaseWhenThenList 'CURSOR' ValueExpression EndOrError
|
||||
{
|
||||
if ($4.toLowerCase() !== 'end') {
|
||||
parser.suggestValueExpressionKeywords($1, [{ value: 'END', weight: 3 }, { value: 'ELSE', weight: 2 }, { value: 'WHEN', weight: 1 }]);
|
||||
} else {
|
||||
parser.suggestValueExpressionKeywords($1, [{ value: 'ELSE', weight: 2 }, { value: 'WHEN', weight: 1 }]);
|
||||
}
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| CaseWhenThenList 'CURSOR' EndOrError
|
||||
{
|
||||
if ($3.toLowerCase() !== 'end') {
|
||||
parser.suggestValueExpressionKeywords($1, [{ value: 'END', weight: 3 }, { value: 'ELSE', weight: 2 }, { value: 'WHEN', weight: 1 }]);
|
||||
} else {
|
||||
parser.suggestValueExpressionKeywords($1, [{ value: 'ELSE', weight: 2 }, { value: 'WHEN', weight: 1 }]);
|
||||
}
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| CaseWhenThenList 'ELSE' ValueExpression_EDIT EndOrError
|
||||
{
|
||||
$1.caseTypes.push($3);
|
||||
$$ = parser.findCaseType($1);
|
||||
$$.suggestFilters = $3.suggestFilters
|
||||
}
|
||||
| CaseWhenThenList 'ELSE' 'CURSOR' EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| 'ELSE' 'CURSOR' EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { types: [ 'T' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' 'ELSE' ValueExpression EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = $3;
|
||||
}
|
||||
| 'CURSOR' 'ELSE' EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { types: [ 'T' ] };
|
||||
}
|
||||
;
|
||||
|
||||
EndOrError
|
||||
: 'END'
|
||||
| error
|
||||
;
|
||||
|
||||
CaseWhenThenList
|
||||
: CaseWhenThenListPartTwo -> { caseTypes: [ $1 ], lastType: $1 }
|
||||
| CaseWhenThenList CaseWhenThenListPartTwo
|
||||
{
|
||||
$1.caseTypes.push($2);
|
||||
$$ = { caseTypes: $1.caseTypes, lastType: $2 };
|
||||
}
|
||||
;
|
||||
|
||||
CaseWhenThenList_EDIT
|
||||
: CaseWhenThenListPartTwo_EDIT
|
||||
| CaseWhenThenList CaseWhenThenListPartTwo_EDIT
|
||||
| CaseWhenThenList CaseWhenThenListPartTwo_EDIT CaseWhenThenList
|
||||
| CaseWhenThenList 'CURSOR' CaseWhenThenList
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($1, ['WHEN']);
|
||||
}
|
||||
| CaseWhenThenListPartTwo_EDIT CaseWhenThenList -> $2
|
||||
;
|
||||
|
||||
CaseWhenThenListPartTwo
|
||||
: 'WHEN' ValueExpression 'THEN' ValueExpression -> $4
|
||||
;
|
||||
|
||||
CaseWhenThenListPartTwo_EDIT
|
||||
: 'WHEN' ValueExpression_EDIT -> { caseTypes: [{ types: ['T'] }], suggestFilters: $2.suggestFilters }
|
||||
| 'WHEN' ValueExpression_EDIT 'THEN' -> { caseTypes: [{ types: ['T'] }], suggestFilters: $2.suggestFilters }
|
||||
| 'WHEN' ValueExpression_EDIT 'THEN' ValueExpression -> { caseTypes: [$4], suggestFilters: $2.suggestFilters }
|
||||
| 'WHEN' ValueExpression 'THEN' ValueExpression_EDIT -> { caseTypes: [$4], suggestFilters: $4.suggestFilters }
|
||||
| 'WHEN' 'THEN' ValueExpression_EDIT -> { caseTypes: [$3], suggestFilters: $3.suggestFilters }
|
||||
| 'CURSOR' ValueExpression 'THEN'
|
||||
{
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'CURSOR' ValueExpression 'THEN' ValueExpression
|
||||
{
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { caseTypes: [$4] };
|
||||
}
|
||||
| 'CURSOR' 'THEN'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'CURSOR' 'THEN' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }], suggestFilters: true };
|
||||
}
|
||||
| 'WHEN' 'CURSOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['THEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }], suggestFilters: true };
|
||||
}
|
||||
| 'WHEN' 'CURSOR' 'THEN'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }], suggestFilters: true };
|
||||
}
|
||||
| 'WHEN' 'CURSOR' 'THEN' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [$4], suggestFilters: true };
|
||||
}
|
||||
| 'WHEN' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($2, ['THEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' ValueExpression 'CURSOR' ValueExpression
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($2, ['THEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' ValueExpression 'THEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' ValueExpression 'THEN' 'CURSOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' 'THEN' 'CURSOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' 'THEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
;
|
19
src/jison/sql/generic/syntax_footer.jison
Normal file
19
src/jison/sql/generic/syntax_footer.jison
Normal file
@ -0,0 +1,19 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%%
|
||||
|
||||
SqlParseSupport.initSyntaxParser(parser);
|
28
src/jison/sql/generic/syntax_header.jison
Normal file
28
src/jison/sql/generic/syntax_header.jison
Normal file
@ -0,0 +1,28 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%left 'AND' 'OR'
|
||||
%left 'BETWEEN'
|
||||
%left 'NOT' '!' '~'
|
||||
%left '=' '<' '>' 'COMPARISON_OPERATOR'
|
||||
%left '-' '*' 'ARITHMETIC_OPERATOR'
|
||||
|
||||
%left ';' ','
|
||||
%nonassoc 'IN' 'IS' 'LIKE' 'RLIKE' 'REGEXP' 'EXISTS' NEGATION
|
||||
|
||||
%start SqlSyntax
|
||||
|
||||
%%
|
19
src/jison/sql/hive/autocomplete_footer.jison
Normal file
19
src/jison/sql/hive/autocomplete_footer.jison
Normal file
@ -0,0 +1,19 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%%
|
||||
|
||||
SqlParseSupport.initSqlParser(parser);
|
29
src/jison/sql/hive/autocomplete_header.jison
Normal file
29
src/jison/sql/hive/autocomplete_header.jison
Normal file
@ -0,0 +1,29 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%left 'AND' 'OR'
|
||||
%left 'BETWEEN'
|
||||
%left 'NOT' '!' '~'
|
||||
%left '=' '<' '>' 'COMPARISON_OPERATOR'
|
||||
%left '-' '*' 'ARITHMETIC_OPERATOR'
|
||||
|
||||
%left ';' ','
|
||||
%nonassoc 'CURSOR' 'PARTIAL_CURSOR'
|
||||
%nonassoc 'IN' 'IS' 'LIKE' 'RLIKE' 'REGEXP' 'EXISTS' NEGATION
|
||||
|
||||
%start SqlAutocomplete
|
||||
|
||||
%%
|
419
src/jison/sql/hive/sql.jisonlex
Normal file
419
src/jison/sql/hive/sql.jisonlex
Normal file
@ -0,0 +1,419 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%options case-insensitive flex
|
||||
%s between
|
||||
%x hdfs doubleQuotedValue singleQuotedValue backtickedValue
|
||||
%%
|
||||
|
||||
\s { /* skip whitespace */ }
|
||||
'--'.* { /* skip comments */ }
|
||||
[/][*][^*]*[*]+([^/*][^*]*[*]+)*[/] { /* skip comments */ }
|
||||
|
||||
'\u2020' { parser.yy.partialCursor = false; parser.yy.cursorFound = yylloc; return 'CURSOR'; }
|
||||
'\u2021' { parser.yy.partialCursor = true; parser.yy.cursorFound = yylloc; return 'PARTIAL_CURSOR'; }
|
||||
|
||||
// Reserved Keywords
|
||||
'ALL' { return 'ALL'; }
|
||||
'ALTER' { parser.determineCase(yytext); parser.addStatementTypeLocation('ALTER', yylloc, yy.lexer.upcomingInput()); return 'ALTER'; }
|
||||
'AND' { return 'AND'; }
|
||||
'ARRAY' { return 'ARRAY'; }
|
||||
'AS' { return 'AS'; }
|
||||
'AUTHORIZATION' { return 'AUTHORIZATION'; }
|
||||
'BETWEEN' { this.begin('between'); return 'BETWEEN'; }
|
||||
'BIGINT' { return 'BIGINT'; }
|
||||
'BINARY' { return 'BINARY'; }
|
||||
'BOOLEAN' { return 'BOOLEAN'; }
|
||||
'BY' { return 'BY'; }
|
||||
'CACHE' { return 'CACHE'; }
|
||||
'CASE' { return 'CASE'; }
|
||||
'CHAR' { return 'CHAR'; }
|
||||
'COLUMN' { return 'COLUMN'; }
|
||||
'CONF' { return 'CONF'; }
|
||||
'CONSTRAINT' { return 'CONSTRAINT'; }
|
||||
'CREATE' { parser.determineCase(yytext); return 'CREATE'; }
|
||||
'CROSS' { return 'CROSS'; }
|
||||
'CUBE' { return 'CUBE'; }
|
||||
'CURRENT' { return 'CURRENT'; }
|
||||
'DATABASE' { return 'DATABASE'; }
|
||||
'DATE' { return 'DATE'; }
|
||||
'DECIMAL' { return 'DECIMAL'; }
|
||||
'DELETE' { parser.determineCase(yytext); return 'DELETE'; }
|
||||
'DESCRIBE' { parser.determineCase(yytext); return 'DESCRIBE'; }
|
||||
'DISTINCT' { return 'DISTINCT'; }
|
||||
'DIV' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'DOUBLE' { return 'DOUBLE'; }
|
||||
'DROP' { parser.determineCase(yytext); parser.addStatementTypeLocation('DROP', yylloc, yy.lexer.upcomingInput()); return 'DROP'; }
|
||||
'ELSE' { return 'ELSE'; }
|
||||
'END' { return 'END'; }
|
||||
'EXISTS' { parser.yy.correlatedSubQuery = true; return 'EXISTS'; }
|
||||
'EXTENDED' { return 'EXTENDED'; }
|
||||
'EXTERNAL' { return 'EXTERNAL'; }
|
||||
'FALSE' { return 'FALSE'; }
|
||||
'FLOAT' { return 'FLOAT'; }
|
||||
'FOLLOWING' { return 'FOLLOWING'; }
|
||||
'FOR' { return 'FOR'; }
|
||||
'FOREIGN' { return 'FOREIGN'; }
|
||||
'FROM' { parser.determineCase(yytext); return 'FROM'; }
|
||||
'FULL' { return 'FULL'; }
|
||||
'FUNCTION' { return 'FUNCTION'; }
|
||||
'GRANT' { return 'GRANT'; }
|
||||
'GROUP' { return 'GROUP'; }
|
||||
'GROUPING' { return 'GROUPING'; }
|
||||
'HAVING' { return 'HAVING'; }
|
||||
'IF' { return 'IF'; }
|
||||
'IMPORT' { parser.determineCase(yytext); return 'IMPORT'; }
|
||||
'IN' { return 'IN'; }
|
||||
'INNER' { return 'INNER'; }
|
||||
'INSERT' { parser.determineCase(yytext); return 'INSERT'; }
|
||||
'INT' { return 'INT'; }
|
||||
'INTEGER' { return 'INTEGER'; }
|
||||
'INTO' { return 'INTO'; }
|
||||
'IS' { return 'IS'; }
|
||||
'JOIN' { return 'JOIN'; }
|
||||
'LATERAL' { return 'LATERAL'; }
|
||||
'LEFT' { return 'LEFT'; }
|
||||
'LIKE' { return 'LIKE'; }
|
||||
'LIMIT' { return 'LIMIT'; }
|
||||
'LOCAL' { return 'LOCAL'; }
|
||||
'LIFECYCLE' { return 'LIFECYCLE'; }
|
||||
'MACRO' { return 'MACRO'; }
|
||||
'MAP' { return 'MAP'; }
|
||||
'NONE' { return 'NONE'; }
|
||||
'NOT' { return 'NOT'; }
|
||||
'NULL' { return 'NULL'; }
|
||||
'NULLS' { return 'NULLS'; }
|
||||
'OF' { return 'OF'; }
|
||||
'ON' { return 'ON'; }
|
||||
'OR' { return 'OR'; }
|
||||
'ORDER' { return 'ORDER'; }
|
||||
'OUT' { return 'OUT'; }
|
||||
'OUTER' { return 'OUTER'; }
|
||||
'PARTITION' { return 'PARTITION'; }
|
||||
'PRECEDING' { return 'PRECEDING'; }
|
||||
'PRECISION' { return 'PRECISION'; }
|
||||
'PRIMARY' { return 'PRIMARY'; }
|
||||
'RANGE' { return 'RANGE'; }
|
||||
'REFERENCES' { return 'REFERENCES'; }
|
||||
'REGEXP' { return 'REGEXP'; }
|
||||
'REVOKE' { return 'REVOKE'; }
|
||||
'RIGHT' { return 'RIGHT'; }
|
||||
'RLIKE' { return 'RLIKE'; }
|
||||
'ROLLUP' { return 'ROLLUP'; }
|
||||
'ROW' { return 'ROW'; }
|
||||
'ROWS' { return 'ROWS'; }
|
||||
'SELECT' { parser.determineCase(yytext); parser.addStatementTypeLocation('SELECT', yylloc); return 'SELECT'; }
|
||||
'SEMI' { return 'SEMI'; }
|
||||
'SET' { parser.determineCase(yytext); parser.addStatementTypeLocation('SET', yylloc); return 'SET'; }
|
||||
'SMALLINT' { return 'SMALLINT'; }
|
||||
'SYNC' { return 'SYNC'; }
|
||||
'TABLE' { return 'TABLE'; }
|
||||
'THEN' { return 'THEN'; }
|
||||
'TIMESTAMP' { return 'TIMESTAMP'; }
|
||||
'TO' { return 'TO'; }
|
||||
'TRUE' { return 'TRUE'; }
|
||||
'TRUNCATE' { parser.determineCase(yytext); parser.addStatementTypeLocation('TRUNCATE', yylloc, yy.lexer.upcomingInput()); return 'TRUNCATE'; }
|
||||
'UNBOUNDED' { return 'UNBOUNDED'; }
|
||||
'UNION' { return 'UNION'; }
|
||||
'UPDATE' { parser.determineCase(yytext); return 'UPDATE'; }
|
||||
'USER' { return 'USER'; }
|
||||
'USING' { return 'USING'; }
|
||||
'UTC_TIMESTAMP' { return 'UTC_TIMESTAMP'; }
|
||||
'VALUES' { return 'VALUES'; }
|
||||
'VARCHAR' { return 'VARCHAR'; }
|
||||
'VIEWS' { return 'VIEWS'; }
|
||||
'WHEN' { return 'WHEN'; }
|
||||
'WHERE' { return 'WHERE'; }
|
||||
'WITH' { parser.determineCase(yytext); parser.addStatementTypeLocation('WITH', yylloc); return 'WITH'; }
|
||||
|
||||
// Non-reserved Keywords
|
||||
'ABORT' { parser.determineCase(yytext); return 'ABORT'; }
|
||||
'ADD' { return 'ADD'; }
|
||||
'ADMIN' { return 'ADMIN'; }
|
||||
'AFTER' { return 'AFTER'; }
|
||||
'ANALYZE' { parser.determineCase(yytext); return 'ANALYZE'; }
|
||||
'ARCHIVE' { return 'ARCHIVE'; }
|
||||
'ASC' { return 'ASC'; }
|
||||
'AST' { return 'AST'; }
|
||||
'AVRO' { return 'AVRO'; }
|
||||
'BUCKET' { return 'BUCKET'; }
|
||||
'BUCKETS' { return 'BUCKETS'; }
|
||||
'CASCADE' { return 'CASCADE'; }
|
||||
'CBO' { return 'CBO'; }
|
||||
'CHANGE' { return 'CHANGE'; }
|
||||
'CHECK' { return 'CHECK'; }
|
||||
'CLUSTER' { return 'CLUSTER'; }
|
||||
'CLUSTERED' { return 'CLUSTERED'; }
|
||||
'COLLECTION' { return 'COLLECTION'; }
|
||||
'COLUMNS' { return 'COLUMNS'; }
|
||||
'COMMENT' { return 'COMMENT'; }
|
||||
'COMPACT' { return 'COMPACT'; }
|
||||
'COMPACTIONS' { return 'COMPACTIONS'; }
|
||||
'COMPUTE' { return 'COMPUTE'; }
|
||||
'CONCATENATE' { return 'CONCATENATE'; }
|
||||
'COST' { return 'COST'; }
|
||||
'CURRENT_DATE' { return 'CURRENT_DATE'; }
|
||||
'CURRENT_TIMESTAMP' { return 'CURRENT_TIMESTAMP'; }
|
||||
'CURRENT_USER' { return 'CURRENT_USER'; }
|
||||
'DATA' { return 'DATA'; }
|
||||
'DATABASES' { return 'DATABASES'; }
|
||||
'DAY' { return 'DAY'; }
|
||||
'DAYOFWEEK' { return 'DAYOFWEEK'; }
|
||||
'DBPROPERTIES' { return 'DBPROPERTIES'; }
|
||||
'DEFAULT' { return 'DEFAULT'; }
|
||||
'DEFERRED' { return 'DEFERRED'; }
|
||||
'DEFINED' { return 'DEFINED'; }
|
||||
'DELIMITED' { return 'DELIMITED'; }
|
||||
'DEPENDENCY' { return 'DEPENDENCY'; }
|
||||
'DESC' { return 'DESC'; }
|
||||
'DETAIL' { return 'DETAIL'; }
|
||||
'DIRECTORY' { this.begin('hdfs'); return 'DIRECTORY'; }
|
||||
'DISABLE' { return 'DISABLE'; }
|
||||
'DISTRIBUTE' { return 'DISTRIBUTE'; }
|
||||
'DISTRIBUTED' { return 'DISTRIBUTED'; }
|
||||
DOUBLE\s+PRECISION { return 'DOUBLE_PRECISION'; }
|
||||
'ENABLE' { return 'ENABLE'; }
|
||||
'ESCAPED' { return 'ESCAPED'; }
|
||||
'EXCHANGE' { return 'EXCHANGE'; }
|
||||
'EXPLAIN' { parser.determineCase(yytext); return 'EXPLAIN'; }
|
||||
'EXPORT' { parser.determineCase(yytext); return 'EXPORT'; }
|
||||
'EXPRESSION' { return 'EXPRESSION'; }
|
||||
'FIELDS' { return 'FIELDS'; }
|
||||
'FILE' { return 'FILE'; }
|
||||
'FILEFORMAT' { return 'FILEFORMAT'; }
|
||||
'FIRST' { return 'FIRST'; }
|
||||
'FORMAT' { return 'FORMAT'; }
|
||||
'FORMATTED' { return 'FORMATTED'; }
|
||||
'FUNCTIONS' { return 'FUNCTIONS'; }
|
||||
'HOUR' { return 'HOUR'; }
|
||||
'IDXPROPERTIES' { return 'IDXPROPERTIES'; }
|
||||
'INDEX' { return 'INDEX'; }
|
||||
'INDEXES' { return 'INDEXES'; }
|
||||
'INPATH' { this.begin('hdfs'); return 'INPATH'; }
|
||||
'INPUTFORMAT' { return 'INPUTFORMAT'; }
|
||||
'ITEMS' { return 'ITEMS'; }
|
||||
'JAR' { return 'JAR'; }
|
||||
'JOINCOST' { return 'JOINCOST'; }
|
||||
'JSONFILE' { return 'JSONFILE'; }
|
||||
'KEY' { return 'KEY'; }
|
||||
'KEYS' { return 'KEYS'; }
|
||||
'LAST' { return 'LAST'; }
|
||||
'LINES' { return 'LINES'; }
|
||||
'LITERAL' { return 'LITERAL'; }
|
||||
'LOAD' { parser.determineCase(yytext); return 'LOAD'; }
|
||||
'LOCATION' { this.begin('hdfs'); return 'LOCATION'; }
|
||||
'LOCK' { return 'LOCK'; }
|
||||
'LOCKS' { return 'LOCKS'; }
|
||||
'MATCHED' { return 'MATCHED'; }
|
||||
'MATERIALIZED' { return 'MATERIALIZED'; }
|
||||
'MERGE' { return 'MERGE'; }
|
||||
'METADATA' { return 'METADATA'; }
|
||||
'MINUTE' { return 'MINUTE'; }
|
||||
'MONTH' { return 'MONTH'; }
|
||||
'MSCK' { return 'MSCK'; }
|
||||
'NO_DROP' { return 'NO_DROP'; }
|
||||
'NORELY' { return 'NORELY'; }
|
||||
'NOSCAN' { return 'NOSCAN'; }
|
||||
'NOVALIDATE' { return 'NOVALIDATE'; }
|
||||
'OFFLINE' { return 'OFFLINE'; }
|
||||
'ONLY' { return 'ONLY'; }
|
||||
'OPERATOR' { return 'OPERATOR'; }
|
||||
'OPTION' { return 'OPTION'; }
|
||||
'ORC' { return 'ORC'; }
|
||||
'OUTPUTFORMAT' { return 'OUTPUTFORMAT'; }
|
||||
'OVER' { return 'OVER'; }
|
||||
'OVERWRITE' { return 'OVERWRITE'; }
|
||||
OVERWRITE\s+DIRECTORY { this.begin('hdfs'); return 'OVERWRITE_DIRECTORY'; }
|
||||
'OWNER' { return 'OWNER'; }
|
||||
'PARQUET' { return 'PARQUET'; }
|
||||
'PARTITIONED' { return 'PARTITIONED'; }
|
||||
'PARTITIONS' { return 'PARTITIONS'; }
|
||||
'PERCENT' { return 'PERCENT'; }
|
||||
'PRIVILEGES' { return 'PRIVILEGES'; }
|
||||
'PURGE' { return 'PURGE'; }
|
||||
'QUARTER' { return 'QUARTER'; }
|
||||
'RCFILE' { return 'RCFILE'; }
|
||||
'REBUILD' { return 'REBUILD'; }
|
||||
'RECOVER' { return 'RECOVER'; }
|
||||
'RELOAD' { parser.determineCase(yytext); return 'RELOAD'; }
|
||||
'RELY' { return 'RELY'; }
|
||||
'RENAME' { return 'RENAME'; }
|
||||
'REPAIR' { return 'REPAIR'; }
|
||||
'REPLACE' { return 'REPLACE'; }
|
||||
'REPLICATION' { return 'REPLICATION'; }
|
||||
'RESTRICT' { return 'RESTRICT'; }
|
||||
'REWRITE' { return 'REWRITE'; }
|
||||
'ROLE' { return 'ROLE'; }
|
||||
'ROLES' { return 'ROLES'; }
|
||||
'SCHEMA' { return 'SCHEMA'; }
|
||||
'SCHEMAS' { return 'SCHEMAS'; }
|
||||
'SECOND' { return 'SECOND'; }
|
||||
'SEQUENCEFILE' { return 'SEQUENCEFILE'; }
|
||||
'SERDE' { return 'SERDE'; }
|
||||
'SERDEPROPERTIES' { return 'SERDEPROPERTIES'; }
|
||||
'SETS' { return 'SETS'; }
|
||||
'SHOW' { parser.determineCase(yytext); parser.addStatementTypeLocation('SHOW', yylloc); return 'SHOW'; }
|
||||
'SHOW_DATABASE' { return 'SHOW_DATABASE'; }
|
||||
'SKEWED LOCATION' { return 'SKEWED_LOCATION'; } // Hack to prevent hdfs lexer state
|
||||
'SKEWED' { return 'SKEWED'; }
|
||||
'SORT' { return 'SORT'; }
|
||||
'SORTED' { return 'SORTED'; }
|
||||
'STATISTICS' { return 'STATISTICS'; }
|
||||
'STORED' { return 'STORED'; }
|
||||
STORED\s+AS\s+DIRECTORIES { return 'STORED_AS_DIRECTORIES'; }
|
||||
'STRING' { return 'STRING'; }
|
||||
'STRUCT' { return 'STRUCT'; }
|
||||
'SUMMARY' { return 'SUMMARY'; }
|
||||
'TABLES' { return 'TABLES'; }
|
||||
'TABLESAMPLE' { return 'TABLESAMPLE'; }
|
||||
'TBLPROPERTIES' { return 'TBLPROPERTIES'; }
|
||||
'TEMPORARY' { return 'TEMPORARY'; }
|
||||
'TERMINATED' { return 'TERMINATED'; }
|
||||
'TEXTFILE' { return 'TEXTFILE'; }
|
||||
'TINYINT' { return 'TINYINT'; }
|
||||
'TOUCH' { return 'TOUCH'; }
|
||||
'TRANSACTIONAL' { return 'TRANSACTIONAL'; }
|
||||
'TRANSACTIONS' { return 'TRANSACTIONS'; }
|
||||
'UNARCHIVE' { return 'UNARCHIVE'; }
|
||||
'UNIONTYPE' { return 'UNIONTYPE'; }
|
||||
'UNIQUE' { return 'UNIQUE'; }
|
||||
'USE' { parser.determineCase(yytext); parser.addStatementTypeLocation('USE', yylloc); return 'USE'; }
|
||||
'VECTORIZATION' { return 'VECTORIZATION'; }
|
||||
'VIEW' { return 'VIEW'; }
|
||||
'WAIT' { return 'WAIT'; }
|
||||
'WEEK' { return 'WEEK'; }
|
||||
'WINDOW' { return 'WINDOW'; }
|
||||
'YEAR' { return 'YEAR'; }
|
||||
|
||||
'.' { return '.'; }
|
||||
'[' { return '['; }
|
||||
']' { return ']'; }
|
||||
|
||||
<between>'AND' { this.popState(); return 'BETWEEN_AND'; }
|
||||
|
||||
// --- UDFs ---
|
||||
AVG\s*\( { yy.lexer.unput('('); yytext = 'avg'; parser.addFunctionLocation(yylloc, yytext); return 'AVG'; }
|
||||
CAST\s*\( { yy.lexer.unput('('); yytext = 'cast'; parser.addFunctionLocation(yylloc, yytext); return 'CAST'; }
|
||||
COLLECT_LIST\s*\( { yy.lexer.unput('('); yytext = 'collect_list'; parser.addFunctionLocation(yylloc, yytext); return 'COLLECT_LIST'; }
|
||||
COLLECT_SET\s*\( { yy.lexer.unput('('); yytext = 'collect_set'; parser.addFunctionLocation(yylloc, yytext); return 'COLLECT_SET'; }
|
||||
CORR\s*\( { yy.lexer.unput('('); yytext = 'corr'; parser.addFunctionLocation(yylloc, yytext); return 'CORR'; }
|
||||
COUNT\s*\( { yy.lexer.unput('('); yytext = 'count'; parser.addFunctionLocation(yylloc, yytext); return 'COUNT'; }
|
||||
COVAR_POP\s*\( { yy.lexer.unput('('); yytext = 'covar_pop'; parser.addFunctionLocation(yylloc, yytext); return 'COVAR_POP'; }
|
||||
COVAR_SAMP\s*\( { yy.lexer.unput('('); yytext = 'covar_samp'; parser.addFunctionLocation(yylloc, yytext); return 'COVAR_SAMP'; }
|
||||
EXTRACT\s*\( { yy.lexer.unput('('); yytext = 'extract'; parser.addFunctionLocation(yylloc, yytext); return 'EXTRACT'; }
|
||||
HISTOGRAM_NUMERIC\s*\( { yy.lexer.unput('('); yytext = 'histogram_numeric'; parser.addFunctionLocation(yylloc, yytext); return 'HISTOGRAM_NUMERIC'; }
|
||||
MAX\s*\( { yy.lexer.unput('('); yytext = 'max'; parser.addFunctionLocation(yylloc, yytext); return 'MAX'; }
|
||||
MIN\s*\( { yy.lexer.unput('('); yytext = 'min'; parser.addFunctionLocation(yylloc, yytext); return 'MIN'; }
|
||||
NTILE\s*\( { yy.lexer.unput('('); yytext = 'ntile'; parser.addFunctionLocation(yylloc, yytext); return 'NTILE'; }
|
||||
PERCENTILE\s*\( { yy.lexer.unput('('); yytext = 'percentile'; parser.addFunctionLocation(yylloc, yytext); return 'PERCENTILE'; }
|
||||
PERCENTILE_APPROX\s*\( { yy.lexer.unput('('); yytext = 'percentile_approx'; parser.addFunctionLocation(yylloc, yytext); return 'PERCENTILE_APPROX'; }
|
||||
STDDEV_POP\s*\( { yy.lexer.unput('('); yytext = 'stddev_pop'; parser.addFunctionLocation(yylloc, yytext); return 'STDDEV_POP'; }
|
||||
STDDEV_SAMP\s*\( { yy.lexer.unput('('); yytext = 'stddev_samp'; parser.addFunctionLocation(yylloc, yytext); return 'STDDEV_SAMP'; }
|
||||
SUM\s*\( { yy.lexer.unput('('); yytext = 'sum'; parser.addFunctionLocation(yylloc, yytext); return 'SUM'; }
|
||||
VAR_POP\s*\( { yy.lexer.unput('('); yytext = 'var_pop'; parser.addFunctionLocation(yylloc, yytext); return 'VAR_POP'; }
|
||||
VAR_SAMP\s*\( { yy.lexer.unput('('); yytext = 'var_samp'; parser.addFunctionLocation(yylloc, yytext); return 'VAR_SAMP'; }
|
||||
VARIANCE\s*\( { yy.lexer.unput('('); yytext = 'variance'; parser.addFunctionLocation(yylloc, yytext); return 'VARIANCE'; }
|
||||
|
||||
// Analytical functions
|
||||
CUME_DIST\s*\( { yy.lexer.unput('('); yytext = 'cume_dist'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
CUME_DIST\s*\( { yy.lexer.unput('('); yytext = 'cume_dist'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
DENSE_RANK\s*\( { yy.lexer.unput('('); yytext = 'dense_rank'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
FIRST_VALUE\s*\( { yy.lexer.unput('('); yytext = 'first_value'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
LAG\s*\( { yy.lexer.unput('('); yytext = 'lag'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
LAST_VALUE\s*\( { yy.lexer.unput('('); yytext = 'last_value'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
LEAD\s*\( { yy.lexer.unput('('); yytext = 'lead'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
PERCENT_RANK\s*\( { yy.lexer.unput('('); yytext = 'percent_rank'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
RANK\s*\( { yy.lexer.unput('('); yytext = 'rank'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
ROW_NUMBER\s*\( { yy.lexer.unput('('); yytext = 'row_number'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
|
||||
[0-9]+ { return 'UNSIGNED_INTEGER'; }
|
||||
[0-9]+(?:[YSL]|BD)? { return 'UNSIGNED_INTEGER'; }
|
||||
[0-9]+E { return 'UNSIGNED_INTEGER_E'; }
|
||||
[A-Za-z0-9_]+ { return 'REGULAR_IDENTIFIER'; }
|
||||
|
||||
<hdfs>'\u2020' { parser.yy.cursorFound = true; return 'CURSOR'; }
|
||||
<hdfs>'\u2021' { parser.yy.cursorFound = true; return 'PARTIAL_CURSOR'; }
|
||||
<hdfs>\s+['"] { return 'HDFS_START_QUOTE'; }
|
||||
<hdfs>[^'"\u2020\u2021]+ { parser.addFileLocation(yylloc, yytext); return 'HDFS_PATH'; }
|
||||
<hdfs>['"] { this.popState(); return 'HDFS_END_QUOTE'; }
|
||||
<hdfs><<EOF>> { return 'EOF'; }
|
||||
|
||||
'&&' { return 'AND'; }
|
||||
'||' { return 'OR'; }
|
||||
'=' { return '='; }
|
||||
'<' { return '<'; }
|
||||
'>' { return '>'; }
|
||||
'!=' { return 'COMPARISON_OPERATOR'; }
|
||||
'<=' { return 'COMPARISON_OPERATOR'; }
|
||||
'>=' { return 'COMPARISON_OPERATOR'; }
|
||||
'<>' { return 'COMPARISON_OPERATOR'; }
|
||||
'<=>' { return 'COMPARISON_OPERATOR'; }
|
||||
'-' { return '-'; }
|
||||
'*' { return '*'; }
|
||||
'+' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'/' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'%' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'|' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'^' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'&' { return 'ARITHMETIC_OPERATOR'; }
|
||||
',' { return ','; }
|
||||
'.' { return '.'; }
|
||||
':' { return ':'; }
|
||||
';' { return ';'; }
|
||||
'~' { return '~'; }
|
||||
'!' { return '!'; }
|
||||
'(' { return '('; }
|
||||
')' { return ')'; }
|
||||
'[' { return '['; }
|
||||
']' { return ']'; }
|
||||
|
||||
\$\{[^}]*\} { return 'VARIABLE_REFERENCE'; }
|
||||
|
||||
\` { this.begin('backtickedValue'); return 'BACKTICK'; }
|
||||
<backtickedValue>[^`]+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '`')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<backtickedValue>\` { this.popState(); return 'BACKTICK'; }
|
||||
|
||||
\' { this.begin('singleQuotedValue'); return 'SINGLE_QUOTE'; }
|
||||
<singleQuotedValue>(?:\\\\|\\[']|[^'])+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '\'')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<singleQuotedValue>\' { this.popState(); return 'SINGLE_QUOTE'; }
|
||||
|
||||
\" { this.begin('doubleQuotedValue'); return 'DOUBLE_QUOTE'; }
|
||||
<doubleQuotedValue>(?:\\\\|\\["]|[^"])+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '"')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<doubleQuotedValue>\" { this.popState(); return 'DOUBLE_QUOTE'; }
|
||||
|
||||
<<EOF>> { return 'EOF'; }
|
||||
|
||||
. { /* To prevent console logging of unknown chars */ }
|
||||
<between>. { }
|
||||
<hdfs>. { }
|
||||
<backtickedValue>. { }
|
||||
<singleQuotedValue>. { }
|
||||
<doubleQuotedValue>. { }
|
867
src/jison/sql/hive/sql_alter.jison
Normal file
867
src/jison/sql/hive/sql_alter.jison
Normal file
@ -0,0 +1,867 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: AlterStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: AlterStatement_EDIT
|
||||
;
|
||||
|
||||
AlterStatement
|
||||
: AlterDatabase
|
||||
| AlterIndex
|
||||
| AlterMaterializedView
|
||||
| AlterTable
|
||||
| AlterView
|
||||
| Msck
|
||||
| ReloadFunction
|
||||
;
|
||||
|
||||
AlterStatement_EDIT
|
||||
: AlterDatabase_EDIT
|
||||
| AlterIndex_EDIT
|
||||
| AlterMaterializedView_EDIT
|
||||
| AlterTable_EDIT
|
||||
| AlterView_EDIT
|
||||
| Msck_EDIT
|
||||
| ReloadFunction_EDIT
|
||||
| 'ALTER' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['DATABASE', 'INDEX', 'MATERIALIZED VIEW', 'SCHEMA', 'TABLE', 'VIEW']);
|
||||
}
|
||||
;
|
||||
|
||||
AlterDatabase
|
||||
: 'ALTER' DatabaseOrSchema RegularOrBacktickedIdentifier 'SET' 'DBPROPERTIES' ParenthesizedPropertyAssignmentList
|
||||
{
|
||||
parser.addDatabaseLocation(@3, [ { name: $3 } ]);
|
||||
}
|
||||
| 'ALTER' DatabaseOrSchema RegularOrBacktickedIdentifier 'SET' HdfsLocation
|
||||
{
|
||||
parser.addDatabaseLocation(@3, [ { name: $3 } ]);
|
||||
}
|
||||
| 'ALTER' DatabaseOrSchema RegularOrBacktickedIdentifier 'SET' 'OWNER' PrincipalSpecification
|
||||
{
|
||||
parser.addDatabaseLocation(@3, [ { name: $3 } ]);
|
||||
}
|
||||
;
|
||||
|
||||
AlterDatabase_EDIT
|
||||
: 'ALTER' DatabaseOrSchema 'CURSOR'
|
||||
{
|
||||
parser.suggestDatabases();
|
||||
}
|
||||
| 'ALTER' DatabaseOrSchema RegularOrBacktickedIdentifier 'CURSOR'
|
||||
{
|
||||
parser.addDatabaseLocation(@3, [ { name: $3 } ]);
|
||||
parser.suggestKeywords(['SET DBPROPERTIES', 'SET LOCATION', 'SET OWNER']);
|
||||
}
|
||||
| 'ALTER' DatabaseOrSchema RegularOrBacktickedIdentifier 'SET' 'CURSOR'
|
||||
{
|
||||
parser.addDatabaseLocation(@3, [ { name: $3 } ]);
|
||||
parser.suggestKeywords(['DBPROPERTIES', 'LOCATION', 'OWNER']);
|
||||
}
|
||||
| 'ALTER' DatabaseOrSchema RegularOrBacktickedIdentifier 'SET' HdfsLocation_EDIT
|
||||
{
|
||||
parser.addDatabaseLocation(@3, [ { name: $3 } ]);
|
||||
}
|
||||
| 'ALTER' DatabaseOrSchema RegularOrBacktickedIdentifier 'SET' 'OWNER' 'CURSOR'
|
||||
{
|
||||
parser.addDatabaseLocation(@3, [ { name: $3 } ]);
|
||||
parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
|
||||
}
|
||||
| 'ALTER' DatabaseOrSchema RegularOrBacktickedIdentifier 'SET' 'OWNER' PrincipalSpecification_EDIT
|
||||
{
|
||||
parser.addDatabaseLocation(@3, [ { name: $3 } ]);
|
||||
}
|
||||
;
|
||||
|
||||
AlterIndex
|
||||
: 'ALTER' 'INDEX' RegularOrBacktickedIdentifier 'ON' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'REBUILD'
|
||||
{
|
||||
parser.addTablePrimary($5);
|
||||
}
|
||||
;
|
||||
|
||||
AlterIndex_EDIT
|
||||
: 'ALTER' 'INDEX' RegularOrBacktickedIdentifier 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['ON']);
|
||||
}
|
||||
| 'ALTER' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'ALTER' 'INDEX' RegularOrBacktickedIdentifier 'ON' SchemaQualifiedTableIdentifier_EDIT
|
||||
| 'ALTER' 'INDEX' RegularOrBacktickedIdentifier 'ON' SchemaQualifiedTableIdentifier OptionalPartitionSpec_EDIT
|
||||
{
|
||||
parser.addTablePrimary($5);
|
||||
}
|
||||
| 'ALTER' 'INDEX' RegularOrBacktickedIdentifier 'ON' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($5);
|
||||
if (!$6) {
|
||||
parser.suggestKeywords(['PARTITION', 'REBUILD']);
|
||||
} else {
|
||||
parser.suggestKeywords(['REBUILD']);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
AlterMaterializedView
|
||||
: 'ALTER' 'MATERIALIZED' 'VIEW' SchemaQualifiedTableIdentifier EnableOrDisable 'REWRITE'
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
AlterMaterializedView_EDIT
|
||||
: 'ALTER' 'MATERIALIZED' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['VIEW']);
|
||||
}
|
||||
| 'ALTER' 'MATERIALIZED' 'VIEW' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables({ onlyViews: true });
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'ALTER' 'MATERIALIZED' 'VIEW' SchemaQualifiedTableIdentifier_EDIT
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyViews = true;
|
||||
}
|
||||
}
|
||||
| 'ALTER' 'MATERIALIZED' 'VIEW' SchemaQualifiedTableIdentifier 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
parser.suggestKeywords(['DISABLE REWRITE', 'ENABLE REWRITE']);
|
||||
}
|
||||
| 'ALTER' 'MATERIALIZED' 'VIEW' SchemaQualifiedTableIdentifier EnableOrDisable 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
parser.suggestKeywords(['REWRITE']);
|
||||
}
|
||||
;
|
||||
|
||||
AlterTable
|
||||
: AlterTableLeftSide 'ADD' OptionalIfNotExists PartitionSpec OptionalHdfsLocation OptionalPartitionSpecs
|
||||
| AlterTableLeftSide 'ADD' 'CONSTRAINT' RegularOrBacktickedIdentifier PrimaryKeySpecification
|
||||
| AlterTableLeftSide 'ADD' TableConstraint
|
||||
| AlterTableLeftSide 'RENAME' 'TO' RegularOrBackTickedSchemaQualifiedName
|
||||
| AlterTableLeftSide ClusteredBy
|
||||
| AlterTableLeftSide 'SKEWED' 'BY' ParenthesizedColumnList 'ON' ParenthesizedSkewedValueList OptionalStoredAsDirectories
|
||||
| AlterTableLeftSide ExchangeSpecification
|
||||
| AlterTableLeftSide 'RECOVER' 'PARTITIONS'
|
||||
| AlterTableLeftSide 'TOUCH' OptionalPartitionSpec
|
||||
| AlterTableLeftSide ArchiveOrUnArchive PartitionSpec
|
||||
| AlterTableLeftSide 'NOT' 'SKEWED'
|
||||
| AlterTableLeftSide 'NOT' 'STORED_AS_DIRECTORIES'
|
||||
| AlterTableLeftSide 'SET' 'SKEWED_LOCATION' ParenthesizedSkewedLocationList
|
||||
| AlterTableLeftSide 'SET' 'OWNER' PrincipalSpecification
|
||||
| AlterTableLeftSide PartitionSpec 'RENAME' 'TO' PartitionSpec
|
||||
| AlterTableLeftSide PartitionSpec 'CHANGE' 'COLUMN' ParenthesizedColumnSpecificationList OptionalCascadeOrRestrict
|
||||
| AlterTableLeftSide DropOperations
|
||||
| AlterTableLeftSide OptionalPartitionOperations
|
||||
| AlterTableLeftSide PartitionSpec OptionalPartitionOperations
|
||||
;
|
||||
|
||||
AlterTable_EDIT
|
||||
: AlterTableLeftSide_EDIT
|
||||
| AlterTableLeftSide_EDIT 'ADD' OptionalIfNotExists PartitionSpec OptionalHdfsLocation OptionalPartitionSpecs
|
||||
| AlterTableLeftSide_EDIT TableConstraint
|
||||
| AlterTableLeftSide_EDIT 'RENAME' 'TO' RegularOrBackTickedSchemaQualifiedName
|
||||
| AlterTableLeftSide_EDIT ClusteredBy
|
||||
| AlterTableLeftSide_EDIT 'SKEWED' 'BY' ParenthesizedColumnList 'ON' ParenthesizedSkewedValueList OptionalStoredAsDirectories
|
||||
| AlterTableLeftSide_EDIT ExchangeSpecification
|
||||
| AlterTableLeftSide_EDIT 'RECOVER' 'PARTITIONS'
|
||||
| AlterTableLeftSide_EDIT 'TOUCH' OptionalPartitionSpec
|
||||
| AlterTableLeftSide_EDIT ArchiveOrUnArchive PartitionSpec
|
||||
| AlterTableLeftSide_EDIT 'NOT' 'SKEWED'
|
||||
| AlterTableLeftSide_EDIT 'NOT' 'STORED_AS_DIRECTORIES'
|
||||
| AlterTableLeftSide_EDIT 'SET' 'SKEWED_LOCATION' ParenthesizedSkewedLocationList
|
||||
| AlterTableLeftSide_EDIT 'SET' 'OWNER' PrincipalSpecification
|
||||
| AlterTableLeftSide_EDIT PartitionSpec 'RENAME' 'TO' PartitionSpec
|
||||
| AlterTableLeftSide_EDIT PartitionSpec 'CHANGE' 'COLUMN' ParenthesizedColumnSpecificationList OptionalCascadeOrRestrict
|
||||
| AlterTableLeftSide_EDIT DropOperations
|
||||
| AlterTableLeftSide_EDIT OptionalPartitionOperations
|
||||
| AlterTableLeftSide_EDIT PartitionSpec OptionalPartitionOperations
|
||||
| AlterTableLeftSide 'ADD' OptionalIfNotExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords([{ value: 'IF NOT EXISTS', weight: 3 }, { value: 'COLUMNS', weight: 2 }, { value: 'CONSTRAINT', weight: 1 }, { value: 'PARTITION', weight: 1 }]);
|
||||
} else {
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
}
|
||||
| AlterTableLeftSide 'REPLACE' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['COLUMNS']);
|
||||
}
|
||||
| AlterTableLeftSide 'ADD' OptionalIfNotExists_EDIT
|
||||
| AlterTableLeftSide 'ADD' OptionalIfNotExists PartitionSpec HdfsLocation_EDIT OptionalPartitionSpecs
|
||||
| AlterTableLeftSide 'ADD' OptionalIfNotExists PartitionSpec OptionalHdfsLocation OptionalPartitionSpecs_EDIT
|
||||
| AlterTableLeftSide 'ADD' OptionalIfNotExists PartitionSpec OptionalHdfsLocation OptionalPartitionSpecs 'CURSOR'
|
||||
{
|
||||
if (!$5 && !$6) {
|
||||
parser.suggestKeywords(['LOCATION', 'PARTITION']);
|
||||
} else if ($6 && $6.suggestKeywords) {
|
||||
var keywords = parser.createWeightedKeywords($6.suggestKeywords, 2);
|
||||
keywords.push({ value: 'PARTITION', weight: 1 });
|
||||
parser.suggestKeywords(keywords);
|
||||
} else {
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
}
|
||||
| AlterTableLeftSide 'ADD' OptionalIfNotExists PartitionSpec_EDIT OptionalHdfsLocation OptionalPartitionSpecs
|
||||
| AlterTableLeftSide 'ADD' 'CONSTRAINT' 'CURSOR'
|
||||
| AlterTableLeftSide 'ADD' 'CONSTRAINT' RegularOrBacktickedIdentifier 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['CHECK', 'FOREIGN KEY', 'PRIMARY KEY', 'UNIQUE']);
|
||||
}
|
||||
| AlterTableLeftSide 'ADD' 'CONSTRAINT' RegularOrBacktickedIdentifier PrimaryKeySpecification_EDIT
|
||||
| AlterTableLeftSide 'ADD' 'CONSTRAINT' RegularOrBacktickedIdentifier ForeignKeySpecification_EDIT
|
||||
| AlterTableLeftSide ArchiveOrUnArchive 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
| AlterTableLeftSide ArchiveOrUnArchive PartitionSpec_EDIT
|
||||
| AlterTableLeftSide ClusteredBy_EDIT
|
||||
| AlterTableLeftSide ExchangeSpecification_EDIT
|
||||
| AlterTableLeftSide 'NOT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['SKEWED', 'STORED AS DIRECTORIES']);
|
||||
}
|
||||
| AlterTableLeftSide 'NOT' 'STORED' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['AS DIRECTORIES']);
|
||||
}
|
||||
| AlterTableLeftSide 'NOT' 'STORED' 'AS' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['DIRECTORIES']);
|
||||
}
|
||||
| AlterTableLeftSide PartitionSpec 'RENAME' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['TO PARTITION']);
|
||||
}
|
||||
| AlterTableLeftSide PartitionSpec 'RENAME' 'TO' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
| AlterTableLeftSide 'RECOVER' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['PARTITIONS']);
|
||||
}
|
||||
| AlterTableLeftSide 'SET' 'SKEWED' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['LOCATION']);
|
||||
}
|
||||
| AlterTableLeftSide 'SET' 'SKEWED_LOCATION' ParenthesizedSkewedLocationList_EDIT
|
||||
| AlterTableLeftSide 'SKEWED' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['BY']);
|
||||
}
|
||||
| AlterTableLeftSide 'SET' 'OWNER' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
|
||||
}
|
||||
| AlterTableLeftSide 'SET' 'OWNER' PrincipalSpecification_EDIT
|
||||
| AlterTableLeftSide 'SKEWED' 'BY' ParenthesizedColumnList_EDIT
|
||||
| AlterTableLeftSide 'SKEWED' 'BY' ParenthesizedColumnList_EDIT 'ON' ParenthesizedSkewedValueList OptionalStoredAsDirectories
|
||||
| AlterTableLeftSide 'SKEWED' 'BY' ParenthesizedColumnList 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['ON']);
|
||||
}
|
||||
| AlterTableLeftSide 'SKEWED' 'BY' ParenthesizedColumnList 'ON' ParenthesizedSkewedValueList OptionalStoredAsDirectories 'CURSOR'
|
||||
{
|
||||
if (!$7) {
|
||||
parser.suggestKeywords(['STORED AS DIRECTORIES']);
|
||||
}
|
||||
}
|
||||
| AlterTableLeftSide 'SKEWED' 'BY' ParenthesizedColumnList 'ON' ParenthesizedSkewedValueList OptionalStoredAsDirectories_EDIT
|
||||
| AlterTableLeftSide 'TOUCH' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
| AlterTableLeftSide 'TOUCH' OptionalPartitionSpec_EDIT
|
||||
| AlterTableLeftSide OptionalPartitionOperations_EDIT
|
||||
| AlterTableLeftSide DropOperations_EDIT
|
||||
| AlterTableLeftSide 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['ADD COLUMNS', 'ADD IF NOT EXISTS', 'ADD PARTITION', 'ARCHIVE PARTITION', 'CHANGE',
|
||||
'CLUSTERED BY', 'CONCATENATE', 'COMPACT', 'DISABLE NO_DROP', 'DISABLE OFFLINE', 'DROP', 'ENABLE NO_DROP',
|
||||
'ENABLE OFFLINE', 'EXCHANGE PARTITION', 'NOT SKEWED', 'NOT STORED AS DIRECTORIES', 'PARTITION',
|
||||
'RECOVER PARTITIONS', 'RENAME TO', 'REPLACE COLUMNS', 'SET FILEFORMAT', 'SET LOCATION', 'SET OWNER', 'SET SERDE',
|
||||
'SET SERDEPROPERTIES', 'SET SKEWED LOCATION', 'SET TBLPROPERTIES', 'SKEWED BY', 'TOUCH', 'UNARCHIVE PARTITION']);
|
||||
}
|
||||
| AlterTableLeftSide PartitionSpec 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['ADD COLUMNS', 'CHANGE', 'COMPACT', 'CONCATENATE', 'DISABLE NO_DROP', 'DISABLE OFFLINE',
|
||||
'ENABLE NO_DROP', 'ENABLE OFFLINE', 'RENAME TO PARTITION', 'REPLACE COLUMNS', 'SET FILEFORMAT', 'SET LOCATION',
|
||||
'SET SERDE', 'SET SERDEPROPERTIES']);
|
||||
}
|
||||
| AlterTableLeftSide PartitionSpec AddOrReplace 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['COLUMNS']);
|
||||
}
|
||||
| AlterTableLeftSide PartitionSpec 'SET' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['FILEFORMAT', 'LOCATION', 'SERDE', 'SERDEPROPERTIES']);
|
||||
}
|
||||
| AlterTableLeftSide 'SET' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['FILEFORMAT', 'LOCATION', 'OWNER', 'SERDE', 'SERDEPROPERTIES', 'SKEWED LOCATION', 'TBLPROPERTIES']);
|
||||
}
|
||||
| AlterTableLeftSide PartitionSpec OptionalPartitionOperations_EDIT
|
||||
| AlterTableLeftSide 'RENAME' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['TO']);
|
||||
}
|
||||
| AlterTableLeftSide 'RENAME' 'TO' 'CURSOR'
|
||||
{
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
;
|
||||
|
||||
ParenthesizedStatsList
|
||||
: '(' StatsList ')'
|
||||
;
|
||||
|
||||
ParenthesizedStatsList_EDIT
|
||||
: '(' StatsList_EDIT RightParenthesisOrError
|
||||
;
|
||||
|
||||
StatsList
|
||||
: StatsAssignment
|
||||
| StatsList ',' StatsAssignment
|
||||
;
|
||||
|
||||
StatsList_EDIT
|
||||
: StatsAssignment_EDIT
|
||||
| StatsList ',' StatsAssignment_EDIT
|
||||
| StatsList ',' StatsAssignment_EDIT ',' StatsList
|
||||
| StatsAssignment_EDIT ',' StatsList
|
||||
;
|
||||
|
||||
StatsAssignment
|
||||
: QuotedValue '=' QuotedValue
|
||||
;
|
||||
|
||||
StatsAssignment_EDIT
|
||||
: 'CURSOR'
|
||||
{
|
||||
parser.suggestIdentifiers(['\'avgSize\'', '\'maxSize\'', '\'numDVs\'', '\'numNulls\'']);
|
||||
}
|
||||
;
|
||||
|
||||
OptionalPartitionOperations
|
||||
: 'SET' 'FILEFORMAT' FileFormat
|
||||
| 'SET' HdfsLocation
|
||||
| 'SET' 'TBLPROPERTIES' ParenthesizedPropertyAssignmentList
|
||||
| 'SET' 'SERDE' QuotedValue OptionalWithSerdeproperties
|
||||
| 'SET' 'SERDEPROPERTIES' ParenthesizedPropertyAssignmentList
|
||||
| AddReplaceColumns
|
||||
| 'CONCATENATE'
|
||||
| 'COMPACT' QuotedValue OptionalAndWait OptionalWithOverwriteTblProperties
|
||||
| EnableOrDisable NoDropOrOffline
|
||||
| 'CHANGE' OptionalColumn ColumnIdentifier ColumnSpecification OptionalAfterOrFirst OptionalCascadeOrRestrict
|
||||
{
|
||||
parser.addColumnLocation($3.location, [ $3.identifier ]);
|
||||
}
|
||||
;
|
||||
|
||||
OptionalPartitionOperations_EDIT
|
||||
: AddReplaceColumns_EDIT
|
||||
| 'CHANGE' OptionalColumn 'CURSOR'
|
||||
{
|
||||
if (!$2) {
|
||||
parser.suggestKeywords(['COLUMN']);
|
||||
}
|
||||
parser.suggestColumns();
|
||||
}
|
||||
| 'CHANGE' OptionalColumn ColumnIdentifier ColumnSpecification_EDIT OptionalAfterOrFirst OptionalCascadeOrRestrict
|
||||
{
|
||||
parser.addColumnLocation($3.location, [ $3.identifier ]);
|
||||
}
|
||||
| 'CHANGE' OptionalColumn ColumnIdentifier ColumnSpecification OptionalAfterOrFirst OptionalCascadeOrRestrict 'CURSOR'
|
||||
{
|
||||
if (!$5 && !$6) {
|
||||
if ($4.suggestKeywords) {
|
||||
var keywords = parser.createWeightedKeywords($4.suggestKeywords, 3);
|
||||
keywords = keywords.concat([{ value: 'AFTER', weight: 2 }, { value: 'FIRST', weight: 2 }, { value: 'CASCADE', weight: 1 }, { value: 'RESTRICT', weight: 1 }]);
|
||||
parser.suggestKeywords(keywords);
|
||||
} else {
|
||||
parser.suggestKeywords([{ value: 'AFTER', weight: 2 }, { value: 'FIRST', weight: 2 }, { value: 'CASCADE', weight: 1 }, { value: 'RESTRICT', weight: 1 }]);
|
||||
}
|
||||
} else if ($5 && !$6) {
|
||||
parser.suggestKeywords(['CASCADE', 'RESTRICT']);
|
||||
}
|
||||
parser.addColumnLocation($3.location, [ $3.identifier ]);
|
||||
}
|
||||
| 'CHANGE' OptionalColumn ColumnIdentifier ColumnSpecification OptionalAfterOrFirst_EDIT OptionalCascadeOrRestrict
|
||||
{
|
||||
parser.addColumnLocation($3.location, [ $3.identifier ]);
|
||||
}
|
||||
| 'COMPACT' QuotedValue OptionalAndWait OptionalWithOverwriteTblProperties 'CURSOR'
|
||||
{
|
||||
if (!$3 && !$4) {
|
||||
parser.suggestKeywords(['AND WAIT', 'WITH OVERWRITE TBLPROPERTIES']);
|
||||
} else if (!$4) {
|
||||
parser.suggestKeywords(['WITH OVERWRITE TBLPROPERTIES']);
|
||||
}
|
||||
}
|
||||
| 'COMPACT' QuotedValue AndWait_EDIT OptionalWithOverwriteTblProperties
|
||||
| 'COMPACT' QuotedValue OptionalAndWait WithOverwriteTblProperties_EDIT
|
||||
| EnableOrDisable 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['NO_DROP', 'OFFLINE']);
|
||||
}
|
||||
| EnableOrDisable NoDropOrOffline_EDIT
|
||||
| 'SET' 'FILEFORMAT' 'CURSOR'
|
||||
{
|
||||
parser.suggestFileFormats();
|
||||
}
|
||||
| 'SET' HdfsLocation_EDIT
|
||||
| 'SET' 'SERDE' QuotedValue OptionalWithSerdeproperties 'CURSOR'
|
||||
{
|
||||
if (!$4) {
|
||||
parser.suggestKeywords(['WITH SERDEPROPERTIES']);
|
||||
}
|
||||
}
|
||||
| 'SET' 'SERDE' QuotedValue WithSerdeproperties_EDIT
|
||||
;
|
||||
|
||||
OptionalAndWait
|
||||
:
|
||||
| 'AND' 'WAIT'
|
||||
;
|
||||
|
||||
AndWait_EDIT
|
||||
: 'AND' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['WAIT']);
|
||||
}
|
||||
;
|
||||
|
||||
OptionalWithOverwriteTblProperties
|
||||
:
|
||||
| 'WITH' 'OVERWRITE' 'TBLPROPERTIES' ParenthesizedPropertyAssignmentList
|
||||
;
|
||||
|
||||
WithOverwriteTblProperties_EDIT
|
||||
: 'WITH' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['OVERWRITE TBLPROPERTIES']);
|
||||
}
|
||||
| 'WITH' 'OVERWRITE' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['TBLPROPERTIES']);
|
||||
}
|
||||
;
|
||||
|
||||
AddReplaceColumns
|
||||
: AddOrReplace 'COLUMNS' ParenthesizedColumnSpecificationList OptionalCascadeOrRestrict
|
||||
;
|
||||
|
||||
AddReplaceColumns_EDIT
|
||||
: AddOrReplace 'COLUMNS' ParenthesizedColumnSpecificationList_EDIT OptionalCascadeOrRestrict
|
||||
| AddOrReplace 'COLUMNS' ParenthesizedColumnSpecificationList OptionalCascadeOrRestrict 'CURSOR'
|
||||
{
|
||||
if (!$4) {
|
||||
parser.suggestKeywords(['CASCADE', 'RESTRICT']);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
ExchangeSpecification
|
||||
: 'EXCHANGE' ExchangePartitionSpec 'WITH' 'TABLE' RegularOrBackTickedSchemaQualifiedName
|
||||
;
|
||||
|
||||
ExchangeSpecification_EDIT
|
||||
: 'EXCHANGE' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
| 'EXCHANGE' ExchangePartitionSpec 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['WITH TABLE']);
|
||||
}
|
||||
| 'EXCHANGE' ExchangePartitionSpec 'WITH' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['TABLE']);
|
||||
}
|
||||
| 'EXCHANGE' ExchangePartitionSpec 'WITH' 'TABLE' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'EXCHANGE' ExchangePartitionSpec 'WITH' 'TABLE' RegularOrBackTickedSchemaQualifiedName_EDIT
|
||||
| 'EXCHANGE' ExchangePartitionSpec_EDIT
|
||||
| 'EXCHANGE' ExchangePartitionSpec_EDIT 'WITH' 'TABLE' RegularOrBackTickedSchemaQualifiedName
|
||||
;
|
||||
|
||||
ExchangePartitionSpec
|
||||
: 'PARTITION' '(' OneOrMorePartitionSpecLists ')'
|
||||
| 'PARTITION' '(' PartitionSpecList ')'
|
||||
;
|
||||
|
||||
ExchangePartitionSpec_EDIT
|
||||
: 'PARTITION' '(' OneOrMorePartitionSpecLists_EDIT RightParenthesisOrError
|
||||
| 'PARTITION' '(' PartitionSpecList_EDIT RightParenthesisOrError
|
||||
;
|
||||
|
||||
OneOrMorePartitionSpecLists
|
||||
: '(' PartitionSpecList ')'
|
||||
| OneOrMorePartitionSpecLists ',' '(' PartitionSpecList ')'
|
||||
;
|
||||
|
||||
OneOrMorePartitionSpecLists_EDIT
|
||||
: '(' PartitionSpecList_EDIT RightParenthesisOrError
|
||||
| OneOrMorePartitionSpecLists ',' '(' PartitionSpecList_EDIT RightParenthesisOrError
|
||||
;
|
||||
|
||||
DropOperations
|
||||
: 'DROP' OptionalIfExists OneOrMorePartitionSpecs OptionalPurge
|
||||
| 'DROP' 'CONSTRAINT' RegularOrBacktickedIdentifier
|
||||
;
|
||||
|
||||
DropOperations_EDIT
|
||||
: 'DROP' OptionalIfExists 'CURSOR'
|
||||
{
|
||||
if (!$2) {
|
||||
parser.suggestKeywords([{ value: 'CONSTRAINT', weight: 1}, { value: 'PARTITION', weight: 1}, { value: 'IF EXISTS', weight: 2 }]);
|
||||
} else {
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
}
|
||||
| 'DROP' OptionalIfExists OneOrMorePartitionSpecs_EDIT OptionalPurge
|
||||
| 'DROP' OptionalIfExists OneOrMorePartitionSpecs OptionalPurge 'CURSOR'
|
||||
{
|
||||
if (!$4) {
|
||||
parser.suggestKeywords(['PURGE']);
|
||||
}
|
||||
}
|
||||
| 'DROP' 'CONSTRAINT' 'CURSOR'
|
||||
| 'DROP' OptionalIfExists_EDIT
|
||||
| 'DROP' ColumnIdentifier_EDIT
|
||||
;
|
||||
|
||||
AlterTableLeftSide
|
||||
: 'ALTER' 'TABLE' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
;
|
||||
|
||||
AlterTableLeftSide_EDIT
|
||||
: 'ALTER' 'TABLE' SchemaQualifiedTableIdentifier_EDIT
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyTables = true;
|
||||
}
|
||||
}
|
||||
| 'ALTER' 'TABLE' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables({ onlyTables: true });
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
;
|
||||
|
||||
AddOrReplace
|
||||
: 'ADD'
|
||||
| 'REPLACE'
|
||||
;
|
||||
|
||||
OptionalAfterOrFirst
|
||||
:
|
||||
| AfterOrFirst ColumnIdentifier
|
||||
;
|
||||
|
||||
AfterOrFirst
|
||||
: 'AFTER'
|
||||
| 'FIRST'
|
||||
;
|
||||
|
||||
OptionalAfterOrFirst_EDIT
|
||||
: AfterOrFirst 'CURSOR'
|
||||
{
|
||||
parser.suggestColumns();
|
||||
}
|
||||
| AfterOrFirst ColumnIdentifier_EDIT
|
||||
;
|
||||
|
||||
OptionalColumn
|
||||
:
|
||||
| 'COLUMN'
|
||||
;
|
||||
|
||||
EnableOrDisable
|
||||
: 'ENABLE'
|
||||
| 'DISABLE'
|
||||
;
|
||||
|
||||
NoDropOrOffline
|
||||
: 'NO_DROP' OptionalCascade
|
||||
| 'OFFLINE'
|
||||
;
|
||||
|
||||
NoDropOrOffline_EDIT
|
||||
: 'NO_DROP' OptionalCascade 'CURSOR'
|
||||
{
|
||||
if (!$2) {
|
||||
parser.suggestKeywords(['CASCADE']);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
ArchiveOrUnArchive
|
||||
: 'ARCHIVE'
|
||||
| 'UNARCHIVE'
|
||||
;
|
||||
|
||||
OneOrMorePartitionSpecs
|
||||
: PartitionSpec
|
||||
| OneOrMorePartitionSpecs ',' PartitionSpec
|
||||
;
|
||||
|
||||
OneOrMorePartitionSpecs_EDIT
|
||||
: PartitionSpec_EDIT
|
||||
| OneOrMorePartitionSpecs ',' AnyCursor
|
||||
{
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
| OneOrMorePartitionSpecs ',' AnyCursor ',' OneOrMorePartitionSpecs
|
||||
{
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
| AnyCursor ',' OneOrMorePartitionSpecs
|
||||
{
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
| OneOrMorePartitionSpecs ',' PartitionSpec_EDIT
|
||||
| PartitionSpec_EDIT ',' OneOrMorePartitionSpecs
|
||||
| OneOrMorePartitionSpecs ',' PartitionSpec_EDIT ',' OneOrMorePartitionSpecs
|
||||
;
|
||||
|
||||
OptionalPartitionSpecs
|
||||
:
|
||||
| PartitionSpecWithLocationList
|
||||
;
|
||||
|
||||
PartitionSpecWithLocationList
|
||||
: PartitionSpecWithLocation
|
||||
| PartitionSpecWithLocationList PartitionSpecWithLocation -> $2
|
||||
;
|
||||
|
||||
OptionalPartitionSpecs_EDIT
|
||||
: PartitionSpecWithLocation_EDIT
|
||||
| PartitionSpecWithLocation_EDIT PartitionSpecWithLocationList
|
||||
| PartitionSpecWithLocationList PartitionSpecWithLocation_EDIT
|
||||
| PartitionSpecWithLocationList PartitionSpecWithLocation_EDIT PartitionSpecWithLocationList
|
||||
;
|
||||
|
||||
PartitionSpecWithLocation_EDIT
|
||||
: PartitionSpec HdfsLocation_EDIT
|
||||
| PartitionSpec_EDIT OptionalHdfsLocation
|
||||
;
|
||||
|
||||
PartitionSpecWithLocation
|
||||
: PartitionSpec OptionalHdfsLocation
|
||||
{
|
||||
if (!$2) {
|
||||
$$ = { suggestKeywords: ['LOCATION'] };
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
ParenthesizedSkewedLocationList
|
||||
: '(' SkewedLocationList ')'
|
||||
;
|
||||
|
||||
ParenthesizedSkewedLocationList_EDIT
|
||||
: '(' SkewedLocationList_EDIT RightParenthesisOrError
|
||||
;
|
||||
|
||||
SkewedLocationList
|
||||
: SkewedLocation
|
||||
| SkewedLocationList ',' SkewedLocation
|
||||
;
|
||||
|
||||
SkewedLocationList_EDIT
|
||||
: SkewedLocation_EDIT
|
||||
| SkewedLocationList ',' SkewedLocation_EDIT
|
||||
| SkewedLocationList ',' SkewedLocation_EDIT ',' SkewedLocationList
|
||||
| SkewedLocation_EDIT ',' SkewedLocationList
|
||||
;
|
||||
|
||||
SkewedLocation
|
||||
: ColumnReference '=' QuotedValue
|
||||
;
|
||||
|
||||
SkewedLocation_EDIT
|
||||
: AnyCursor
|
||||
{
|
||||
parser.suggestColumns();
|
||||
}
|
||||
| ColumnReference_EDIT
|
||||
| AnyCursor '=' QuotedValue
|
||||
{
|
||||
parser.suggestColumns();
|
||||
}
|
||||
| ColumnReference_EDIT '=' QuotedValue
|
||||
| ColumnReferences '=' QuotedValue
|
||||
;
|
||||
|
||||
OptionalStoredAsDirectories
|
||||
:
|
||||
| 'STORED_AS_DIRECTORIES'
|
||||
;
|
||||
|
||||
OptionalStoredAsDirectories_EDIT
|
||||
: 'STORED' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['AS DIRECTORIES']);
|
||||
}
|
||||
| 'STORED' 'AS' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['DIRECTORIES']);
|
||||
}
|
||||
;
|
||||
|
||||
AlterView
|
||||
: AlterViewLeftSide 'SET' 'TBLPROPERTIES' ParenthesizedPropertyAssignmentList
|
||||
| AlterViewLeftSide 'AS' QuerySpecification
|
||||
;
|
||||
|
||||
AlterView_EDIT
|
||||
: AlterViewLeftSide_EDIT
|
||||
| AlterViewLeftSide 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['AS', 'SET TBLPROPERTIES']);
|
||||
}
|
||||
| AlterViewLeftSide 'SET' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['TBLPROPERTIES']);
|
||||
}
|
||||
| AlterViewLeftSide 'AS' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
| AlterViewLeftSide 'AS' QuerySpecification_EDIT
|
||||
;
|
||||
|
||||
|
||||
AlterViewLeftSide
|
||||
: 'ALTER' 'VIEW' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
;
|
||||
|
||||
AlterViewLeftSide_EDIT
|
||||
: 'ALTER' 'VIEW' SchemaQualifiedTableIdentifier_EDIT
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyViews = true;
|
||||
}
|
||||
}
|
||||
| 'ALTER' 'VIEW' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables({ onlyViews: true });
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
;
|
||||
|
||||
Msck
|
||||
: 'MSCK' OptionalRepair 'TABLE' SchemaQualifiedTableIdentifier OptionalAddDropSyncPartitions
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
Msck_EDIT
|
||||
: 'MSCK' OptionalRepair 'CURSOR'
|
||||
{
|
||||
if (!$2) {
|
||||
parser.suggestKeywords(['TABLE', 'REPAIR TABLE']);
|
||||
} else {
|
||||
parser.suggestKeywords(['TABLE']);
|
||||
}
|
||||
}
|
||||
| 'MSCK' OptionalRepair 'TABLE' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables({ onlyTables: true });
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'MSCK' OptionalRepair 'TABLE' SchemaQualifiedTableIdentifier_EDIT
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyViews = true;
|
||||
}
|
||||
}
|
||||
| 'MSCK' OptionalRepair 'TABLE' SchemaQualifiedTableIdentifier AddDropSyncPartitions_EDIT
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
| 'MSCK' OptionalRepair 'TABLE' SchemaQualifiedTableIdentifier OptionalAddDropSyncPartitions 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
if (!$5) {
|
||||
parser.suggestKeywords(['ADD PARTITIONS', 'DROP PARTITIONS', 'SYNC PARTITIONS']);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
OptionalRepair
|
||||
:
|
||||
| 'REPAIR'
|
||||
;
|
||||
|
||||
OptionalAddDropSyncPartitions
|
||||
:
|
||||
| AddDropOrSync 'PARTITIONS'
|
||||
;
|
||||
|
||||
AddDropSyncPartitions_EDIT
|
||||
: AddDropOrSync 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['PARTITIONS']);
|
||||
}
|
||||
;
|
||||
|
||||
AddDropOrSync
|
||||
: 'ADD'
|
||||
| 'DROP'
|
||||
| 'SYNC'
|
||||
;
|
||||
|
||||
ReloadFunction
|
||||
: 'RELOAD' 'FUNCTION'
|
||||
;
|
||||
|
||||
ReloadFunction_EDIT
|
||||
: 'RELOAD' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['FUNCTION']);
|
||||
}
|
||||
;
|
||||
|
||||
NullableComment
|
||||
: QuotedValue
|
||||
| 'NULL'
|
||||
;
|
236
src/jison/sql/hive/sql_analyze.jison
Normal file
236
src/jison/sql/hive/sql_analyze.jison
Normal file
@ -0,0 +1,236 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: AnalyzeStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: AnalyzeStatement_EDIT
|
||||
;
|
||||
|
||||
SqlStatement
|
||||
: ExplainClause DataDefinition
|
||||
| ExplainClause DataManipulation
|
||||
| ExplainClause QuerySpecification
|
||||
;
|
||||
|
||||
SqlStatement_EDIT
|
||||
: ExplainClause_EDIT
|
||||
| ExplainClause DataDefinition_EDIT
|
||||
| ExplainClause DataManipulation_EDIT
|
||||
| ExplainClause QuerySpecification_EDIT
|
||||
| ExplainClause_EDIT DataDefinition
|
||||
| ExplainClause_EDIT DataManipulation
|
||||
| ExplainClause_EDIT QuerySpecification
|
||||
;
|
||||
|
||||
AnalyzeStatement
|
||||
: 'ANALYZE' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'COMPUTE' 'STATISTICS' OptionalForColumns OptionalCacheMetadata OptionalNoscan
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
;
|
||||
|
||||
AnalyzeStatement_EDIT
|
||||
: 'ANALYZE' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['TABLE']);
|
||||
}
|
||||
| 'ANALYZE' 'TABLE' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables({ onlyTables: true });
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'ANALYZE' 'TABLE' SchemaQualifiedTableIdentifier_EDIT OptionalPartitionSpec
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyTables = true;
|
||||
}
|
||||
}
|
||||
| 'ANALYZE' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec_EDIT
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
| 'ANALYZE' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
if (!$4) {
|
||||
parser.suggestKeywords([{ value: 'PARTITION', weight: 2 }, { value: 'COMPUTE STATISTICS', weight: 1 }]);
|
||||
} else {
|
||||
parser.suggestKeywords(['COMPUTE STATISTICS']);
|
||||
}
|
||||
}
|
||||
| 'ANALYZE' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'COMPUTE' 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
parser.suggestKeywords(['STATISTICS']);
|
||||
}
|
||||
| 'ANALYZE' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'COMPUTE' 'STATISTICS' 'CURSOR' OptionalForColumns OptionalCacheMetadata OptionalNoscan
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
parser.suggestKeywords(parser.getKeywordsForOptionalsLR([$8, $9, $10], [{ value: 'FOR COLUMNS', weight: 3 }, { value: 'CACHE METADATA', weight: 2 }, { value: 'NOSCAN', weight: 1 }]));
|
||||
}
|
||||
| 'ANALYZE' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'COMPUTE' 'STATISTICS' ForColumns 'CURSOR' OptionalCacheMetadata OptionalNoscan
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
parser.suggestKeywords(parser.getKeywordsForOptionalsLR([$9, $10], [{ value: 'CACHE METADATA', weight: 2 }, { value: 'NOSCAN', weight: 1 }]));
|
||||
}
|
||||
| 'ANALYZE' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'COMPUTE' 'STATISTICS' OptionalForColumns CacheMetadata 'CURSOR' OptionalNoscan
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
parser.suggestKeywords(parser.getKeywordsForOptionalsLR([$10], [{ value: 'NOSCAN', weight: 1 }]));
|
||||
}
|
||||
| 'ANALYZE' 'CURSOR' SchemaQualifiedTableIdentifier OptionalPartitionSpec
|
||||
{
|
||||
parser.suggestKeywords(['TABLE']);
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
| 'ANALYZE' 'CURSOR' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'COMPUTE' 'STATISTICS' OptionalForColumns OptionalCacheMetadata OptionalNoscan
|
||||
{
|
||||
parser.suggestKeywords(['TABLE']);
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
| 'ANALYZE' 'TABLE' SchemaQualifiedTableIdentifier_EDIT OptionalPartitionSpec 'COMPUTE' 'STATISTICS' OptionalForColumns OptionalCacheMetadata OptionalNoscan
|
||||
| 'ANALYZE' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec_EDIT 'COMPUTE' 'STATISTICS' OptionalForColumns OptionalCacheMetadata OptionalNoscan
|
||||
| 'ANALYZE' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'COMPUTE' 'STATISTICS' ForColumns_EDIT OptionalCacheMetadata OptionalNoscan
|
||||
| 'ANALYZE' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'COMPUTE' 'STATISTICS' OptionalForColumns CacheMetadata_EDIT OptionalNoscan
|
||||
;
|
||||
|
||||
OptionalForColumns
|
||||
:
|
||||
| ForColumns
|
||||
;
|
||||
|
||||
ForColumns
|
||||
: 'FOR' 'COLUMNS'
|
||||
;
|
||||
|
||||
ForColumns_EDIT
|
||||
: 'FOR' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['COLUMNS']);
|
||||
}
|
||||
;
|
||||
|
||||
OptionalCacheMetadata
|
||||
:
|
||||
| CacheMetadata
|
||||
;
|
||||
|
||||
CacheMetadata
|
||||
: 'CACHE' 'METADATA'
|
||||
;
|
||||
|
||||
CacheMetadata_EDIT
|
||||
: 'CACHE' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['METADATA']);
|
||||
}
|
||||
;
|
||||
|
||||
OptionalNoscan
|
||||
:
|
||||
| 'NOSCAN'
|
||||
;
|
||||
|
||||
ExplainClause
|
||||
: 'EXPLAIN' OptionalExplainTypes
|
||||
;
|
||||
|
||||
ExplainClause_EDIT
|
||||
: 'EXPLAIN' OptionalExplainTypes 'CURSOR'
|
||||
{
|
||||
if (!$2) {
|
||||
parser.suggestDdlAndDmlKeywords([
|
||||
{ value: 'AST', weight: 2 },
|
||||
{ value: 'AUTHORIZATION', weight: 2 },
|
||||
{ value: 'CBO', weight: 2 },
|
||||
{ value: 'DEPENDENCY', weight: 2 },
|
||||
{ value: 'EXTENDED', weight: 2 },
|
||||
{ value: 'FORMATTED CBO', weight: 2 },
|
||||
{ value: 'LOCKS', weight: 2 },
|
||||
{ value: 'VECTORIZATION', weight: 2 }
|
||||
]);
|
||||
} else if ($2 && $2.suggestKeywords) {
|
||||
parser.suggestDdlAndDmlKeywords($2.suggestKeywords);
|
||||
} else {
|
||||
parser.suggestDdlAndDmlKeywords();
|
||||
}
|
||||
}
|
||||
| 'EXPLAIN' 'FORMATTED' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['CBO']);
|
||||
}
|
||||
;
|
||||
|
||||
OptionalExplainTypes
|
||||
:
|
||||
| 'AST'
|
||||
| 'AUTHORIZATION'
|
||||
| 'FORMATTED' 'CBO' OptionalCostOrJoincost
|
||||
{
|
||||
if (!$3) {
|
||||
$$ = { suggestKeywords: ['COST', 'JOINCOST'] };
|
||||
}
|
||||
}
|
||||
| 'CBO' OptionalCostOrJoincost
|
||||
{
|
||||
if (!$2) {
|
||||
$$ = { suggestKeywords: ['COST', 'JOINCOST'] };
|
||||
}
|
||||
}
|
||||
| 'DEPENDENCY'
|
||||
| 'EXTENDED'
|
||||
| 'LOCKS'
|
||||
| 'VECTORIZATION' OptionalOnly OptionalVectorizationTypes
|
||||
{
|
||||
var keywords = [];
|
||||
if (!$3) {
|
||||
keywords = keywords.concat([
|
||||
{ weight: 1, value: 'DETAIL' },
|
||||
{ weight: 1, value: 'EXPRESSION' },
|
||||
{ weight: 1, value: 'OPERATOR' },
|
||||
{ weight: 1, value: 'SUMMARY' }
|
||||
]);
|
||||
}
|
||||
if (!$2) {
|
||||
keywords.push({ weight: 2, value: 'ONLY' });
|
||||
}
|
||||
if (keywords.length) {
|
||||
$$ = { suggestKeywords: keywords };
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
OptionalCostOrJoincost
|
||||
:
|
||||
| 'COST'
|
||||
| 'JOINCOST'
|
||||
;
|
||||
|
||||
OptionalOnly
|
||||
:
|
||||
| 'ONLY'
|
||||
;
|
||||
|
||||
OptionalVectorizationTypes
|
||||
:
|
||||
| 'DETAIL'
|
||||
| 'EXPRESSION'
|
||||
| 'OPERATOR'
|
||||
| 'SUMMARY'
|
||||
;
|
1629
src/jison/sql/hive/sql_create.jison
Normal file
1629
src/jison/sql/hive/sql_create.jison
Normal file
File diff suppressed because it is too large
Load Diff
348
src/jison/sql/hive/sql_drop.jison
Normal file
348
src/jison/sql/hive/sql_drop.jison
Normal file
@ -0,0 +1,348 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: DropStatement
|
||||
| AbortStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: DropStatement_EDIT
|
||||
| AbortStatement_EDIT
|
||||
;
|
||||
|
||||
DataManipulation
|
||||
: DeleteStatement
|
||||
;
|
||||
|
||||
DataManipulation_EDIT
|
||||
: DeleteStatement_EDIT
|
||||
;
|
||||
|
||||
DropStatement
|
||||
: DropDatabaseStatement
|
||||
| DropFunctionStatement
|
||||
| DropRoleStatement
|
||||
| DropTableStatement
|
||||
| DropIndexStatement
|
||||
| DropMacroStatement
|
||||
| DropMaterializedViewStatement
|
||||
| DropViewStatement
|
||||
| TruncateTableStatement
|
||||
;
|
||||
|
||||
DropStatement_EDIT
|
||||
: DropDatabaseStatement_EDIT
|
||||
| DropFunctionStatement_EDIT
|
||||
| DropTableStatement_EDIT
|
||||
| DropIndexStatement_EDIT
|
||||
| DropMacroStatement_EDIT
|
||||
| DropMaterializedViewStatement_EDIT
|
||||
| DropViewStatement_EDIT
|
||||
| TruncateTableStatement_EDIT
|
||||
| 'DROP' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['DATABASE', 'FUNCTION', 'INDEX', 'MATERIALIZED VIEW', 'ROLE', 'SCHEMA', 'TABLE', 'TEMPORARY FUNCTION', 'TEMPORARY MACRO', 'VIEW']);
|
||||
}
|
||||
;
|
||||
|
||||
DropDatabaseStatement
|
||||
: 'DROP' DatabaseOrSchema OptionalIfExists RegularOrBacktickedIdentifier OptionalCascadeOrRestrict
|
||||
;
|
||||
|
||||
DropDatabaseStatement_EDIT
|
||||
: 'DROP' DatabaseOrSchema OptionalIfExists
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists_EDIT
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
parser.suggestDatabases();
|
||||
}
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists RegularOrBacktickedIdentifier 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['CASCADE', 'RESTRICT']);
|
||||
}
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists_EDIT RegularOrBacktickedIdentifier OptionalCascadeOrRestrict
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists 'CURSOR' RegularOrBacktickedIdentifier OptionalCascadeOrRestrict
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
DropFunctionStatement
|
||||
: 'DROP' 'FUNCTION' OptionalIfExists SchemaQualifiedIdentifier
|
||||
| 'DROP' 'TEMPORARY' 'FUNCTION' OptionalIfExists RegularIdentifier
|
||||
;
|
||||
|
||||
DropFunctionStatement_EDIT
|
||||
: 'DROP' 'FUNCTION' OptionalIfExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'DROP' 'FUNCTION' OptionalIfExists 'CURSOR' SchemaQualifiedIdentifier
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'DROP' 'FUNCTION' OptionalIfExists_EDIT
|
||||
| 'DROP' 'FUNCTION' OptionalIfExists_EDIT SchemaQualifiedIdentifier
|
||||
| 'DROP' 'FUNCTION' OptionalIfExists SchemaQualifiedIdentifier_EDIT
|
||||
| 'DROP' 'TEMPORARY' 'FUNCTION' OptionalIfExists 'CURSOR'
|
||||
{
|
||||
if (!$4) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'DROP' 'TEMPORARY' 'FUNCTION' OptionalIfExists_EDIT
|
||||
;
|
||||
|
||||
DropRoleStatement
|
||||
: 'DROP' 'ROLE' RegularIdentifier
|
||||
;
|
||||
|
||||
DropTableStatement
|
||||
: 'DROP' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier OptionalPurge
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
DropTableStatement_EDIT
|
||||
: 'DROP' 'TABLE' OptionalIfExists_EDIT
|
||||
| 'DROP' 'TABLE' OptionalIfExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
parser.suggestTables({ onlyTables: true });
|
||||
parser.suggestDatabases({
|
||||
appendDot: true
|
||||
});
|
||||
}
|
||||
| 'DROP' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier_EDIT OptionalPurge
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyTables = true;
|
||||
}
|
||||
}
|
||||
| 'DROP' 'TABLE' OptionalIfExists_EDIT SchemaQualifiedTableIdentifier OptionalPurge
|
||||
| 'DROP' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier OptionalPurge 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
if (!$5) {
|
||||
parser.suggestKeywords(['PURGE']);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
OptionalPurge
|
||||
:
|
||||
| 'PURGE'
|
||||
;
|
||||
|
||||
DropIndexStatement
|
||||
: 'DROP' 'INDEX' OptionalIfExists RegularOrBacktickedIdentifier 'ON' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($6);
|
||||
}
|
||||
;
|
||||
|
||||
DropIndexStatement_EDIT
|
||||
: 'DROP' 'INDEX' OptionalIfExists 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
| 'DROP' 'INDEX' OptionalIfExists_EDIT
|
||||
| 'DROP' 'INDEX' OptionalIfExists RegularOrBacktickedIdentifier 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['ON']);
|
||||
}
|
||||
| 'DROP' 'INDEX' OptionalIfExists RegularOrBacktickedIdentifier 'ON' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'DROP' 'INDEX' OptionalIfExists RegularOrBacktickedIdentifier 'ON' SchemaQualifiedTableIdentifier_EDIT
|
||||
;
|
||||
|
||||
DropMacroStatement
|
||||
: 'DROP' 'TEMPORARY' 'MACRO' OptionalIfExists RegularIdentifier
|
||||
;
|
||||
|
||||
DropMacroStatement_EDIT
|
||||
: 'DROP' 'TEMPORARY' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['FUNCTION', 'MACRO']);
|
||||
}
|
||||
| 'DROP' 'TEMPORARY' 'MACRO' OptionalIfExists 'CURSOR'
|
||||
{
|
||||
if (!$4) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'DROP' 'TEMPORARY' 'MACRO' OptionalIfExists_EDIT
|
||||
;
|
||||
|
||||
|
||||
DropMaterializedViewStatement
|
||||
: 'DROP' 'MATERIALIZED' 'VIEW' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
DropMaterializedViewStatement_EDIT
|
||||
: 'DROP' 'MATERIALIZED' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['VIEW']);
|
||||
}
|
||||
| 'DROP' 'MATERIALIZED' 'VIEW' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables({ onlyViews: true });
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'DROP' 'MATERIALIZED' VIEW SchemaQualifiedTableIdentifier_EDIT
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyViews = true;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
DropViewStatement
|
||||
: 'DROP' 'VIEW' OptionalIfExists SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
DropViewStatement_EDIT
|
||||
: 'DROP' 'VIEW' OptionalIfExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
parser.suggestTables({ onlyViews: true });
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'DROP' 'VIEW' OptionalIfExists 'CURSOR' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($5);
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'DROP' 'VIEW' OptionalIfExists_EDIT
|
||||
| 'DROP' 'VIEW' OptionalIfExists_EDIT SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
| 'DROP' 'VIEW' OptionalIfExists SchemaQualifiedTableIdentifier_EDIT
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyViews = true;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
TruncateTableStatement
|
||||
: 'TRUNCATE' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
;
|
||||
|
||||
TruncateTableStatement_EDIT
|
||||
: 'TRUNCATE' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['TABLE']);
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' 'CURSOR' OptionalPartitionSpec
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' SchemaQualifiedTableIdentifier_EDIT OptionalPartitionSpec
|
||||
| 'TRUNCATE' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
if (!$4) {
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec_EDIT
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' 'CURSOR' SchemaQualifiedTableIdentifier OptionalPartitionSpec
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
DeleteStatement
|
||||
: 'DELETE' 'FROM' SchemaQualifiedTableIdentifier OptionalWhereClause
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
;
|
||||
|
||||
DeleteStatement_EDIT
|
||||
: 'DELETE' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['FROM']);
|
||||
}
|
||||
| 'DELETE' 'FROM' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'DELETE' 'FROM' SchemaQualifiedTableIdentifier 'CURSOR' OptionalWhereClause
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
if (!$5) {
|
||||
parser.suggestKeywords(['WHERE']);
|
||||
}
|
||||
}
|
||||
| 'DELETE' 'FROM' SchemaQualifiedTableIdentifier_EDIT OptionalWhereClause
|
||||
| 'DELETE' 'FROM' SchemaQualifiedTableIdentifier WhereClause_EDIT
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
;
|
||||
|
||||
AbortStatement
|
||||
: 'ABORT' 'TRANSACTIONS' TransactionIdList
|
||||
;
|
||||
|
||||
AbortStatement_EDIT
|
||||
: 'ABORT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['TRANSACTIONS']);
|
||||
}
|
||||
;
|
||||
|
||||
TransactionIdList
|
||||
: UnsignedNumericLiteral
|
||||
| TransactionIdList ',' UnsignedNumericLiteral
|
||||
;
|
169
src/jison/sql/hive/sql_error.jison
Normal file
169
src/jison/sql/hive/sql_error.jison
Normal file
@ -0,0 +1,169 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
SqlStatements
|
||||
: error
|
||||
| NonStartingToken error // Having just ': error' does not work for some reason, jison bug?
|
||||
;
|
||||
|
||||
SqlStatement_EDIT
|
||||
: AnyCursor error
|
||||
{
|
||||
parser.suggestDdlAndDmlKeywords(['EXPLAIN', 'FROM']);
|
||||
}
|
||||
;
|
||||
|
||||
SelectStatement
|
||||
: 'SELECT' OptionalAllOrDistinct SelectList_ERROR TableExpression
|
||||
| 'SELECT' OptionalAllOrDistinct SelectList TableExpression_ERROR
|
||||
;
|
||||
|
||||
SelectStatement_EDIT
|
||||
: 'SELECT' OptionalAllOrDistinct SelectList_ERROR_EDIT TableExpression
|
||||
{
|
||||
parser.selectListNoTableSuggest($3, $2);
|
||||
}
|
||||
| 'SELECT' OptionalAllOrDistinct SelectList_ERROR TableExpression_EDIT
|
||||
;
|
||||
|
||||
SelectList_ERROR
|
||||
: ErrorList
|
||||
| SelectList ',' ErrorList
|
||||
| ErrorList ',' SelectList ',' ErrorList
|
||||
| ErrorList ',' SelectList
|
||||
| SelectList ',' ErrorList ',' SelectList
|
||||
;
|
||||
|
||||
SelectList_ERROR_EDIT
|
||||
: ErrorList ',' SelectList_EDIT -> $3
|
||||
| SelectList ',' ErrorList ',' SelectList_EDIT -> $5
|
||||
| ErrorList ',' SelectList ',' ErrorList ',' SelectList_EDIT -> $7
|
||||
| ErrorList ',' AnyCursor
|
||||
{
|
||||
$$ = { cursorAtStart : false, suggestFunctions: true, suggestColumns: true, suggestAggregateFunctions: true };
|
||||
}
|
||||
| SelectList ',' ErrorList ',' AnyCursor
|
||||
{
|
||||
$$ = { cursorAtStart : false, suggestFunctions: true, suggestColumns: true, suggestAggregateFunctions: true };
|
||||
}
|
||||
| ErrorList ',' SelectList ',' Errors ',' AnyCursor
|
||||
{
|
||||
$$ = { cursorAtStart : true, suggestFunctions: true, suggestColumns: true, suggestAggregateFunctions: true };
|
||||
}
|
||||
;
|
||||
|
||||
SetSpecification
|
||||
: 'SET' SetOption '=' error
|
||||
;
|
||||
|
||||
ErrorList
|
||||
: error
|
||||
| Errors ',' error
|
||||
;
|
||||
|
||||
LateralView
|
||||
: 'LATERAL' 'VIEW' OptionalOuter ArbitraryFunction RegularOrBacktickedIdentifier 'AS' error -> { }
|
||||
| 'LATERAL' 'VIEW' OptionalOuter ArbitraryFunction error -> { }
|
||||
| 'LATERAL' 'VIEW' OptionalOuter error -> { }
|
||||
| 'LATERAL' error -> { }
|
||||
;
|
||||
|
||||
JoinType_EDIT
|
||||
: 'FULL' 'CURSOR' error
|
||||
{
|
||||
parser.suggestKeywords(['JOIN', 'OUTER JOIN']);
|
||||
}
|
||||
| 'LEFT' 'CURSOR' error
|
||||
{
|
||||
parser.suggestKeywords(['JOIN', 'OUTER JOIN', 'SEMI JOIN']);
|
||||
}
|
||||
| 'RIGHT' 'CURSOR' error
|
||||
{
|
||||
parser.suggestKeywords(['JOIN', 'OUTER JOIN']);
|
||||
}
|
||||
;
|
||||
|
||||
OptionalSelectConditions_EDIT
|
||||
: WhereClause error 'CURSOR' OptionalGroupByClause OptionalHavingClause OptionalWindowClause OptionalOrderByClause OptionalClusterOrDistributeBy OptionalLimitClause
|
||||
{
|
||||
$$ = {
|
||||
suggestKeywords: parser.getKeywordsForOptionalsLR([$4, $5, $6, $7, $8, $9], [{ value: 'GROUP BY', weight: 8 }, { value: 'HAVING', weight: 7 }, { value: 'WINDOW', weight: 6 }, { value: 'ORDER BY', weight: 5 }, [{ value: 'CLUSTER BY', weight: 4 }, { value: 'DISTRIBUTE BY', weight: 4 }, { value: 'SORT BY', weight: 4 }], { value: 'LIMIT', weight: 3 }], [true, true, true, true, true, true]),
|
||||
cursorAtEnd: !$4 && !$5 && !$6 && !$7 && !$8 && !$9
|
||||
};
|
||||
}
|
||||
| OptionalWhereClause OptionalGroupByClause HavingClause error 'CURSOR' OptionalWindowClause OptionalOrderByClause OptionalClusterOrDistributeBy OptionalLimitClause
|
||||
{
|
||||
$$ = {
|
||||
suggestKeywords: parser.getKeywordsForOptionalsLR([$6, $7, $8, $9], [{ value: 'WINDOW', weight: 6 }, { value: 'ORDER BY', weight: 5 }, [{ value: 'CLUSTER BY', weight: 4 }, { value: 'DISTRIBUTE BY', weight: 4 }, { value: 'SORT BY', weight: 4 }], { value: 'LIMIT', weight: 3 }], [true, true, true, true]),
|
||||
cursorAtEnd: !$6 && !$7 && !$8 && !$9
|
||||
}
|
||||
}
|
||||
| OptionalWhereClause OptionalGroupByClause OptionalHavingClause WindowClause error 'CURSOR' OptionalOrderByClause OptionalClusterOrDistributeBy OptionalLimitClause
|
||||
{
|
||||
$$ = {
|
||||
suggestKeywords: parser.getKeywordsForOptionalsLR([$7, $8, $9], [{ value: 'ORDER BY', weight: 5 }, [{ value: 'CLUSTER BY', weight: 4 }, { value: 'DISTRIBUTE BY', weight: 4 }, { value: 'SORT BY', weight: 4 }], { value: 'LIMIT', weight: 3 }], [true, true, true]),
|
||||
cursorAtEnd: !$7 && !$8 && !$9
|
||||
}
|
||||
}
|
||||
| OptionalWhereClause OptionalGroupByClause OptionalHavingClause OptionalWindowClause OrderByClause error 'CURSOR' OptionalClusterOrDistributeBy OptionalLimitClause
|
||||
{
|
||||
$$ = {
|
||||
suggestKeywords: parser.getKeywordsForOptionalsLR([$8, $9], [[{ value: 'CLUSTER BY', weight: 4 }, { value: 'DISTRIBUTE BY', weight: 4 }, { value: 'SORT BY', weight: 4 }], { value: 'LIMIT', weight: 3 }], [true, true]),
|
||||
cursorAtEnd: !$8 && !$9
|
||||
}
|
||||
}
|
||||
| OptionalWhereClause OptionalGroupByClause OptionalHavingClause OptionalWindowClause OptionalOrderByClause ClusterOrDistributeBy error 'CURSOR' OptionalLimitClause
|
||||
{
|
||||
$$ = {
|
||||
suggestKeywords: parser.getKeywordsForOptionalsLR([$9], [{ value: 'LIMIT', weight: 3 }], [true]),
|
||||
cursorAtEnd: !$9
|
||||
}
|
||||
}
|
||||
| OptionalWhereClause OptionalGroupByClause OptionalHavingClause OptionalWindowClause OptionalOrderByClause OptionalClusterOrDistributeBy LimitClause error 'CURSOR'
|
||||
{
|
||||
$$ = {
|
||||
suggestKeywords: [],
|
||||
cursorAtEnd: true
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
OptionalSelectConditions_EDIT
|
||||
: WhereClause error GroupByClause_EDIT OptionalHavingClause OptionalWindowClause OptionalOrderByClause OptionalClusterOrDistributeBy OptionalLimitClause
|
||||
| WhereClause error OptionalGroupByClause HavingClause_EDIT OptionalWindowClause OptionalOrderByClause OptionalClusterOrDistributeBy OptionalLimitClause
|
||||
| WhereClause error OptionalGroupByClause OptionalHavingClause WindowClause_EDIT OptionalOrderByClause OptionalClusterOrDistributeBy OptionalLimitClause
|
||||
| WhereClause error OptionalGroupByClause OptionalHavingClause OptionalWindowClause OrderByClause_EDIT OptionalClusterOrDistributeBy OptionalLimitClause
|
||||
| WhereClause error OptionalGroupByClause OptionalHavingClause OptionalWindowClause OptionalOrderByClause ClusterOrDistributeBy_EDIT OptionalLimitClause
|
||||
| WhereClause error OptionalGroupByClause OptionalHavingClause OptionalWindowClause OptionalOrderByClause OptionalClusterOrDistributeBy LimitClause_EDIT
|
||||
| OptionalWhereClause GroupByClause error HavingClause_EDIT OptionalWindowClause OptionalOrderByClause OptionalClusterOrDistributeBy OptionalLimitClause
|
||||
| OptionalWhereClause GroupByClause error OptionalHavingClause WindowClause_EDIT OptionalOrderByClause OptionalClusterOrDistributeBy OptionalLimitClause
|
||||
| OptionalWhereClause GroupByClause error OptionalHavingClause OptionalWindowClause OrderByClause_EDIT OptionalClusterOrDistributeBy OptionalLimitClause
|
||||
| OptionalWhereClause GroupByClause error OptionalHavingClause OptionalWindowClause OptionalOrderByClause ClusterOrDistributeBy_EDIT OptionalLimitClause
|
||||
| OptionalWhereClause GroupByClause error OptionalHavingClause OptionalWindowClause OptionalOrderByClause OptionalClusterOrDistributeBy LimitClause_EDIT
|
||||
| OptionalWhereClause OptionalGroupByClause HavingClause error WindowClause_EDIT OptionalOrderByClause OptionalClusterOrDistributeBy OptionalLimitClause
|
||||
| OptionalWhereClause OptionalGroupByClause HavingClause error OptionalWindowClause OrderByClause_EDIT OptionalClusterOrDistributeBy OptionalLimitClause
|
||||
| OptionalWhereClause OptionalGroupByClause HavingClause error OptionalWindowClause OptionalOrderByClause ClusterOrDistributeBy_EDIT OptionalLimitClause
|
||||
| OptionalWhereClause OptionalGroupByClause HavingClause error OptionalWindowClause OptionalOrderByClause OptionalClusterOrDistributeBy LimitClause_EDIT
|
||||
| OptionalWhereClause OptionalGroupByClause OptionalHavingClause WindowClause error OrderByClause_EDIT OptionalClusterOrDistributeBy OptionalLimitClause
|
||||
| OptionalWhereClause OptionalGroupByClause OptionalHavingClause WindowClause error OptionalOrderByClause ClusterOrDistributeBy_EDIT OptionalLimitClause
|
||||
| OptionalWhereClause OptionalGroupByClause OptionalHavingClause WindowClause error OptionalOrderByClause OptionalClusterOrDistributeBy LimitClause_EDIT
|
||||
| OptionalWhereClause OptionalGroupByClause OptionalHavingClause OptionalWindowClause OrderByClause error ClusterOrDistributeBy_EDIT OptionalLimitClause
|
||||
| OptionalWhereClause OptionalGroupByClause OptionalHavingClause OptionalWindowClause OrderByClause error OptionalClusterOrDistributeBy LimitClause_EDIT
|
||||
;
|
||||
|
||||
DatabaseDefinition_EDIT
|
||||
: 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals_EDIT error
|
||||
;
|
378
src/jison/sql/hive/sql_grant.jison
Normal file
378
src/jison/sql/hive/sql_grant.jison
Normal file
@ -0,0 +1,378 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: GrantStatement
|
||||
| RevokeStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: GrantStatement_EDIT
|
||||
| RevokeStatement_EDIT
|
||||
;
|
||||
|
||||
GrantStatement
|
||||
: 'GRANT' PrivilegeTypeList OptionalOnSpecification 'TO' PrincipalSpecificationList OptionalWithGrantOption
|
||||
| 'GRANT' UserOrRoleList 'TO' PrincipalSpecificationList OptionalWithAdminOption
|
||||
| 'GRANT' 'ROLE' UserOrRoleList 'TO' PrincipalSpecificationList OptionalWithAdminOption
|
||||
;
|
||||
|
||||
GrantStatement_EDIT
|
||||
: 'GRANT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['ALL', 'ALTER', 'CREATE', 'DELETE', 'DROP', 'INDEX', 'INSERT', 'LOCK', 'ROLE', 'SELECT', 'UPDATE']);
|
||||
}
|
||||
| 'GRANT' PrivilegeTypeList_EDIT OptionalOnSpecification
|
||||
| 'GRANT' PrivilegeTypeList OnSpecification_EDIT
|
||||
| 'GRANT' PrivilegeTypeList OptionalOnSpecification 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['ON', 'TO']);
|
||||
} else {
|
||||
parser.suggestKeywords(['TO']);
|
||||
}
|
||||
}
|
||||
| 'GRANT' PrivilegeTypeList OptionalOnSpecification 'TO' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
|
||||
}
|
||||
| 'GRANT' PrivilegeTypeList OptionalOnSpecification 'TO' PrincipalSpecificationList_EDIT
|
||||
| 'GRANT' PrivilegeTypeList OptionalOnSpecification 'TO' PrincipalSpecificationList OptionalWithGrantOption 'CURSOR'
|
||||
{
|
||||
if (!$6) {
|
||||
parser.suggestKeywords(['WITH GRANT OPTION']);
|
||||
}
|
||||
}
|
||||
| 'GRANT' PrivilegeTypeList OptionalOnSpecification 'TO' PrincipalSpecificationList WithGrantOption_EDIT
|
||||
| 'GRANT' UserOrRoleList 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['TO']);
|
||||
}
|
||||
| 'GRANT' UserOrRoleList 'TO' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
|
||||
}
|
||||
| 'GRANT' UserOrRoleList 'TO' PrincipalSpecificationList_EDIT
|
||||
| 'GRANT' UserOrRoleList 'TO' PrincipalSpecificationList OptionalWithAdminOption 'CURSOR'
|
||||
{
|
||||
if (!$5) {
|
||||
parser.suggestKeywords(['WITH ADMIN OPTION']);
|
||||
}
|
||||
}
|
||||
| 'GRANT' UserOrRoleList 'TO' PrincipalSpecificationList WithAdminOption_EDIT
|
||||
| 'GRANT' 'ROLE' UserOrRoleList 'TO' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
|
||||
}
|
||||
| 'GRANT' 'ROLE' UserOrRoleList 'TO' PrincipalSpecificationList_EDIT
|
||||
| 'GRANT' 'ROLE' UserOrRoleList 'TO' PrincipalSpecificationList OptionalWithAdminOption 'CURSOR'
|
||||
{
|
||||
if (!$6) {
|
||||
parser.suggestKeywords(['WITH ADMIN OPTION']);
|
||||
}
|
||||
}
|
||||
| 'GRANT' 'ROLE' UserOrRoleList 'TO' PrincipalSpecificationList WithAdminOption_EDIT
|
||||
;
|
||||
|
||||
OptionalOnSpecification
|
||||
:
|
||||
| 'ON' ObjectSpecification
|
||||
;
|
||||
|
||||
OnSpecification_EDIT
|
||||
: 'ON' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['DATABASE', 'TABLE']);
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'ON' ObjectSpecification_EDIT
|
||||
;
|
||||
|
||||
ObjectSpecification
|
||||
: 'DATABASE' RegularOrBacktickedIdentifier
|
||||
| 'TABLE' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($2);
|
||||
}
|
||||
| SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($1);
|
||||
}
|
||||
;
|
||||
|
||||
ObjectSpecification_EDIT
|
||||
: 'DATABASE' 'CURSOR'
|
||||
{
|
||||
parser.suggestDatabases();
|
||||
}
|
||||
| 'TABLE' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'TABLE' SchemaQualifiedTableIdentifier_EDIT
|
||||
| SchemaQualifiedTableIdentifier_EDIT
|
||||
;
|
||||
|
||||
PrivilegeTypeList
|
||||
: PrivilegeTypeWithOptionalColumn
|
||||
{
|
||||
if ($1.toUpperCase() === 'ALL') {
|
||||
$$ = { singleAll: true };
|
||||
}
|
||||
}
|
||||
| PrivilegeTypeList ',' PrivilegeTypeWithOptionalColumn
|
||||
;
|
||||
|
||||
PrivilegeTypeList_EDIT
|
||||
: PrivilegeTypeWithOptionalColumn_EDIT
|
||||
| PrivilegeTypeList ',' PrivilegeTypeWithOptionalColumn_EDIT
|
||||
| PrivilegeTypeWithOptionalColumn_EDIT ',' PrivilegeTypeList
|
||||
| PrivilegeTypeList ',' PrivilegeTypeWithOptionalColumn_EDIT ',' PrivilegeTypeList
|
||||
| 'CURSOR' ',' PrivilegeTypeList
|
||||
{
|
||||
parser.suggestKeywords(['ALL', 'ALTER', 'CREATE', 'DELETE', 'DROP', 'INDEX', 'INSERT', 'LOCK', 'SELECT', 'SHOW_DATABASE', 'UPDATE']);
|
||||
}
|
||||
| PrivilegeTypeList ',' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['ALL', 'ALTER', 'CREATE', 'DELETE', 'DROP', 'INDEX', 'INSERT', 'LOCK', 'SELECT', 'SHOW_DATABASE', 'UPDATE']);
|
||||
}
|
||||
| PrivilegeTypeList ',' 'CURSOR' ',' PrivilegeTypeList
|
||||
{
|
||||
parser.suggestKeywords(['ALL', 'ALTER', 'CREATE', 'DELETE', 'DROP', 'INDEX', 'INSERT', 'LOCK', 'SELECT', 'SHOW_DATABASE', 'UPDATE']);
|
||||
}
|
||||
;
|
||||
|
||||
PrivilegeTypeWithOptionalColumn
|
||||
: PrivilegeType OptionalParenthesizedColumnList
|
||||
;
|
||||
|
||||
PrivilegeTypeWithOptionalColumn_EDIT
|
||||
: PrivilegeType ParenthesizedColumnList_EDIT
|
||||
;
|
||||
|
||||
PrivilegeType
|
||||
: 'ALL'
|
||||
| 'ALTER'
|
||||
| 'CREATE'
|
||||
| 'DELETE'
|
||||
| 'DROP'
|
||||
| 'INDEX'
|
||||
| 'INSERT'
|
||||
| 'LOCK'
|
||||
| 'SELECT'
|
||||
| 'SHOW_DATABASE'
|
||||
| 'UPDATE'
|
||||
;
|
||||
|
||||
PrincipalSpecificationList
|
||||
: PrincipalSpecification
|
||||
| PrincipalSpecificationList ',' PrincipalSpecification
|
||||
;
|
||||
|
||||
PrincipalSpecificationList_EDIT
|
||||
: PrincipalSpecificationList ',' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
|
||||
}
|
||||
| 'CURSOR' ',' PrincipalSpecificationList
|
||||
{
|
||||
parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
|
||||
}
|
||||
| PrincipalSpecificationList ',' 'CURSOR' ',' PrincipalSpecificationList
|
||||
{
|
||||
parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
|
||||
}
|
||||
;
|
||||
|
||||
PrincipalSpecification
|
||||
: 'USER' RegularOrBacktickedIdentifier
|
||||
| 'GROUP' RegularOrBacktickedIdentifier
|
||||
| 'ROLE' RegularOrBacktickedIdentifier
|
||||
;
|
||||
|
||||
PrincipalSpecification_EDIT
|
||||
: 'USER' 'CURSOR'
|
||||
| 'GROUP' 'CURSOR'
|
||||
| 'ROLE' 'CURSOR'
|
||||
;
|
||||
|
||||
UserOrRoleList
|
||||
: RegularOrBacktickedIdentifier
|
||||
| UserOrRoleList ',' RegularOrBacktickedIdentifier
|
||||
;
|
||||
|
||||
OptionalWithGrantOption
|
||||
:
|
||||
| 'WITH' 'GRANT' 'OPTION'
|
||||
;
|
||||
|
||||
WithGrantOption_EDIT
|
||||
: 'WITH' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['GRANT OPTION']);
|
||||
}
|
||||
| 'WITH' 'GRANT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['OPTION']);
|
||||
}
|
||||
;
|
||||
|
||||
OptionalWithAdminOption
|
||||
:
|
||||
| 'WITH' 'ADMIN' 'OPTION'
|
||||
;
|
||||
|
||||
WithAdminOption_EDIT
|
||||
: 'WITH' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['ADMIN OPTION']);
|
||||
}
|
||||
| 'WITH' 'ADMIN' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['OPTION']);
|
||||
}
|
||||
;
|
||||
|
||||
RevokeStatement
|
||||
: 'REVOKE' PrivilegeTypeList OptionalOnSpecification 'FROM' PrincipalSpecificationList
|
||||
| 'REVOKE' 'GRANT' 'OPTION' 'FOR' PrivilegeTypeList OptionalOnSpecification 'FROM' PrincipalSpecificationList
|
||||
| 'REVOKE' UserOrRoleList 'FROM' PrincipalSpecificationList
|
||||
| 'REVOKE' 'ROLE' UserOrRoleList 'FROM' PrincipalSpecificationList
|
||||
| 'REVOKE' 'ADMIN' 'OPTION' 'FOR' UserOrRoleList 'FROM' PrincipalSpecificationList
|
||||
| 'REVOKE' 'ADMIN' 'OPTION' 'FOR' 'ROLE' UserOrRoleList 'FROM' PrincipalSpecificationList
|
||||
| 'REVOKE' 'ALL' PrivilegesOrGrantOption 'FROM' UserOrRoleList
|
||||
;
|
||||
|
||||
RevokeStatement_EDIT
|
||||
: 'REVOKE' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['ADMIN OPTION FOR', 'ALL', 'ALL GRANT OPTION FROM', 'ALL PRIVILEGES FROM', 'ALTER', 'CREATE', 'DELETE', 'DROP', 'GRANT OPTION FOR', 'INDEX', 'INSERT', 'LOCK', 'ROLE', 'SELECT', 'UPDATE']);
|
||||
}
|
||||
| 'REVOKE' PrivilegeTypeList_EDIT
|
||||
| 'REVOKE' PrivilegeTypeList OnSpecification_EDIT
|
||||
| 'REVOKE' PrivilegeTypeList OptionalOnSpecification 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
if ($2.singleAll) {
|
||||
parser.suggestKeywords(['FROM', 'GRANT OPTION', 'ON', 'PRIVILEGES FROM']);
|
||||
} else {
|
||||
parser.suggestKeywords(['FROM', 'ON']);
|
||||
}
|
||||
} else {
|
||||
parser.suggestKeywords(['FROM']);
|
||||
}
|
||||
}
|
||||
| 'REVOKE' PrivilegeTypeList OptionalOnSpecification 'FROM' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
|
||||
}
|
||||
| 'REVOKE' PrivilegeTypeList OptionalOnSpecification 'FROM' PrincipalSpecificationList_EDIT
|
||||
| 'REVOKE' 'GRANT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['OPTION FOR']);
|
||||
}
|
||||
| 'REVOKE' 'GRANT' 'OPTION' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['FOR']);
|
||||
}
|
||||
| 'REVOKE' 'GRANT' 'OPTION' 'FOR' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['ALL', 'ALTER', 'CREATE', 'DELETE', 'DROP', 'INDEX', 'INSERT', 'LOCK', 'SELECT', 'SHOW_DATABASE', 'UPDATE']);
|
||||
}
|
||||
| 'REVOKE' 'GRANT' 'OPTION' 'FOR' PrivilegeTypeList_EDIT
|
||||
| 'REVOKE' 'GRANT' 'OPTION' 'FOR' PrivilegeTypeList OnSpecification_EDIT
|
||||
| 'REVOKE' 'GRANT' 'OPTION' 'FOR' PrivilegeTypeList OptionalOnSpecification 'CURSOR'
|
||||
{
|
||||
if (!$6) {
|
||||
parser.suggestKeywords(['FROM', 'ON']);
|
||||
} else {
|
||||
parser.suggestKeywords(['FROM']);
|
||||
}
|
||||
}
|
||||
| 'REVOKE' 'GRANT' 'OPTION' 'FOR' PrivilegeTypeList OptionalOnSpecification 'FROM' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
|
||||
}
|
||||
| 'REVOKE' 'GRANT' 'OPTION' 'FOR' PrivilegeTypeList OptionalOnSpecification 'FROM' PrincipalSpecificationList_EDIT
|
||||
| 'REVOKE' UserOrRoleList 'CURSOR'
|
||||
{
|
||||
if ($2.toUpperCase() === 'ADMIN') {
|
||||
parser.suggestKeywords(['FROM', 'OPTION FOR']);
|
||||
} else {
|
||||
parser.suggestKeywords(['FROM']);
|
||||
}
|
||||
}
|
||||
| 'REVOKE' UserOrRoleList 'FROM' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
|
||||
}
|
||||
| 'REVOKE' UserOrRoleList 'FROM' PrincipalSpecificationList_EDIT
|
||||
| 'REVOKE' 'ROLE' UserOrRoleList 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['FROM']);
|
||||
}
|
||||
| 'REVOKE' 'ROLE' UserOrRoleList 'FROM' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
|
||||
}
|
||||
| 'REVOKE' 'ROLE' UserOrRoleList 'FROM' PrincipalSpecificationList_EDIT
|
||||
|
||||
| 'REVOKE' 'ADMIN' 'OPTION' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['FOR']);
|
||||
}
|
||||
| 'REVOKE' 'ADMIN' 'OPTION' 'FOR' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['ROLE']);
|
||||
}
|
||||
| 'REVOKE' 'ADMIN' 'OPTION' 'FOR' UserOrRoleList 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['FROM']);
|
||||
}
|
||||
| 'REVOKE' 'ADMIN' 'OPTION' 'FOR' UserOrRoleList 'FROM' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
|
||||
}
|
||||
| 'REVOKE' 'ADMIN' 'OPTION' 'FOR' UserOrRoleList 'FROM' PrincipalSpecificationList_EDIT
|
||||
| 'REVOKE' 'ADMIN' 'OPTION' 'FOR' 'ROLE' UserOrRoleList 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['FROM']);
|
||||
}
|
||||
| 'REVOKE' 'ADMIN' 'OPTION' 'FOR' 'ROLE' UserOrRoleList 'FROM' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
|
||||
}
|
||||
| 'REVOKE' 'ADMIN' 'OPTION' 'FOR' 'ROLE' UserOrRoleList 'FROM' PrincipalSpecificationList_EDIT
|
||||
| 'REVOKE' 'ALL' PrivilegesOrGrantOption_EDIT
|
||||
| 'REVOKE' 'ALL' PrivilegesOrGrantOption 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['FROM']);
|
||||
}
|
||||
;
|
||||
|
||||
PrivilegesOrGrantOption
|
||||
: 'PRIVILEGES'
|
||||
| 'GRANT' 'OPTION'
|
||||
;
|
||||
|
||||
PrivilegesOrGrantOption_EDIT
|
||||
: 'GRANT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['OPTION']);
|
||||
}
|
||||
;
|
536
src/jison/sql/hive/sql_insert.jison
Normal file
536
src/jison/sql/hive/sql_insert.jison
Normal file
@ -0,0 +1,536 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataManipulation
|
||||
: InsertStatement
|
||||
| CommonTableExpression InsertStatement
|
||||
| MergeStatement
|
||||
;
|
||||
|
||||
DataManipulation_EDIT
|
||||
: InsertStatement_EDIT
|
||||
| CommonTableExpression InsertStatement_EDIT
|
||||
{
|
||||
parser.addCommonTableExpressions($1);
|
||||
}
|
||||
| CommonTableExpression_EDIT InsertStatement
|
||||
| MergeStatement_EDIT
|
||||
;
|
||||
|
||||
InsertStatement
|
||||
: InsertWithoutQuery
|
||||
| InsertWithoutQuery QuerySpecification
|
||||
| FromClause Inserts
|
||||
| FromClause SelectWithoutTableExpression OptionalSelectConditions
|
||||
;
|
||||
|
||||
InsertStatement_EDIT
|
||||
: InsertWithoutQuery_EDIT
|
||||
| InsertWithoutQuery 'CURSOR'
|
||||
{
|
||||
var keywords = [];
|
||||
if ($1.suggestKeywords) {
|
||||
keywords = parser.createWeightedKeywords($1.suggestKeywords, 2).concat([{ value: 'SELECT', weight: 1}]);
|
||||
} else {
|
||||
keywords = ['SELECT'];
|
||||
}
|
||||
if ($1.addValues) {
|
||||
keywords.push({ weight: 1.1, value: 'VALUES' });
|
||||
}
|
||||
if (keywords.length > 0) {
|
||||
parser.suggestKeywords(keywords);
|
||||
}
|
||||
}
|
||||
| InsertWithoutQuery_EDIT QuerySpecification
|
||||
| InsertWithoutQuery QuerySpecification_EDIT
|
||||
| FromClause Inserts_EDIT
|
||||
{
|
||||
if (!$2.keepTables) {
|
||||
delete parser.yy.result.suggestTables;
|
||||
delete parser.yy.result.suggestDatabases;
|
||||
}
|
||||
}
|
||||
| FromClause_EDIT
|
||||
| FromClause_EDIT Inserts
|
||||
| FromClause_EDIT SelectWithoutTableExpression OptionalSelectConditions
|
||||
| FromClause 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['INSERT INTO', 'INSERT OVERWRITE', 'SELECT']);
|
||||
}
|
||||
| FromClause SelectWithoutTableExpression_EDIT OptionalSelectConditions
|
||||
{
|
||||
if ($2.cursorAtEnd) {
|
||||
parser.checkForSelectListKeywords($2);
|
||||
var keywords = parser.yy.result.suggestKeywords || [];
|
||||
if ($3.suggestKeywords) {
|
||||
keywords = keywords.concat($3.suggestKeywords);
|
||||
}
|
||||
if (keywords.length > 0) {
|
||||
parser.suggestKeywords(keywords);
|
||||
}
|
||||
}
|
||||
delete parser.yy.result.suggestTables;
|
||||
delete parser.yy.result.suggestDatabases;
|
||||
}
|
||||
| FromClause SelectWithoutTableExpression OptionalSelectConditions_EDIT
|
||||
{
|
||||
if ($3.cursorAtStart) {
|
||||
parser.checkForSelectListKeywords($2.tableExpression);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
InsertWithoutQuery
|
||||
: 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier OptionalPartitionSpec 'VALUES' InsertValuesList
|
||||
{
|
||||
$4.owner = 'insert';
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
| 'INSERT' 'OVERWRITE' OptionalTable SchemaQualifiedTableIdentifier OptionalPartitionSpec OptionalIfNotExists
|
||||
{
|
||||
$4.owner = 'insert';
|
||||
parser.addTablePrimary($4);
|
||||
if (!$5 && !$6) {
|
||||
$$ = { suggestKeywords: ['PARTITION'] }
|
||||
} else if (!$6) {
|
||||
$$ = { suggestKeywords: ['IF NOT EXISTS'] }
|
||||
}
|
||||
}
|
||||
| 'INSERT' 'OVERWRITE' 'LOCAL' 'DIRECTORY' HdfsPath OptionalInsertRowFormat OptionalStoredAs
|
||||
{
|
||||
if (!$6 && !$7) {
|
||||
$$ = { suggestKeywords: [{ value: 'ROW FORMAT', weight: 2 }, { value: 'STORED AS', weight: 1}] };
|
||||
} else if (!$7) {
|
||||
$$ = { suggestKeywords: ['STORED AS'] };
|
||||
}
|
||||
}
|
||||
| 'INSERT' 'OVERWRITE_DIRECTORY' HdfsPath OptionalInsertRowFormat OptionalStoredAs
|
||||
{
|
||||
if (!$4 && !$5) {
|
||||
$$ = { suggestKeywords: [{ value: 'ROW FORMAT', weight: 2 }, { value: 'STORED AS', weight: 1}] };
|
||||
} else if (!$5) {
|
||||
$$ = { suggestKeywords: ['STORED AS'] };
|
||||
}
|
||||
}
|
||||
| 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier OptionalPartitionSpec OptionalParenthesizedColumnList
|
||||
{
|
||||
$4.owner = 'insert';
|
||||
parser.addTablePrimary($4);
|
||||
if (!$5 && !$6) {
|
||||
$$ = { suggestKeywords: ['PARTITION'], addValues: true };
|
||||
} else if (!$6) {
|
||||
$$ = { addValues: true };
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
InsertWithoutQuery_EDIT
|
||||
: 'INSERT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['OVERWRITE', 'INTO']);
|
||||
}
|
||||
| 'INSERT' 'OVERWRITE' OptionalTable 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['DIRECTORY', 'LOCAL DIRECTORY', 'TABLE']);
|
||||
}
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
$$ = { keepTables: true }
|
||||
}
|
||||
| 'INSERT' 'OVERWRITE' OptionalTable SchemaQualifiedTableIdentifier_EDIT OptionalPartitionSpec OptionalParenthesizedColumnList
|
||||
{
|
||||
$$ = { keepTables: true }
|
||||
}
|
||||
| 'INSERT' 'OVERWRITE' OptionalTable SchemaQualifiedTableIdentifier OptionalPartitionSpec_EDIT OptionalIfNotExists
|
||||
{
|
||||
$4.owner = 'insert';
|
||||
parser.addTablePrimary($4);
|
||||
if (parser.yy.result.suggestColumns) {
|
||||
parser.yy.result.suggestColumns.owner = 'insert';
|
||||
}
|
||||
}
|
||||
| 'INSERT' 'OVERWRITE' OptionalTable SchemaQualifiedTableIdentifier OptionalPartitionSpec OptionalIfNotExists_EDIT
|
||||
{
|
||||
$4.owner = 'insert';
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
| 'INSERT' 'OVERWRITE' 'LOCAL' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['DIRECTORY']);
|
||||
}
|
||||
| 'INSERT' 'OVERWRITE' 'LOCAL' 'DIRECTORY' HdfsPath_EDIT OptionalInsertRowFormat OptionalStoredAs
|
||||
| 'INSERT' 'OVERWRITE' 'LOCAL' 'DIRECTORY' HdfsPath OptionalInsertRowFormat_EDIT OptionalStoredAs
|
||||
| 'INSERT' 'OVERWRITE' 'LOCAL' 'DIRECTORY' HdfsPath OptionalInsertRowFormat OptionalStoredAs_EDIT
|
||||
| 'INSERT' 'OVERWRITE_DIRECTORY' HdfsPath_EDIT OptionalInsertRowFormat OptionalStoredAs // DIRECTORY is a non-reserved keyword
|
||||
| 'INSERT' 'OVERWRITE_DIRECTORY' HdfsPath OptionalInsertRowFormat_EDIT OptionalStoredAs
|
||||
| 'INSERT' 'OVERWRITE_DIRECTORY' HdfsPath OptionalInsertRowFormat OptionalStoredAs_EDIT
|
||||
| 'INSERT' 'INTO' OptionalTable 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['TABLE']);
|
||||
}
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
$$ = { keepTables: true }
|
||||
}
|
||||
| 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier_EDIT OptionalPartitionSpec OptionalParenthesizedColumnList
|
||||
{
|
||||
$$ = { keepTables: true }
|
||||
}
|
||||
| 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier OptionalPartitionSpec_EDIT OptionalParenthesizedColumnList
|
||||
{
|
||||
$4.owner = 'insert';
|
||||
parser.addTablePrimary($4);
|
||||
if (parser.yy.result.suggestColumns) {
|
||||
parser.yy.result.suggestColumns.owner = 'insert';
|
||||
}
|
||||
}
|
||||
| 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier OptionalPartitionSpec OptionalParenthesizedColumnList_EDIT
|
||||
{
|
||||
$4.owner = 'insert';
|
||||
parser.addTablePrimary($4);
|
||||
if (parser.yy.result.suggestColumns) {
|
||||
parser.yy.result.suggestColumns.owner = 'insert';
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
Inserts
|
||||
: GenericInsert
|
||||
| Inserts GenericInsert
|
||||
;
|
||||
|
||||
Inserts_EDIT
|
||||
: GenericInsert_EDIT
|
||||
| Inserts GenericInsert_EDIT
|
||||
| GenericInsert_EDIT Inserts
|
||||
| Inserts GenericInsert_EDIT Inserts
|
||||
;
|
||||
|
||||
// TODO: Verify unions in insert
|
||||
GenericInsert
|
||||
: InsertWithoutQuery SelectWithoutTableExpression OptionalSelectConditions
|
||||
;
|
||||
|
||||
GenericInsert_EDIT
|
||||
: InsertWithoutQuery_EDIT
|
||||
| InsertWithoutQuery_EDIT SelectWithoutTableExpression OptionalSelectConditions
|
||||
| InsertWithoutQuery 'CURSOR'
|
||||
{
|
||||
if ($1.suggestKeywords) {
|
||||
parser.suggestKeywords(parser.createWeightedKeywords($1.suggestKeywords, 2).concat([{ value: 'SELECT', weight: 1}]));
|
||||
} else {
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
}
|
||||
| InsertWithoutQuery SelectWithoutTableExpression_EDIT OptionalSelectConditions
|
||||
{
|
||||
if ($2.cursorAtEnd) {
|
||||
parser.checkForSelectListKeywords($2);
|
||||
var keywords = parser.yy.result.suggestKeywords || [];
|
||||
if ($3.suggestKeywords) {
|
||||
keywords = keywords.concat($3.suggestKeywords);
|
||||
}
|
||||
if (keywords.length > 0) {
|
||||
parser.suggestKeywords(keywords);
|
||||
}
|
||||
}
|
||||
}
|
||||
| InsertWithoutQuery SelectWithoutTableExpression OptionalSelectConditions_EDIT
|
||||
;
|
||||
|
||||
InsertValuesList
|
||||
: ParenthesizedRowValuesList
|
||||
| RowValuesList ',' ParenthesizedRowValuesList
|
||||
;
|
||||
|
||||
ParenthesizedRowValuesList
|
||||
: '(' InValueList ')'
|
||||
;
|
||||
|
||||
OptionalTable
|
||||
:
|
||||
| 'TABLE'
|
||||
;
|
||||
|
||||
OptionalInsertRowFormat
|
||||
:
|
||||
| 'ROW' 'FORMAT' DelimitedRowFormat
|
||||
;
|
||||
|
||||
OptionalInsertRowFormat_EDIT
|
||||
: 'ROW' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['FORMAT DELIMITED']);
|
||||
}
|
||||
| 'ROW' 'FORMAT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['DELIMITED']);
|
||||
}
|
||||
| 'ROW' 'FORMAT' DelimitedRowFormat_EDIT
|
||||
;
|
||||
|
||||
SelectWithoutTableExpression
|
||||
: 'SELECT' OptionalAllOrDistinct SelectList -> { selectList: $3 }
|
||||
;
|
||||
|
||||
SelectWithoutTableExpression_EDIT
|
||||
: 'SELECT' OptionalAllOrDistinct SelectList 'CURSOR'
|
||||
{
|
||||
$$ = $3;
|
||||
$$.cursorAtEnd = true;
|
||||
}
|
||||
| 'SELECT' OptionalAllOrDistinct SelectList_EDIT
|
||||
{
|
||||
parser.selectListNoTableSuggest($3, $2);
|
||||
}
|
||||
| 'SELECT' OptionalAllOrDistinct 'CURSOR'
|
||||
{
|
||||
var keywords = parser.getSelectListKeywords();
|
||||
if (!$2 || $2 === 'ALL') {
|
||||
parser.suggestAggregateFunctions();
|
||||
parser.suggestAnalyticFunctions();
|
||||
}
|
||||
if (!$2) {
|
||||
keywords.push({ value: 'ALL', weight: 2 });
|
||||
keywords.push({ value: 'DISTINCT', weight: 2 });
|
||||
}
|
||||
parser.suggestKeywords(keywords);
|
||||
parser.suggestFunctions();
|
||||
parser.suggestColumns();
|
||||
}
|
||||
;
|
||||
|
||||
MergeStatement
|
||||
: MergeStatementLeftPart 'ON' ValueExpression WhenList
|
||||
;
|
||||
|
||||
MergeStatement_EDIT
|
||||
: MergeStatementLeftPart_EDIT
|
||||
| MergeStatementLeftPart 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['ON']);
|
||||
}
|
||||
| MergeStatementLeftPart 'ON' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
}
|
||||
| MergeStatementLeftPart 'ON' ValueExpression_EDIT
|
||||
| MergeStatementLeftPart 'ON' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($3, [{ value: 'WHEN', weight: 2 }]);
|
||||
}
|
||||
| MergeStatementLeftPart 'ON' ValueExpression WhenList_EDIT
|
||||
;
|
||||
|
||||
MergeStatementLeftPart
|
||||
: 'MERGE' 'INTO' SchemaQualifiedTableIdentifier 'AS' RegularIdentifier 'USING' MergeSource 'AS' RegularIdentifier
|
||||
{
|
||||
$3.alias = $5;
|
||||
parser.addTablePrimary($3);
|
||||
if ($7.subQuery) {
|
||||
parser.addTablePrimary({ subQueryAlias: $9 });
|
||||
} else {
|
||||
$7.alias = $9;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
MergeStatementLeftPart_EDIT
|
||||
: 'MERGE' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['INTO']);
|
||||
}
|
||||
| 'MERGE' 'INTO' 'CURSOR'
|
||||
{
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
parser.suggestTables();
|
||||
}
|
||||
| 'MERGE' 'INTO' SchemaQualifiedTableIdentifier_EDIT
|
||||
| 'MERGE' 'INTO' SchemaQualifiedTableIdentifier 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
parser.suggestKeywords(['AS T USING']);
|
||||
}
|
||||
| 'MERGE' 'INTO' SchemaQualifiedTableIdentifier 'AS' 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
parser.suggestKeywords(['T USING']);
|
||||
}
|
||||
| 'MERGE' 'INTO' SchemaQualifiedTableIdentifier 'AS' RegularIdentifier 'CURSOR'
|
||||
{
|
||||
$3.alias = $5;
|
||||
parser.addTablePrimary($3);
|
||||
parser.suggestKeywords(['USING']);
|
||||
}
|
||||
| 'MERGE' 'INTO' SchemaQualifiedTableIdentifier 'AS' RegularIdentifier 'USING' 'CURSOR'
|
||||
{
|
||||
$3.alias = $5;
|
||||
parser.addTablePrimary($3);
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
parser.suggestTables();
|
||||
}
|
||||
| 'MERGE' 'INTO' SchemaQualifiedTableIdentifier 'AS' RegularIdentifier 'USING' MergeSource_EDIT
|
||||
{
|
||||
$3.alias = $5;
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
| 'MERGE' 'INTO' SchemaQualifiedTableIdentifier 'AS' RegularIdentifier 'USING' MergeSource 'CURSOR'
|
||||
{
|
||||
$3.alias = $5;
|
||||
parser.addTablePrimary($3);
|
||||
parser.suggestKeywords(['AS S ON']);
|
||||
}
|
||||
| 'MERGE' 'INTO' SchemaQualifiedTableIdentifier 'AS' RegularIdentifier 'USING' MergeSource 'AS' 'CURSOR'
|
||||
{
|
||||
$3.alias = $5;
|
||||
parser.addTablePrimary($3);
|
||||
parser.suggestKeywords(['S ON']);
|
||||
}
|
||||
;
|
||||
|
||||
MergeSource
|
||||
: '(' TableSubQueryInner ')' -> $2
|
||||
| SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($1);
|
||||
}
|
||||
;
|
||||
|
||||
MergeSource_EDIT
|
||||
: '(' 'CURSOR' RightParenthesisOrError
|
||||
{
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
| '(' TableSubQueryInner_EDIT RightParenthesisOrError
|
||||
| SchemaQualifiedTableIdentifier_EDIT
|
||||
;
|
||||
|
||||
WhenList
|
||||
: WhenClause
|
||||
| WhenClause WhenClause
|
||||
| WhenClause WhenClause WhenClause
|
||||
;
|
||||
|
||||
WhenList_EDIT
|
||||
: WhenClause_EDIT
|
||||
{
|
||||
if ($1.suggestThenKeywords) {
|
||||
parser.suggestKeywords(['DELETE', 'INSERT VALUES', 'UPDATE SET']);
|
||||
}
|
||||
}
|
||||
| WhenClause 'CURSOR'
|
||||
{
|
||||
if (!$1.notPresent) {
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
}
|
||||
}
|
||||
| WhenClause WhenClause_EDIT
|
||||
{
|
||||
if (!$1.notPresent && $2.suggestThenKeywords) {
|
||||
var keywords = [];
|
||||
if (!$1.isDelete) {
|
||||
keywords.push('DELETE');
|
||||
}
|
||||
if (!$1.isInsert) {
|
||||
keywords.push('INSERT VALUES');
|
||||
}
|
||||
if (!$1.isUpdate) {
|
||||
keywords.push('UPDATE SET');
|
||||
}
|
||||
parser.suggestKeywords(keywords);
|
||||
}
|
||||
}
|
||||
| WhenClause WhenClause 'CURSOR'
|
||||
{
|
||||
if (!$2.notPresent) {
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
}
|
||||
}
|
||||
| WhenClause WhenClause WhenClause_EDIT
|
||||
{
|
||||
if (!$2.notPresent && $3.suggestThenKeywords) {
|
||||
var keywords = [];
|
||||
if (!$1.isDelete && !$2.isDelete) {
|
||||
keywords.push('DELETE');
|
||||
}
|
||||
if (!$1.isInsert && !$2.isInsert) {
|
||||
keywords.push('INSERT VALUES');
|
||||
}
|
||||
if (!$1.isUpdate && !$2.isUpdate) {
|
||||
keywords.push('UPDATE SET');
|
||||
}
|
||||
parser.suggestKeywords(keywords);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
WhenClause
|
||||
: 'WHEN' OptionalNot 'MATCHED' OptionalMatchCondition 'THEN' UpdateDeleteOrInsert -> { notPresent: !!$2, isDelete: $6.isDelete, isInsert: $6.isInsert, isUpdate: $6.isUpdate }
|
||||
;
|
||||
|
||||
WhenClause_EDIT
|
||||
: 'WHEN' OptionalNot 'CURSOR'
|
||||
{
|
||||
if (!$2) {
|
||||
parser.suggestKeywords(['NOT MATCHED', 'MATCHED']);
|
||||
} else {
|
||||
parser.suggestKeywords(['MATCHED']);
|
||||
}
|
||||
}
|
||||
| 'WHEN' OptionalNot 'MATCHED' OptionalMatchCondition 'CURSOR'
|
||||
{
|
||||
if (!$4) {
|
||||
parser.suggestKeywords(['AND', 'THEN']);
|
||||
} else {
|
||||
parser.suggestValueExpressionKeywords($4, [{ value: 'THEN', weight: 2 }]);
|
||||
}
|
||||
}
|
||||
| 'WHEN' OptionalNot 'MATCHED' MatchCondition_EDIT
|
||||
| 'WHEN' OptionalNot 'MATCHED' OptionalMatchCondition 'THEN' 'CURSOR' -> { suggestThenKeywords: true }
|
||||
| 'WHEN' OptionalNot 'MATCHED' OptionalMatchCondition 'THEN' UpdateDeleteOrInsert_EDIT
|
||||
;
|
||||
|
||||
OptionalMatchCondition
|
||||
:
|
||||
| 'AND' ValueExpression -> $2
|
||||
;
|
||||
|
||||
MatchCondition_EDIT
|
||||
: 'AND' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
}
|
||||
;
|
||||
|
||||
UpdateDeleteOrInsert
|
||||
: 'UPDATE' 'SET' SetClauseList -> { isUpdate: true }
|
||||
| 'DELETE' -> { isDelete: true }
|
||||
| 'INSERT' 'VALUES' InsertValuesList -> { isInsert: true }
|
||||
;
|
||||
|
||||
UpdateDeleteOrInsert_EDIT
|
||||
: 'UPDATE' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['SET']);
|
||||
}
|
||||
| 'UPDATE' 'SET' SetClauseList_EDIT
|
||||
| 'INSERT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['VALUES']);
|
||||
}
|
||||
;
|
293
src/jison/sql/hive/sql_load.jison
Normal file
293
src/jison/sql/hive/sql_load.jison
Normal file
@ -0,0 +1,293 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataManipulation
|
||||
: LoadStatement
|
||||
| ImportStatement
|
||||
| ExportStatement
|
||||
;
|
||||
|
||||
DataManipulation_EDIT
|
||||
: LoadStatement_EDIT
|
||||
| ImportStatement_EDIT
|
||||
| ExportStatement_EDIT
|
||||
;
|
||||
|
||||
LoadStatement
|
||||
: 'LOAD' 'DATA' OptionalLocal 'INPATH' HdfsPath OptionalOverwrite 'INTO' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec OptionalInputFormat
|
||||
{
|
||||
parser.addTablePrimary($9);
|
||||
}
|
||||
;
|
||||
|
||||
LoadStatement_EDIT
|
||||
: 'LOAD' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['DATA LOCAL INPATH', 'DATA INPATH']);
|
||||
}
|
||||
| 'LOAD' 'DATA' OptionalLocal 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['INPATH', 'LOCAL INPATH']);
|
||||
} else {
|
||||
parser.suggestKeywords(['INPATH']);
|
||||
}
|
||||
}
|
||||
| 'LOAD' 'DATA' OptionalLocal 'INPATH' HdfsPath_EDIT OptionalOverwrite
|
||||
| 'LOAD' 'DATA' OptionalLocal 'INPATH' HdfsPath OptionalOverwrite 'CURSOR'
|
||||
{
|
||||
if (!$6) {
|
||||
parser.suggestKeywords(['OVERWRITE INTO TABLE', 'INTO TABLE']);
|
||||
} else {
|
||||
parser.suggestKeywords(['INTO TABLE']);
|
||||
}
|
||||
}
|
||||
| 'LOAD' 'DATA' OptionalLocal 'INPATH' HdfsPath OptionalOverwrite 'INTO' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords([ 'TABLE' ]);
|
||||
}
|
||||
| 'LOAD' 'DATA' OptionalLocal 'INPATH' HdfsPath OptionalOverwrite 'INTO' 'TABLE' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'LOAD' 'DATA' OptionalLocal 'INPATH' HdfsPath OptionalOverwrite 'INTO' 'TABLE' SchemaQualifiedTableIdentifier_EDIT OptionalPartitionSpec OptionalInputFormat
|
||||
| 'LOAD' 'DATA' OptionalLocal 'INPATH' HdfsPath OptionalOverwrite 'INTO' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec OptionalInputFormat 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($9);
|
||||
if (!$10 && !$11) {
|
||||
parser.suggestKeywords(['INPUTFORMAT', 'PARTITION']);
|
||||
} else if ($10 && !$11) {
|
||||
parser.suggestKeywords(['INPUTFORMAT']);
|
||||
}
|
||||
}
|
||||
| 'LOAD' 'DATA' OptionalLocal 'INPATH' HdfsPath OptionalOverwrite 'INTO' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec_EDIT OptionalInputFormat
|
||||
{
|
||||
parser.addTablePrimary($9);
|
||||
}
|
||||
| 'LOAD' 'DATA' OptionalLocal 'INPATH' HdfsPath OptionalOverwrite 'INTO' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec InputFormat_EDIT
|
||||
{
|
||||
parser.addTablePrimary($9);
|
||||
}
|
||||
| 'LOAD' 'DATA' OptionalLocal 'INPATH' HdfsPath_EDIT OptionalOverwrite 'INTO' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec OptionalInputFormat
|
||||
{
|
||||
parser.addTablePrimary($9);
|
||||
}
|
||||
;
|
||||
|
||||
OptionalOverwrite
|
||||
:
|
||||
| 'OVERWRITE'
|
||||
;
|
||||
|
||||
OptionalLocal
|
||||
:
|
||||
| 'LOCAL'
|
||||
;
|
||||
|
||||
OptionalInputFormat
|
||||
:
|
||||
| InputFormat
|
||||
;
|
||||
|
||||
InputFormat
|
||||
: 'INPUTFORMAT' QuotedValue 'SERDE' QuotedValue
|
||||
;
|
||||
|
||||
InputFormat_EDIT
|
||||
: 'INPUTFORMAT' QuotedValue 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['SERDE']);
|
||||
}
|
||||
;
|
||||
|
||||
ImportStatement
|
||||
: 'IMPORT' OptionalTableWithPartition PushHdfsLexerState 'FROM' HdfsPath OptionalHdfsLocation
|
||||
;
|
||||
|
||||
ImportStatement_EDIT
|
||||
: 'IMPORT' 'CURSOR' OptionalTableWithPartition
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['EXTERNAL TABLE', 'FROM', 'TABLE']);
|
||||
} else if (!$3.hasExternal) {
|
||||
parser.suggestKeywords(['EXTERNAL']);
|
||||
}
|
||||
}
|
||||
| 'IMPORT' TableWithPartition 'CURSOR'
|
||||
{
|
||||
if ($2.suggestKeywords) {
|
||||
parser.suggestKeywords(parser.createWeightedKeywords($2.suggestKeywords, 2).concat(['FROM']));
|
||||
} else {
|
||||
parser.suggestKeywords(['FROM']);
|
||||
}
|
||||
}
|
||||
| 'IMPORT' TableWithPartition_EDIT
|
||||
| 'IMPORT' OptionalTableWithPartition PushHdfsLexerState 'FROM' HdfsPath_EDIT OptionalHdfsLocation
|
||||
| 'IMPORT' OptionalTableWithPartition PushHdfsLexerState 'FROM' HdfsPath HdfsLocation_EDIT
|
||||
| 'IMPORT' OptionalTableWithPartition PushHdfsLexerState 'FROM' HdfsPath OptionalHdfsLocation 'CURSOR'
|
||||
{
|
||||
if (!$6) {
|
||||
parser.suggestKeywords(['LOCATION']);
|
||||
}
|
||||
}
|
||||
| 'IMPORT' 'CURSOR' OptionalTableWithPartition PushHdfsLexerState 'FROM' HdfsPath OptionalHdfsLocation
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['EXTERNAL TABLE', 'TABLE']);
|
||||
} else if (!$3.hasExternal) {
|
||||
parser.suggestKeywords(['EXTERNAL']);
|
||||
}
|
||||
}
|
||||
| 'IMPORT' TableWithPartition_EDIT PushHdfsLexerState 'FROM' HdfsPath OptionalHdfsLocation
|
||||
| 'IMPORT' TableWithPartition 'CURSOR' PushHdfsLexerState 'FROM' HdfsPath OptionalHdfsLocation
|
||||
{
|
||||
if ($2.suggestKeywords) {
|
||||
parser.suggestKeywords(parser.createWeightedKeywords($2.suggestKeywords, 2).concat(['FROM']));
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
OptionalTableWithPartition
|
||||
:
|
||||
| TableWithPartition
|
||||
;
|
||||
|
||||
TableWithPartition
|
||||
: 'EXTERNAL' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
if (!$4) {
|
||||
$$ = { hasExternal: true, suggestKeywords: ['PARTITION'] };
|
||||
} else {
|
||||
$$ = { hasExternal: true }
|
||||
}
|
||||
}
|
||||
| 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec
|
||||
{
|
||||
parser.addTablePrimary($2);
|
||||
if (!$3) {
|
||||
$$ = { suggestKeywords: ['PARTITION'] };
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
TableWithPartition_EDIT
|
||||
: 'EXTERNAL' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['TABLE']);
|
||||
}
|
||||
| 'EXTERNAL' 'TABLE' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'EXTERNAL' 'TABLE' SchemaQualifiedTableIdentifier_EDIT OptionalPartitionSpec
|
||||
| 'EXTERNAL' 'TABLE' SchemaQualifiedTableIdentifier PartitionSpec_EDIT
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
| 'TABLE' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
|
||||
| 'TABLE' SchemaQualifiedTableIdentifier_EDIT OptionalPartitionSpec
|
||||
| 'TABLE' SchemaQualifiedTableIdentifier PartitionSpec_EDIT
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
;
|
||||
|
||||
ExportStatement
|
||||
: 'EXPORT' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec PushHdfsLexerState 'TO' HdfsPath
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
| 'EXPORT' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec PushHdfsLexerState 'TO' HdfsPath 'FOR' 'REPLICATION' '(' QuotedValue ')'
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
;
|
||||
|
||||
ExportStatement_EDIT
|
||||
: 'EXPORT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['TABLE']);
|
||||
}
|
||||
| 'EXPORT' 'TABLE' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'EXPORT' 'TABLE' SchemaQualifiedTableIdentifier_EDIT
|
||||
| 'EXPORT' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
if (!$4) {
|
||||
parser.suggestKeywords([{ weight: 2, value: 'PARTITION' }, { weight: 1, value: 'TO' }]);
|
||||
} else {
|
||||
parser.suggestKeywords([ 'TO' ]);
|
||||
}
|
||||
}
|
||||
| 'EXPORT' 'TABLE' SchemaQualifiedTableIdentifier PartitionSpec_EDIT
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
| 'EXPORT' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec PushHdfsLexerState 'TO' HdfsPath_EDIT
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
| 'EXPORT' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec PushHdfsLexerState 'TO' HdfsPath 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
parser.suggestKeywords(['FOR replication()']);
|
||||
}
|
||||
| 'EXPORT' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec PushHdfsLexerState 'TO' HdfsPath 'FOR' 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
parser.suggestKeywords(['replication()']);
|
||||
}
|
||||
| 'EXPORT' 'TABLE' SchemaQualifiedTableIdentifier_EDIT OptionalPartitionSpec PushHdfsLexerState 'TO' HdfsPath
|
||||
| 'EXPORT' 'TABLE' SchemaQualifiedTableIdentifier_EDIT OptionalPartitionSpec PushHdfsLexerState 'TO' HdfsPath 'FOR' 'REPLICATION' '(' QuotedValue ')'
|
||||
| 'EXPORT' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'CURSOR' PushHdfsLexerState 'TO' HdfsPath
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
if (!$4) {
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
}
|
||||
| 'EXPORT' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'CURSOR' PushHdfsLexerState 'TO' HdfsPath 'FOR' 'REPLICATION' '(' QuotedValue ')'
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
if (!$4) {
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
}
|
||||
| 'EXPORT' 'TABLE' SchemaQualifiedTableIdentifier PartitionSpec_EDIT PushHdfsLexerState 'TO' HdfsPath
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
| 'EXPORT' 'TABLE' SchemaQualifiedTableIdentifier PartitionSpec_EDIT PushHdfsLexerState 'TO' HdfsPath 'FOR' 'REPLICATION' '(' QuotedValue ')'
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
| 'EXPORT' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec PushHdfsLexerState 'TO' HdfsPath_EDIT 'FOR' 'REPLICATION' '(' QuotedValue ')'
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
;
|
3683
src/jison/sql/hive/sql_main.jison
Normal file
3683
src/jison/sql/hive/sql_main.jison
Normal file
File diff suppressed because it is too large
Load Diff
62
src/jison/sql/hive/sql_set.jison
Normal file
62
src/jison/sql/hive/sql_set.jison
Normal file
@ -0,0 +1,62 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: SetRoleStatement
|
||||
| SetSpecification
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: SetRoleStatement_EDIT
|
||||
| 'SET' 'CURSOR'
|
||||
{
|
||||
parser.suggestSetOptions();
|
||||
parser.suggestKeywords(['ROLE']);
|
||||
}
|
||||
;
|
||||
|
||||
SetSpecification
|
||||
: 'SET' SetOption '=' SetValue
|
||||
| 'SET' 'ALL'
|
||||
;
|
||||
|
||||
SetOption
|
||||
: RegularIdentifier
|
||||
| SetOption '.' RegularIdentifier
|
||||
;
|
||||
|
||||
SetValue
|
||||
: RegularIdentifier
|
||||
| SignedInteger
|
||||
| SignedInteger RegularIdentifier
|
||||
| QuotedValue
|
||||
| 'TRUE'
|
||||
| 'FALSE'
|
||||
| 'NULL'
|
||||
;
|
||||
|
||||
SetRoleStatement
|
||||
: 'SET' 'ROLE' RegularIdentifier
|
||||
| 'SET' 'ROLE' 'ALL'
|
||||
| 'SET' 'ROLE' 'NONE'
|
||||
;
|
||||
|
||||
SetRoleStatement_EDIT
|
||||
: 'SET' 'ROLE' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['ALL', 'NONE']);
|
||||
}
|
||||
;
|
535
src/jison/sql/hive/sql_show.jison
Normal file
535
src/jison/sql/hive/sql_show.jison
Normal file
@ -0,0 +1,535 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: ShowStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: ShowStatement_EDIT
|
||||
;
|
||||
|
||||
ShowStatement
|
||||
: ShowColumnsStatement
|
||||
| ShowCompactionsStatement
|
||||
| ShowConfStatement
|
||||
| ShowCreateTableStatement
|
||||
| ShowCurrentRolesStatement
|
||||
| ShowDatabasesStatement
|
||||
| ShowFunctionsStatement
|
||||
| ShowGrantStatement
|
||||
| ShowIndexStatement
|
||||
| ShowLocksStatement
|
||||
| ShowMaterializedViewsStatement
|
||||
| ShowPartitionsStatement
|
||||
| ShowRolesStatement
|
||||
| ShowRoleStatement
|
||||
| ShowTablesStatement
|
||||
| ShowTableStatement
|
||||
| ShowTblPropertiesStatement
|
||||
| ShowTransactionsStatement
|
||||
| ShowViewsStatement
|
||||
;
|
||||
|
||||
ShowStatement_EDIT
|
||||
: 'SHOW' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['COLUMNS', 'COMPACTIONS', 'CONF', 'CREATE TABLE', 'CURRENT ROLES', 'DATABASES', 'FORMATTED', 'FUNCTIONS', 'GRANT', 'INDEX', 'INDEXES', 'LOCKS', 'MATERIALIZED VIEWS', 'PARTITIONS', 'PRINCIPALS', 'ROLE GRANT', 'ROLES', 'SCHEMAS', 'TABLE EXTENDED', 'TABLES', 'TBLPROPERTIES', 'TRANSACTIONS', 'VIEWS']);
|
||||
}
|
||||
| 'SHOW' 'CURSOR' RegularOrBackTickedSchemaQualifiedName
|
||||
{
|
||||
// ROLES is considered a non-reserved keywords so we can't match it in ShowCurrentRolesStatement_EDIT
|
||||
if ($3.identifierChain && $3.identifierChain.length === 1 && $3.identifierChain[0].name.toLowerCase() === 'roles') {
|
||||
parser.suggestKeywords(['CURRENT']);
|
||||
parser.yy.locations.pop();
|
||||
} else {
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
}
|
||||
| 'SHOW' 'CURSOR' LIKE SingleQuotedValue
|
||||
{
|
||||
parser.suggestKeywords(['DATABASES', 'SCHEMAS', 'TABLE EXTENDED']);
|
||||
}
|
||||
| ShowColumnsStatement_EDIT
|
||||
| ShowCreateTableStatement_EDIT
|
||||
| ShowCurrentRolesStatement_EDIT
|
||||
| ShowDatabasesStatement_EDIT
|
||||
| ShowGrantStatement_EDIT
|
||||
| ShowIndexStatement_EDIT
|
||||
| ShowLocksStatement_EDIT
|
||||
| ShowMaterializedViewsStatement_EDIT
|
||||
| ShowPartitionsStatement_EDIT
|
||||
| ShowRoleStatement_EDIT
|
||||
| ShowTablesStatement_EDIT
|
||||
| ShowTableStatement_EDIT
|
||||
| ShowTblPropertiesStatement_EDIT
|
||||
| ShowViewsStatement_EDIT
|
||||
;
|
||||
|
||||
ShowColumnsStatement
|
||||
: 'SHOW' 'COLUMNS' FromOrIn RegularOrBacktickedIdentifier
|
||||
| 'SHOW' 'COLUMNS' FromOrIn RegularOrBacktickedIdentifier FromOrIn RegularOrBacktickedIdentifier
|
||||
;
|
||||
|
||||
ShowColumnsStatement_EDIT
|
||||
: 'SHOW' 'COLUMNS' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['FROM', 'IN']);
|
||||
}
|
||||
| 'SHOW' 'COLUMNS' 'CURSOR' RegularOrBacktickedIdentifier
|
||||
{
|
||||
parser.suggestKeywords(['FROM', 'IN']);
|
||||
}
|
||||
| 'SHOW' 'COLUMNS' FromOrIn 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
}
|
||||
| 'SHOW' 'COLUMNS' FromOrIn 'CURSOR' FromOrIn
|
||||
{
|
||||
parser.suggestTables();
|
||||
}
|
||||
| 'SHOW' 'COLUMNS' FromOrIn 'CURSOR' FromOrIn RegularOrBacktickedIdentifier
|
||||
{
|
||||
parser.suggestTables();
|
||||
}
|
||||
| 'SHOW' 'COLUMNS' FromOrIn RegularOrBacktickedIdentifier 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['FROM', 'IN']);
|
||||
}
|
||||
| 'SHOW' 'COLUMNS' FromOrIn RegularOrBacktickedIdentifier 'CURSOR' RegularOrBacktickedIdentifier
|
||||
{
|
||||
parser.suggestKeywords(['FROM', 'IN']);
|
||||
}
|
||||
| 'SHOW' 'COLUMNS' FromOrIn RegularOrBacktickedIdentifier FromOrIn 'CURSOR'
|
||||
{
|
||||
parser.suggestDatabases();
|
||||
}
|
||||
;
|
||||
|
||||
ShowCompactionsStatement
|
||||
: 'SHOW' 'COMPACTIONS'
|
||||
;
|
||||
|
||||
ShowConfStatement
|
||||
: 'SHOW' 'CONF' ConfigurationName
|
||||
;
|
||||
|
||||
ShowCreateTableStatement
|
||||
: 'SHOW' 'CREATE' TableOrView RegularOrBackTickedSchemaQualifiedName
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
ShowCreateTableStatement_EDIT
|
||||
: 'SHOW' 'CREATE' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['TABLE']);
|
||||
}
|
||||
| 'SHOW' 'CREATE' TableOrView 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({
|
||||
appendDot: true
|
||||
});
|
||||
}
|
||||
| 'SHOW' 'CREATE' TableOrView RegularOrBackTickedSchemaQualifiedName_EDIT
|
||||
{
|
||||
if (parser.yy.result.suggestTables && $3.isView) {
|
||||
parser.yy.result.suggestTables.onlyViews = true;
|
||||
}
|
||||
}
|
||||
| 'SHOW' 'CREATE' 'CURSOR' RegularOrBackTickedSchemaQualifiedName
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
parser.suggestKeywords(['TABLE']);
|
||||
}
|
||||
;
|
||||
|
||||
TableOrView
|
||||
: 'TABLE'
|
||||
| 'VIEW' -> { isView: true }
|
||||
;
|
||||
|
||||
ShowCurrentRolesStatement
|
||||
: 'SHOW' 'CURRENT' 'ROLES'
|
||||
;
|
||||
|
||||
ShowCurrentRolesStatement_EDIT
|
||||
: 'SHOW' 'CURRENT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords([ 'ROLES' ]);
|
||||
}
|
||||
;
|
||||
|
||||
ShowDatabasesStatement
|
||||
: 'SHOW' DatabasesOrSchemas 'LIKE' SingleQuotedValue
|
||||
;
|
||||
|
||||
ShowDatabasesStatement_EDIT
|
||||
: 'SHOW' DatabasesOrSchemas 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['LIKE']);
|
||||
}
|
||||
;
|
||||
|
||||
ShowFunctionsStatement
|
||||
: 'SHOW' 'FUNCTIONS'
|
||||
| 'SHOW' 'FUNCTIONS' DoubleQuotedValue
|
||||
;
|
||||
|
||||
ShowGrantStatement
|
||||
: 'SHOW' 'GRANT' OptionalPrincipalName
|
||||
| 'SHOW' 'GRANT' OptionalPrincipalName 'ON' 'ALL'
|
||||
| 'SHOW' 'GRANT' OptionalPrincipalName 'ON' SchemaQualifiedTableIdentifier
|
||||
| 'SHOW' 'GRANT' OptionalPrincipalName 'ON' 'TABLE' SchemaQualifiedTableIdentifier
|
||||
;
|
||||
|
||||
ShowGrantStatement_EDIT
|
||||
: 'SHOW' 'GRANT' OptionalPrincipalName_EDIT
|
||||
{
|
||||
parser.suggestKeywords(['ON']);
|
||||
}
|
||||
| 'SHOW' 'GRANT' OptionalPrincipalName_EDIT 'ON' 'ALL'
|
||||
| 'SHOW' 'GRANT' OptionalPrincipalName 'ON' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['ALL', 'TABLE']);
|
||||
parser.suggestTables();
|
||||
}
|
||||
| 'SHOW' 'GRANT' OptionalPrincipalName 'ON' SchemaQualifiedTableIdentifier_EDIT
|
||||
| 'SHOW' 'GRANT' OptionalPrincipalName 'ON' 'TABLE' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
}
|
||||
| 'SHOW' 'GRANT' OptionalPrincipalName 'ON' 'CURSOR' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.suggestKeywords(['TABLE']);
|
||||
}
|
||||
| 'SHOW' 'GRANT' OptionalPrincipalName 'ON' 'CURSOR' SchemaQualifiedTableIdentifier_EDIT
|
||||
;
|
||||
|
||||
OptionalPrincipalName
|
||||
:
|
||||
| RegularIdentifier
|
||||
;
|
||||
|
||||
OptionalPrincipalName_EDIT
|
||||
: 'CURSOR'
|
||||
| RegularIdentifier 'CURSOR'
|
||||
;
|
||||
|
||||
ShowIndexStatement
|
||||
: 'SHOW' OptionallyFormattedIndex 'ON' RegularOrBacktickedIdentifier
|
||||
| 'SHOW' OptionallyFormattedIndex 'ON' RegularOrBacktickedIdentifier FromOrIn RegularOrBacktickedIdentifier
|
||||
;
|
||||
|
||||
ShowIndexStatement_EDIT
|
||||
: 'SHOW' OptionallyFormattedIndex
|
||||
| 'SHOW' OptionallyFormattedIndex_EDIT
|
||||
| 'SHOW' OptionallyFormattedIndex_EDIT 'ON' RegularOrBacktickedIdentifier
|
||||
| 'SHOW' OptionallyFormattedIndex_EDIT 'ON' RegularOrBacktickedIdentifier FromOrIn RegularOrBacktickedIdentifier
|
||||
| 'SHOW' OptionallyFormattedIndex 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['ON']);
|
||||
}
|
||||
| 'SHOW' OptionallyFormattedIndex 'ON' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
}
|
||||
| 'SHOW' OptionallyFormattedIndex 'CURSOR' RegularOrBacktickedIdentifier
|
||||
{
|
||||
parser.suggestKeywords(['ON']);
|
||||
}
|
||||
| 'SHOW' OptionallyFormattedIndex 'ON' RegularOrBacktickedIdentifier 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['FROM', 'IN']);
|
||||
}
|
||||
| 'SHOW' OptionallyFormattedIndex 'ON' RegularOrBacktickedIdentifier 'CURSOR' RegularOrBacktickedIdentifier
|
||||
{
|
||||
parser.suggestKeywords(['FROM', 'IN']);
|
||||
}
|
||||
| 'SHOW' OptionallyFormattedIndex 'ON' RegularOrBacktickedIdentifier FromOrIn 'CURSOR'
|
||||
{
|
||||
parser.suggestDatabases();
|
||||
}
|
||||
| 'SHOW' OptionallyFormattedIndex 'ON' 'CURSOR' FromOrIn RegularOrBacktickedIdentifier
|
||||
{
|
||||
parser.suggestTables({identifierChain: [{name: $6}]});
|
||||
}
|
||||
;
|
||||
|
||||
ShowMaterializedViewsStatement
|
||||
: 'SHOW' 'MATERIALIZED' 'VIEWS' OptionalInOrFromDatabase OptionalLike
|
||||
;
|
||||
|
||||
ShowMaterializedViewsStatement_EDIT
|
||||
: 'SHOW' 'MATERIALIZED' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['VIEWS']);
|
||||
}
|
||||
| 'SHOW' 'MATERIALIZED' 'VIEWS' OptionalInOrFromDatabase OptionalLike 'CURSOR'
|
||||
{
|
||||
if (!$5 && !$4) {
|
||||
parser.suggestKeywords([{ value: 'IN', weight: 2 }, { value: 'FROM', weight: 2 }, { value: 'LIKE', weight: 1 }]);
|
||||
} else if (!$5) {
|
||||
parser.suggestKeywords(['LIKE']);
|
||||
}
|
||||
}
|
||||
| 'SHOW' 'MATERIALIZED' 'VIEWS' InOrFromDatabase_EDIT OptionalLike
|
||||
| 'SHOW' 'MATERIALIZED' 'VIEWS' OptionalInOrFromDatabase Like_EDIT
|
||||
;
|
||||
|
||||
ShowLocksStatement
|
||||
: 'SHOW' 'LOCKS' RegularOrBackTickedSchemaQualifiedName
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
| 'SHOW' 'LOCKS' RegularOrBackTickedSchemaQualifiedName 'EXTENDED'
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
| 'SHOW' 'LOCKS' RegularOrBackTickedSchemaQualifiedName PartitionSpec
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
| 'SHOW' 'LOCKS' RegularOrBackTickedSchemaQualifiedName PartitionSpec 'EXTENDED'
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
| 'SHOW' 'LOCKS' DatabaseOrSchema RegularOrBacktickedIdentifier
|
||||
;
|
||||
|
||||
ShowLocksStatement_EDIT
|
||||
: 'SHOW' 'LOCKS' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({
|
||||
appendDot: true
|
||||
});
|
||||
parser.suggestKeywords(['DATABASE', 'SCHEMA']);
|
||||
}
|
||||
| 'SHOW' 'LOCKS' RegularOrBackTickedSchemaQualifiedName_EDIT
|
||||
| 'SHOW' 'LOCKS' RegularOrBackTickedSchemaQualifiedName 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
parser.suggestKeywords(['EXTENDED', 'PARTITION']);
|
||||
}
|
||||
| 'SHOW' 'LOCKS' RegularOrBackTickedSchemaQualifiedName_EDIT 'EXTENDED'
|
||||
| 'SHOW' 'LOCKS' RegularOrBackTickedSchemaQualifiedName_EDIT PartitionSpec
|
||||
| 'SHOW' 'LOCKS' RegularOrBackTickedSchemaQualifiedName PartitionSpec 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
parser.suggestKeywords(['EXTENDED']);
|
||||
}
|
||||
| 'SHOW' 'LOCKS' RegularOrBackTickedSchemaQualifiedName_EDIT PartitionSpec 'EXTENDED'
|
||||
| 'SHOW' 'LOCKS' DatabaseOrSchema 'CURSOR'
|
||||
{
|
||||
parser.suggestDatabases();
|
||||
}
|
||||
;
|
||||
|
||||
ShowPartitionsStatement
|
||||
: 'SHOW' 'PARTITIONS' RegularOrBackTickedSchemaQualifiedName
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
| 'SHOW' 'PARTITIONS' RegularOrBackTickedSchemaQualifiedName PartitionSpec
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
;
|
||||
|
||||
ShowPartitionsStatement_EDIT
|
||||
: 'SHOW' 'PARTITIONS' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({
|
||||
appendDot: true
|
||||
});
|
||||
}
|
||||
| 'SHOW' 'PARTITIONS' RegularOrBackTickedSchemaQualifiedName_EDIT
|
||||
| 'SHOW' 'PARTITIONS' RegularOrBackTickedSchemaQualifiedName 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
| 'SHOW' 'PARTITIONS' RegularOrBackTickedSchemaQualifiedName_EDIT PartitionSpec
|
||||
;
|
||||
|
||||
ShowRoleStatement
|
||||
: 'SHOW' 'ROLE' 'GRANT' RoleOrUser RegularIdentifier
|
||||
;
|
||||
|
||||
ShowRoleStatement_EDIT
|
||||
: 'SHOW' 'ROLE' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['GRANT']);
|
||||
}
|
||||
| 'SHOW' 'ROLE' 'CURSOR' RoleOrUser RegularIdentifier
|
||||
{
|
||||
parser.suggestKeywords(['GRANT']);
|
||||
}
|
||||
| 'SHOW' 'ROLE' 'GRANT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['ROLE', 'USER']);
|
||||
}
|
||||
| 'SHOW' 'ROLE' 'GRANT' 'CURSOR' RegularIdentifier
|
||||
{
|
||||
parser.suggestKeywords(['ROLE', 'USER']);
|
||||
}
|
||||
;
|
||||
|
||||
ShowRolesStatement
|
||||
: 'SHOW' 'ROLES'
|
||||
;
|
||||
|
||||
ShowTableStatement
|
||||
: 'SHOW' 'TABLE' 'EXTENDED' OptionalFromDatabase 'LIKE' SingleQuotedValue
|
||||
| 'SHOW' 'TABLE' 'EXTENDED' OptionalFromDatabase 'LIKE' SingleQuotedValue PartitionSpec
|
||||
;
|
||||
|
||||
ShowTableStatement_EDIT
|
||||
: 'SHOW' 'TABLE' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['EXTENDED']);
|
||||
}
|
||||
| 'SHOW' 'TABLE' 'EXTENDED' OptionalFromDatabase
|
||||
| 'SHOW' 'TABLE' 'EXTENDED' OptionalFromDatabase_EDIT
|
||||
| 'SHOW' 'TABLE' 'EXTENDED' OptionalFromDatabase 'CURSOR'
|
||||
{
|
||||
if ($4) {
|
||||
parser.suggestKeywords(['LIKE']);
|
||||
} else {
|
||||
parser.suggestKeywords(['FROM', 'IN', 'LIKE']);
|
||||
}
|
||||
}
|
||||
| 'SHOW' 'TABLE' 'EXTENDED' OptionalFromDatabase_EDIT 'LIKE' SingleQuotedValue
|
||||
| 'SHOW' 'TABLE' 'CURSOR' OptionalFromDatabase 'LIKE' SingleQuotedValue
|
||||
{
|
||||
parser.suggestKeywords(['EXTENDED']);
|
||||
}
|
||||
| 'SHOW' 'TABLE' 'EXTENDED' OptionalFromDatabase 'CURSOR' SingleQuotedValue
|
||||
{
|
||||
parser.suggestKeywords(['LIKE']);
|
||||
}
|
||||
| 'SHOW' 'TABLE' 'EXTENDED' OptionalFromDatabase 'LIKE' SingleQuotedValue 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
| 'SHOW' 'TABLE' 'EXTENDED' OptionalFromDatabase_EDIT 'LIKE' SingleQuotedValue PartitionSpec
|
||||
| 'SHOW' 'TABLE' 'CURSOR' OptionalFromDatabase 'LIKE' SingleQuotedValue PartitionSpec
|
||||
{
|
||||
parser.suggestKeywords(['EXTENDED']);
|
||||
}
|
||||
| 'SHOW' 'TABLE' 'EXTENDED' OptionalFromDatabase 'CURSOR' SingleQuotedValue PartitionSpec
|
||||
{
|
||||
parser.suggestKeywords(['LIKE']);
|
||||
}
|
||||
| 'SHOW' 'TABLE' 'EXTENDED' OptionalFromDatabase 'LIKE' SingleQuotedValue 'CURSOR' PartitionSpecList
|
||||
{
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
;
|
||||
|
||||
ShowTablesStatement
|
||||
: 'SHOW' 'TABLES' OptionalInDatabase
|
||||
| 'SHOW' 'TABLES' OptionalInDatabase SingleQuotedValue
|
||||
| 'SHOW' 'TABLES' OptionalInDatabase 'LIKE' SingleQuotedValue
|
||||
;
|
||||
|
||||
ShowTablesStatement_EDIT
|
||||
: 'SHOW' 'TABLES' OptionalInDatabase 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IN', 'LIKE']);
|
||||
} else {
|
||||
parser.suggestKeywords(['LIKE']);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
ShowTblPropertiesStatement
|
||||
: 'SHOW' 'TBLPROPERTIES' RegularOrBackTickedSchemaQualifiedName
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
| 'SHOW' 'TBLPROPERTIES' RegularOrBackTickedSchemaQualifiedName '(' QuotedValue ')'
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
;
|
||||
|
||||
ShowTblPropertiesStatement_EDIT
|
||||
: 'SHOW' 'TBLPROPERTIES' RegularOrBackTickedSchemaQualifiedName_EDIT
|
||||
| 'SHOW' 'TBLPROPERTIES' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ prependDot: true });
|
||||
}
|
||||
;
|
||||
|
||||
ShowTransactionsStatement
|
||||
: 'SHOW' 'TRANSACTIONS'
|
||||
;
|
||||
|
||||
ShowViewsStatement
|
||||
: 'SHOW' 'VIEWS' OptionalInOrFromDatabase OptionalLike
|
||||
;
|
||||
|
||||
ShowViewsStatement_EDIT
|
||||
: 'SHOW' 'VIEWS' OptionalInOrFromDatabase OptionalLike 'CURSOR'
|
||||
{
|
||||
if (!$4 && !$3) {
|
||||
parser.suggestKeywords([{ value: 'IN', weight: 2 }, { value: 'FROM', weight: 2 }, { value: 'LIKE', weight: 1 }]);
|
||||
} else if (!$4) {
|
||||
parser.suggestKeywords(['LIKE']);
|
||||
}
|
||||
}
|
||||
| 'SHOW' 'VIEWS' InOrFromDatabase_EDIT OptionalLike
|
||||
| 'SHOW' 'VIEWS' OptionalInOrFromDatabase Like_EDIT
|
||||
;
|
||||
|
||||
OptionalInOrFromDatabase
|
||||
:
|
||||
| 'IN' RegularOrBacktickedIdentifier
|
||||
{
|
||||
parser.addDatabaseLocation(@2, [ { name: $2 } ]);
|
||||
}
|
||||
| 'FROM' RegularOrBacktickedIdentifier
|
||||
{
|
||||
parser.addDatabaseLocation(@2, [ { name: $2 } ]);
|
||||
}
|
||||
;
|
||||
|
||||
InOrFromDatabase_EDIT
|
||||
: 'IN' 'CURSOR'
|
||||
{
|
||||
parser.suggestDatabases();
|
||||
}
|
||||
| 'FROM' 'CURSOR'
|
||||
{
|
||||
parser.suggestDatabases();
|
||||
}
|
||||
;
|
||||
|
||||
OptionalLike
|
||||
:
|
||||
| 'LIKE' SingleQuotedValue
|
||||
;
|
||||
|
||||
Like_EDIT
|
||||
: 'LIKE' 'CURSOR'
|
||||
;
|
124
src/jison/sql/hive/sql_update.jison
Normal file
124
src/jison/sql/hive/sql_update.jison
Normal file
@ -0,0 +1,124 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataManipulation
|
||||
: UpdateStatement
|
||||
;
|
||||
|
||||
DataManipulation_EDIT
|
||||
: UpdateStatement_EDIT
|
||||
;
|
||||
|
||||
UpdateStatement
|
||||
: 'UPDATE' TargetTable 'SET' SetClauseList OptionalFromJoinedTable OptionalWhereClause
|
||||
;
|
||||
|
||||
UpdateStatement_EDIT
|
||||
: 'UPDATE' TargetTable_EDIT 'SET' SetClauseList OptionalFromJoinedTable OptionalWhereClause
|
||||
| 'UPDATE' TargetTable 'SET' SetClauseList_EDIT OptionalFromJoinedTable OptionalWhereClause
|
||||
| 'UPDATE' TargetTable 'SET' SetClauseList FromJoinedTable_EDIT OptionalWhereClause
|
||||
| 'UPDATE' TargetTable 'SET' SetClauseList OptionalFromJoinedTable WhereClause_EDIT
|
||||
| 'UPDATE' TargetTable 'SET' SetClauseList OptionalFromJoinedTable OptionalWhereClause 'CURSOR'
|
||||
{
|
||||
if (!$6) {
|
||||
parser.suggestKeywords([ 'WHERE' ]);
|
||||
}
|
||||
}
|
||||
| 'UPDATE' TargetTable 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords([ 'SET' ]);
|
||||
}
|
||||
| 'UPDATE' TargetTable_EDIT
|
||||
| 'UPDATE' TargetTable
|
||||
| 'UPDATE' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
;
|
||||
|
||||
TargetTable
|
||||
: TableName
|
||||
;
|
||||
|
||||
TargetTable_EDIT
|
||||
: TableName_EDIT
|
||||
;
|
||||
|
||||
TableName
|
||||
: LocalOrSchemaQualifiedName
|
||||
{
|
||||
parser.addTablePrimary($1);
|
||||
}
|
||||
;
|
||||
|
||||
TableName_EDIT
|
||||
: LocalOrSchemaQualifiedName_EDIT
|
||||
;
|
||||
|
||||
SetClauseList
|
||||
: SetClause
|
||||
| SetClauseList ',' SetClause
|
||||
;
|
||||
|
||||
SetClauseList_EDIT
|
||||
: SetClause_EDIT
|
||||
| SetClauseList ',' SetClause_EDIT
|
||||
| SetClause_EDIT ',' SetClauseList
|
||||
| SetClauseList ',' SetClause_EDIT ',' SetClauseList
|
||||
;
|
||||
|
||||
SetClause
|
||||
: SetTarget '=' UpdateSource
|
||||
;
|
||||
|
||||
SetClause_EDIT
|
||||
: SetTarget '=' UpdateSource_EDIT
|
||||
| SetTarget 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords([ '=' ]);
|
||||
}
|
||||
| 'CURSOR'
|
||||
{
|
||||
parser.suggestColumns();
|
||||
}
|
||||
;
|
||||
|
||||
SetTarget
|
||||
: ColumnReference
|
||||
;
|
||||
|
||||
UpdateSource
|
||||
: ValueExpression
|
||||
;
|
||||
|
||||
UpdateSource_EDIT
|
||||
: ValueExpression_EDIT
|
||||
;
|
||||
|
||||
OptionalFromJoinedTable
|
||||
:
|
||||
| 'FROM' TableReference -> $2
|
||||
;
|
||||
|
||||
FromJoinedTable_EDIT
|
||||
: 'FROM' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'FROM' TableReference_EDIT
|
||||
;
|
42
src/jison/sql/hive/sql_use.jison
Normal file
42
src/jison/sql/hive/sql_use.jison
Normal file
@ -0,0 +1,42 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: UseStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: UseStatement_EDIT
|
||||
;
|
||||
|
||||
UseStatement
|
||||
: 'USE' RegularIdentifier
|
||||
{
|
||||
if (! parser.yy.cursorFound) {
|
||||
parser.yy.result.useDatabase = $2;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
UseStatement_EDIT
|
||||
: 'USE' 'CURSOR'
|
||||
{
|
||||
parser.suggestDatabases();
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
// ===================================== Fin =====================================
|
839
src/jison/sql/hive/sql_valueExpression.jison
Normal file
839
src/jison/sql/hive/sql_valueExpression.jison
Normal file
@ -0,0 +1,839 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
ValueExpression
|
||||
: 'NOT' ValueExpression
|
||||
{
|
||||
// verifyType($2, 'BOOLEAN');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| '!' ValueExpression
|
||||
{
|
||||
// verifyType($2, 'BOOLEAN');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| '~' ValueExpression -> $2
|
||||
| '-' ValueExpression %prec NEGATION
|
||||
{
|
||||
// verifyType($2, 'NUMBER');
|
||||
$$ = $2;
|
||||
$2.types = ['NUMBER'];
|
||||
}
|
||||
| ValueExpression 'IS' OptionalNot 'NULL' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IS' OptionalNot 'TRUE' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IS' OptionalNot 'FALSE' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IS' OptionalNot 'DISTINCT' 'FROM' ValueExpression -> { types: [ 'BOOLEAN' ] }
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'NOT' ValueExpression_EDIT -> { types: [ 'BOOLEAN' ], suggestFilters: $2.suggestFilters }
|
||||
| 'NOT' 'CURSOR'
|
||||
{
|
||||
parser.suggestFunctions();
|
||||
parser.suggestColumns();
|
||||
parser.suggestKeywords(['EXISTS']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| '!' ValueExpression_EDIT -> { types: [ 'BOOLEAN' ], suggestFilters: $2.suggestFilters }
|
||||
| '!' AnyCursor
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'BOOLEAN' ] });
|
||||
parser.suggestColumns({ types: [ 'BOOLEAN' ] });
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| '~' ValueExpression_EDIT -> { types: [ 'T' ], suggestFilters: $2.suggestFilters }
|
||||
| '~' 'PARTIAL_CURSOR'
|
||||
{
|
||||
parser.suggestFunctions();
|
||||
parser.suggestColumns();
|
||||
$$ = { types: [ 'T' ] };
|
||||
}
|
||||
| '-' ValueExpression_EDIT %prec NEGATION
|
||||
{
|
||||
if (!$2.typeSet) {
|
||||
parser.applyTypeToSuggestions('NUMBER');
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $2.suggestFilters };
|
||||
}
|
||||
| '-' 'PARTIAL_CURSOR' %prec NEGATION
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'NUMBER' ] });
|
||||
parser.suggestColumns({ types: [ 'NUMBER' ] });
|
||||
$$ = { types: [ 'NUMBER' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['FALSE', 'NOT NULL', 'NOT TRUE', 'NOT FALSE', 'NULL', 'TRUE']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'NOT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['FALSE', 'NULL', 'TRUE']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' OptionalNot 'DISTINCT' 'CURSOR'
|
||||
{
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'CURSOR' 'NULL'
|
||||
{
|
||||
parser.suggestKeywords(['NOT']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'CURSOR' 'FALSE'
|
||||
{
|
||||
parser.suggestKeywords(['NOT']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'CURSOR' 'TRUE'
|
||||
{
|
||||
parser.suggestKeywords(['NOT']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' OptionalNot 'DISTINCT' 'FROM' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $3 ? 'IS NOT DISTINCT FROM' : 'IS DISTINCT FROM');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' OptionalNot 'DISTINCT' 'FROM' ValueExpression_EDIT
|
||||
{
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $6.suggestFilters }
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ EXISTS and parenthesized ------------------
|
||||
ValueExpression
|
||||
: 'EXISTS' TableSubQuery
|
||||
{
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
// clear correlated flag after completed sub-query (set by lexer)
|
||||
parser.yy.correlatedSubQuery = false;
|
||||
}
|
||||
| '(' ValueExpression ')' -> $2
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'EXISTS' TableSubQuery_EDIT -> { types: [ 'BOOLEAN' ] }
|
||||
| '(' ValueExpression_EDIT RightParenthesisOrError
|
||||
{
|
||||
$$ = $2;
|
||||
}
|
||||
| '(' 'CURSOR' RightParenthesisOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { types: ['T'], typeSet: true };
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ COMPARISON ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression '=' ValueExpression
|
||||
{
|
||||
parser.addColRefToVariableIfExists($1, $3);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression '<' ValueExpression
|
||||
{
|
||||
parser.addColRefToVariableIfExists($1, $3);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression '>' ValueExpression
|
||||
{
|
||||
parser.addColRefToVariableIfExists($1, $3);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'COMPARISON_OPERATOR' ValueExpression
|
||||
{
|
||||
parser.addColRefToVariableIfExists($1, $3);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'CURSOR' '=' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest($3, $2);
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' '<' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest($3, $2);
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' '>' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest($3, $2);
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' 'COMPARISON_OPERATOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest($3, $2);
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression_EDIT '=' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT '<' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT '>' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT 'COMPARISON_OPERATOR' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression '=' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression '<' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ] , typeSet: true, endsWithLessThanOrEqual: true };
|
||||
}
|
||||
| ValueExpression '>' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'COMPARISON_OPERATOR' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, endsWithLessThanOrEqual: $2 === '<=' };
|
||||
}
|
||||
| ValueExpression '=' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
| ValueExpression '<' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
| ValueExpression '>' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
| ValueExpression 'COMPARISON_OPERATOR' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
// ------------------ IN ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression 'NOT' 'IN' '(' TableSubQueryInner ')' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'NOT' 'IN' '(' ValueExpressionList ')' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IN' '(' TableSubQueryInner ')' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IN' '(' ValueExpressionList ')' -> { types: [ 'BOOLEAN' ] }
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: ValueExpression 'NOT' 'IN' ValueExpressionInSecondPart_EDIT
|
||||
{
|
||||
if ($4.inValueEdit) {
|
||||
parser.valueExpressionSuggest($1, $2 + ' ' + $3);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
}
|
||||
if ($4.cursorAtStart) {
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'IN' ValueExpressionInSecondPart_EDIT
|
||||
{
|
||||
if ($3.inValueEdit) {
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
}
|
||||
if ($3.cursorAtStart) {
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression_EDIT 'NOT' 'IN' '(' ValueExpressionList RightParenthesisOrError -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression_EDIT 'NOT' 'IN' '(' TableSubQueryInner RightParenthesisOrError -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression_EDIT 'IN' '(' ValueExpressionList RightParenthesisOrError -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression_EDIT 'IN' '(' TableSubQueryInner RightParenthesisOrError -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
;
|
||||
|
||||
ValueExpressionInSecondPart_EDIT
|
||||
: '(' TableSubQueryInner_EDIT RightParenthesisOrError
|
||||
| '(' ValueExpressionList_EDIT RightParenthesisOrError -> { inValueEdit: true }
|
||||
| '(' AnyCursor RightParenthesisOrError -> { inValueEdit: true, cursorAtStart: true }
|
||||
;
|
||||
|
||||
// ------------------ BETWEEN ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression 'NOT' 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression -> { types: [ 'BOOLEAN' ] }
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: ValueExpression_EDIT 'NOT' 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression
|
||||
{
|
||||
if ($4.types[0] === $6.types[0] && !$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($4.types);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' ValueExpression_EDIT 'BETWEEN_AND' ValueExpression
|
||||
{
|
||||
if ($1.types[0] === $6.types[0] && !$4.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $4.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression_EDIT
|
||||
{
|
||||
if ($1.types[0] === $4.types[0] && !$6.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $6.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' ValueExpression 'BETWEEN_AND' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $5);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($4, ['AND']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2 + ' ' + $3);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression_EDIT 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression
|
||||
{
|
||||
if ($1.types[0] === $3.types[0] && !$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types)
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' ValueExpression_EDIT 'BETWEEN_AND' ValueExpression
|
||||
{
|
||||
if ($1.types[0] === $3.types[0] && !$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types)
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression_EDIT
|
||||
{
|
||||
if ($1.types[0] === $3.types[0] && !$5.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types)
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $5.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' ValueExpression 'BETWEEN_AND' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $4);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($3, ['AND']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ BOOLEAN ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression 'OR' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'BOOLEAN');
|
||||
// verifyType($3, 'BOOLEAN');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'AND' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'BOOLEAN');
|
||||
// verifyType($3, 'BOOLEAN');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'CURSOR' 'OR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, suggestFilters: true };
|
||||
}
|
||||
| ValueExpression_EDIT 'OR' ValueExpression
|
||||
{
|
||||
parser.addColRefIfExists($3);
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression 'OR' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, suggestFilters: true };
|
||||
}
|
||||
| ValueExpression 'OR' ValueExpression_EDIT
|
||||
{
|
||||
parser.addColRefIfExists($1);
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
| 'CURSOR' 'AND' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, suggestFilters: true };
|
||||
}
|
||||
| ValueExpression_EDIT 'AND' ValueExpression
|
||||
{
|
||||
parser.addColRefIfExists($3);
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression 'AND' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, suggestFilters: true };
|
||||
}
|
||||
| ValueExpression 'AND' ValueExpression_EDIT
|
||||
{
|
||||
parser.addColRefIfExists($1);
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ ARITHMETIC ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression '-' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'NUMBER');
|
||||
// verifyType($3, 'NUMBER');
|
||||
$$ = { types: [ 'NUMBER' ] };
|
||||
}
|
||||
| ValueExpression '*' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'NUMBER');
|
||||
// verifyType($3, 'NUMBER');
|
||||
$$ = { types: [ 'NUMBER' ] };
|
||||
}
|
||||
| ValueExpression 'ARITHMETIC_OPERATOR' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'NUMBER');
|
||||
// verifyType($3, 'NUMBER');
|
||||
$$ = { types: [ 'NUMBER' ] };
|
||||
}
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'CURSOR' '*' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions([ 'NUMBER' ]);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' 'ARITHMETIC_OPERATOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions([ 'NUMBER' ]);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression_EDIT '-' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT '*' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT 'ARITHMETIC_OPERATOR' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression '-' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression '*' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'ARITHMETIC_OPERATOR' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression '-' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $3.suggestFilters };
|
||||
}
|
||||
| ValueExpression '*' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $3.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'ARITHMETIC_OPERATOR' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $3.suggestFilters };
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ LIKE, RLIKE and REGEXP ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression LikeRightPart -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'NOT' LikeRightPart -> { types: [ 'BOOLEAN' ] }
|
||||
;
|
||||
|
||||
LikeRightPart
|
||||
: 'LIKE' ValueExpression -> { suggestKeywords: ['NOT'] }
|
||||
| 'RLIKE' ValueExpression -> { suggestKeywords: ['NOT'] }
|
||||
| 'REGEXP' ValueExpression -> { suggestKeywords: ['NOT'] }
|
||||
;
|
||||
|
||||
LikeRightPart_EDIT
|
||||
: 'LIKE' ValueExpression_EDIT
|
||||
| 'RLIKE' ValueExpression_EDIT
|
||||
| 'REGEXP' ValueExpression_EDIT
|
||||
| 'LIKE' PartialBacktickedOrCursor
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'STRING' ] });
|
||||
parser.suggestColumns({ types: [ 'STRING' ] });
|
||||
$$ = { types: ['BOOLEAN'] }
|
||||
}
|
||||
| 'RLIKE' PartialBacktickedOrCursor
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'STRING' ] });
|
||||
parser.suggestColumns({ types: [ 'STRING' ] });
|
||||
$$ = { types: ['BOOLEAN'] }
|
||||
}
|
||||
| 'REGEXP' PartialBacktickedOrCursor
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'STRING' ] });
|
||||
parser.suggestColumns({ types: [ 'STRING' ] });
|
||||
$$ = { types: ['BOOLEAN'] }
|
||||
}
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: ValueExpression_EDIT LikeRightPart -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression_EDIT 'NOT' LikeRightPart -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression LikeRightPart_EDIT -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'NOT' LikeRightPart_EDIT -> { types: [ 'BOOLEAN' ] }
|
||||
| 'CURSOR' LikeRightPart
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions([ 'STRING' ]);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' 'NOT' LikeRightPart
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2 + ' ' + $3);
|
||||
parser.applyTypeToSuggestions([ 'STRING' ]);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ CASE, WHEN, THEN ------------------
|
||||
|
||||
ValueExpression
|
||||
: 'CASE' CaseRightPart -> $2
|
||||
| 'CASE' ValueExpression CaseRightPart -> $3
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'CASE' CaseRightPart_EDIT -> $2
|
||||
| 'CASE' 'CURSOR' EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { types: [ 'T' ], typeSet: true };
|
||||
}
|
||||
| 'CASE' ValueExpression CaseRightPart_EDIT -> $3
|
||||
| 'CASE' ValueExpression 'CURSOR' EndOrError
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($2, ['WHEN']);
|
||||
$$ = { types: [ 'T' ], typeSet: true };
|
||||
}
|
||||
| 'CASE' ValueExpression_EDIT CaseRightPart
|
||||
{
|
||||
$$ = $3;
|
||||
$$.suggestFilters = $2.suggestFilters;
|
||||
}
|
||||
| 'CASE' ValueExpression_EDIT EndOrError -> { types: [ 'T' ], suggestFilters: $2.suggestFilters }
|
||||
| 'CASE' 'CURSOR' CaseRightPart -> { types: [ 'T' ] }
|
||||
;
|
||||
|
||||
CaseRightPart
|
||||
: CaseWhenThenList 'END' -> parser.findCaseType($1)
|
||||
| CaseWhenThenList 'ELSE' ValueExpression 'END'
|
||||
{
|
||||
$1.caseTypes.push($3);
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
;
|
||||
|
||||
CaseRightPart_EDIT
|
||||
: CaseWhenThenList_EDIT EndOrError -> parser.findCaseType($1)
|
||||
| CaseWhenThenList 'ELSE' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($3, ['END']);
|
||||
$1.caseTypes.push($3);
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| CaseWhenThenList_EDIT 'ELSE' ValueExpression EndOrError
|
||||
{
|
||||
$1.caseTypes.push($3);
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| CaseWhenThenList_EDIT 'ELSE' EndOrError -> parser.findCaseType($1)
|
||||
| CaseWhenThenList 'CURSOR' ValueExpression EndOrError
|
||||
{
|
||||
if ($4.toLowerCase() !== 'end') {
|
||||
parser.suggestValueExpressionKeywords($1, [{ value: 'END', weight: 3 }, { value: 'ELSE', weight: 2 }, { value: 'WHEN', weight: 1 }]);
|
||||
} else {
|
||||
parser.suggestValueExpressionKeywords($1, [{ value: 'ELSE', weight: 2 }, { value: 'WHEN', weight: 1 }]);
|
||||
}
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| CaseWhenThenList 'CURSOR' EndOrError
|
||||
{
|
||||
if ($3.toLowerCase() !== 'end') {
|
||||
parser.suggestValueExpressionKeywords($1, [{ value: 'END', weight: 3 }, { value: 'ELSE', weight: 2 }, { value: 'WHEN', weight: 1 }]);
|
||||
} else {
|
||||
parser.suggestValueExpressionKeywords($1, [{ value: 'ELSE', weight: 2 }, { value: 'WHEN', weight: 1 }]);
|
||||
}
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| CaseWhenThenList 'ELSE' ValueExpression_EDIT EndOrError
|
||||
{
|
||||
$1.caseTypes.push($3);
|
||||
$$ = parser.findCaseType($1);
|
||||
$$.suggestFilters = $3.suggestFilters
|
||||
}
|
||||
| CaseWhenThenList 'ELSE' 'CURSOR' EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| 'ELSE' 'CURSOR' EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { types: [ 'T' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' 'ELSE' ValueExpression EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = $3;
|
||||
}
|
||||
| 'CURSOR' 'ELSE' EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { types: [ 'T' ] };
|
||||
}
|
||||
;
|
||||
|
||||
EndOrError
|
||||
: 'END'
|
||||
| error
|
||||
;
|
||||
|
||||
CaseWhenThenList
|
||||
: CaseWhenThenListPartTwo -> { caseTypes: [ $1 ], lastType: $1 }
|
||||
| CaseWhenThenList CaseWhenThenListPartTwo
|
||||
{
|
||||
$1.caseTypes.push($2);
|
||||
$$ = { caseTypes: $1.caseTypes, lastType: $2 };
|
||||
}
|
||||
;
|
||||
|
||||
CaseWhenThenList_EDIT
|
||||
: CaseWhenThenListPartTwo_EDIT
|
||||
| CaseWhenThenList CaseWhenThenListPartTwo_EDIT
|
||||
| CaseWhenThenList CaseWhenThenListPartTwo_EDIT CaseWhenThenList
|
||||
| CaseWhenThenList 'CURSOR' CaseWhenThenList
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($1, ['WHEN']);
|
||||
}
|
||||
| CaseWhenThenListPartTwo_EDIT CaseWhenThenList -> $2
|
||||
;
|
||||
|
||||
CaseWhenThenListPartTwo
|
||||
: 'WHEN' ValueExpression 'THEN' ValueExpression -> $4
|
||||
;
|
||||
|
||||
CaseWhenThenListPartTwo_EDIT
|
||||
: 'WHEN' ValueExpression_EDIT -> { caseTypes: [{ types: ['T'] }], suggestFilters: $2.suggestFilters }
|
||||
| 'WHEN' ValueExpression_EDIT 'THEN' -> { caseTypes: [{ types: ['T'] }], suggestFilters: $2.suggestFilters }
|
||||
| 'WHEN' ValueExpression_EDIT 'THEN' ValueExpression -> { caseTypes: [$4], suggestFilters: $2.suggestFilters }
|
||||
| 'WHEN' ValueExpression 'THEN' ValueExpression_EDIT -> { caseTypes: [$4], suggestFilters: $4.suggestFilters }
|
||||
| 'WHEN' 'THEN' ValueExpression_EDIT -> { caseTypes: [$3], suggestFilters: $3.suggestFilters }
|
||||
| 'CURSOR' ValueExpression 'THEN'
|
||||
{
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'CURSOR' ValueExpression 'THEN' ValueExpression
|
||||
{
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { caseTypes: [$4] };
|
||||
}
|
||||
| 'CURSOR' 'THEN'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'CURSOR' 'THEN' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }], suggestFilters: true };
|
||||
}
|
||||
| 'WHEN' 'CURSOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['THEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }], suggestFilters: true };
|
||||
}
|
||||
| 'WHEN' 'CURSOR' 'THEN'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }], suggestFilters: true };
|
||||
}
|
||||
| 'WHEN' 'CURSOR' 'THEN' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [$4], suggestFilters: true };
|
||||
}
|
||||
| 'WHEN' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($2, ['THEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' ValueExpression 'CURSOR' ValueExpression
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($2, ['THEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' ValueExpression 'THEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' ValueExpression 'THEN' 'CURSOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' 'THEN' 'CURSOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' 'THEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
;
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user