Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[editor] Add SparkSQL autocomplete for DROP, INSERT, LOAD, MSCK and T…
…RUNCATE statements
- Loading branch information
1 parent
f44ad92
commit 11fc7d8
Showing
30 changed files
with
4,035 additions
and
1,283 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
desktop/core/src/desktop/js/parse/sql/sparksql/jison/drop/drop_common.jison
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// 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_EDIT | ||
: 'DROP' 'CURSOR' | ||
{ | ||
parser.suggestKeywords(['DATABASE', 'FUNCTION', 'SCHEMA', 'TABLE', 'TEMPORARY FUNCTION', 'VIEW']); | ||
} | ||
; |
13 changes: 13 additions & 0 deletions
13
desktop/core/src/desktop/js/parse/sql/sparksql/jison/drop/drop_common.test.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[ | ||
{ | ||
"namePrefix": "should suggest keywords", | ||
"beforeCursor": "", | ||
"afterCursor": "", | ||
"containsKeywords": [ | ||
"DROP" | ||
], | ||
"expectedResult": { | ||
"lowerCase": false | ||
} | ||
} | ||
] |
49 changes: 49 additions & 0 deletions
49
desktop/core/src/desktop/js/parse/sql/sparksql/jison/drop/drop_function.jison
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// 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 | ||
: DropFunctionStatement | ||
; | ||
|
||
DataDefinition_EDIT | ||
: DropFunctionStatement_EDIT | ||
; | ||
|
||
DropFunctionStatement | ||
: 'DROP' OptionalTemporary 'FUNCTION' OptionalIfExists SchemaQualifiedIdentifier | ||
; | ||
|
||
DropFunctionStatement_EDIT | ||
: 'DROP' 'TEMPORARY' 'CURSOR' | ||
{ | ||
parser.suggestKeywords(['FUNCTION']); | ||
} | ||
| 'DROP' OptionalTemporary 'FUNCTION' OptionalIfExists 'CURSOR' | ||
{ | ||
if (!$4) { | ||
parser.suggestKeywords(['IF EXISTS']); | ||
} | ||
} | ||
| 'DROP' OptionalTemporary 'FUNCTION' OptionalIfExists 'CURSOR' SchemaQualifiedIdentifier | ||
{ | ||
if (!$4) { | ||
parser.suggestKeywords(['IF EXISTS']); | ||
} | ||
} | ||
| 'DROP' OptionalTemporary 'FUNCTION' OptionalIfExists_EDIT | ||
| 'DROP' OptionalTemporary 'FUNCTION' OptionalIfExists_EDIT SchemaQualifiedIdentifier | ||
| 'DROP' OptionalTemporary 'FUNCTION' OptionalIfExists SchemaQualifiedIdentifier_EDIT | ||
; |
59 changes: 59 additions & 0 deletions
59
desktop/core/src/desktop/js/parse/sql/sparksql/jison/drop/drop_function.test.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
[ | ||
{ | ||
"namePrefix": "should handle", | ||
"beforeCursor": "DROP TEMPORARY FUNCTION IF EXISTS baa;", | ||
"afterCursor": "", | ||
"containsKeywords": [ | ||
"SELECT" | ||
], | ||
"noErrors": true, | ||
"expectedResult": { | ||
"lowerCase": false | ||
} | ||
}, | ||
{ | ||
"namePrefix": "should suggest keywords", | ||
"beforeCursor": "DROP ", | ||
"afterCursor": "", | ||
"containsKeywords": [ | ||
"FUNCTION", | ||
"TEMPORARY FUNCTION" | ||
], | ||
"expectedResult": { | ||
"lowerCase": false | ||
} | ||
}, | ||
{ | ||
"namePrefix": "should suggest keywords", | ||
"beforeCursor": "DROP TEMPORARY ", | ||
"afterCursor": "", | ||
"containsKeywords": [ | ||
"FUNCTION" | ||
], | ||
"expectedResult": { | ||
"lowerCase": false | ||
} | ||
}, | ||
{ | ||
"namePrefix": "should suggest keywords", | ||
"beforeCursor": "DROP FUNCTION ", | ||
"afterCursor": "", | ||
"expectedResult": { | ||
"lowerCase": false, | ||
"suggestKeywords": [ | ||
"IF EXISTS" | ||
] | ||
} | ||
}, | ||
{ | ||
"namePrefix": "should suggest keywords", | ||
"beforeCursor": "DROP FUNCTION IF ", | ||
"afterCursor": "", | ||
"expectedResult": { | ||
"lowerCase": false, | ||
"suggestKeywords": [ | ||
"EXISTS" | ||
] | ||
} | ||
} | ||
] |
57 changes: 57 additions & 0 deletions
57
desktop/core/src/desktop/js/parse/sql/sparksql/jison/drop/drop_table.jison
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// 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 | ||
: DropTableStatement | ||
; | ||
|
||
DataDefinition_EDIT | ||
: DropTableStatement_EDIT | ||
; | ||
|
||
DropTableStatement | ||
: 'DROP' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier | ||
{ | ||
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 | ||
{ | ||
if (parser.yy.result.suggestTables) { | ||
parser.yy.result.suggestTables.onlyTables = true; | ||
} | ||
} | ||
| 'DROP' 'TABLE' OptionalIfExists 'CURSOR' SchemaQualifiedTableIdentifier | ||
{ | ||
if (!$3) { | ||
parser.suggestKeywords(['IF EXISTS']); | ||
} | ||
} | ||
| 'DROP' 'TABLE' OptionalIfExists_EDIT SchemaQualifiedTableIdentifier | ||
; |
94 changes: 94 additions & 0 deletions
94
desktop/core/src/desktop/js/parse/sql/sparksql/jison/drop/drop_table.test.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
[ | ||
{ | ||
"namePrefix": "should handle", | ||
"beforeCursor": "DROP TABLE IF EXISTS db.tbl;", | ||
"afterCursor": "", | ||
"containsKeywords": [ | ||
"SELECT" | ||
], | ||
"noErrors": true, | ||
"expectedResult": { | ||
"lowerCase": false | ||
} | ||
}, | ||
{ | ||
"namePrefix": "should suggest keywords", | ||
"beforeCursor": "DROP ", | ||
"afterCursor": "", | ||
"containsKeywords": [ | ||
"TABLE" | ||
], | ||
"expectedResult": { | ||
"lowerCase": false | ||
} | ||
}, | ||
{ | ||
"namePrefix": "should suggest tables", | ||
"beforeCursor": "DROP TABLE ", | ||
"afterCursor": "", | ||
"expectedResult": { | ||
"lowerCase": false, | ||
"suggestTables": { | ||
"onlyTables": true | ||
}, | ||
"suggestDatabases": { | ||
"appendDot": true | ||
}, | ||
"suggestKeywords": [ | ||
"IF EXISTS" | ||
] | ||
} | ||
}, | ||
{ | ||
"namePrefix": "should suggest keywords", | ||
"beforeCursor": "DROP TABLE IF ", | ||
"afterCursor": "", | ||
"expectedResult": { | ||
"lowerCase": false, | ||
"suggestKeywords": [ | ||
"EXISTS" | ||
] | ||
} | ||
}, | ||
{ | ||
"namePrefix": "should suggest tables", | ||
"beforeCursor": "DROP TABLE IF EXISTS ", | ||
"afterCursor": "", | ||
"expectedResult": { | ||
"lowerCase": false, | ||
"suggestTables": { | ||
"onlyTables": true | ||
}, | ||
"suggestDatabases": { | ||
"appendDot": true | ||
} | ||
} | ||
}, | ||
{ | ||
"namePrefix": "should suggest tables", | ||
"beforeCursor": "DROP TABLE IF EXISTS foo.", | ||
"afterCursor": "", | ||
"expectedResult": { | ||
"lowerCase": false, | ||
"suggestTables": { | ||
"identifierChain": [ | ||
{ | ||
"name": "foo" | ||
} | ||
], | ||
"onlyTables": true | ||
} | ||
} | ||
}, | ||
{ | ||
"namePrefix": "should suggest keywords", | ||
"beforeCursor": "DROP TABLE ", | ||
"afterCursor": " foo.bar", | ||
"expectedResult": { | ||
"lowerCase": false, | ||
"suggestKeywords": [ | ||
"IF EXISTS" | ||
] | ||
} | ||
} | ||
] |
Oops, something went wrong.