Browse Source

[editor] Extract Hive ROW FORMAT and CLUSTERED BY clauses into separate grammar files

Johan Åhlén 3 years ago
parent
commit
f443ab3e54

File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/hive/hiveAutocompleteParser.js


File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/hive/hiveSyntaxParser.js


+ 96 - 0
desktop/core/src/desktop/js/parse/sql/hive/jison/create/clustered_by.jison

@@ -0,0 +1,96 @@
+// 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.
+
+OptionalClusteredBy
+ :
+ | ClusteredBy
+ ;
+
+ClusteredBy
+ : 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalSortedBy 'INTO' 'UNSIGNED_INTEGER' 'BUCKETS'
+ ;
+
+ClusteredBy_EDIT
+ : 'CLUSTERED' 'CURSOR'
+   {
+     parser.suggestKeywords(['BY']);
+   }
+ | 'CLUSTERED' 'BY' ParenthesizedColumnList_EDIT OptionalSortedBy
+ | 'CLUSTERED' 'BY' ParenthesizedColumnList_EDIT OptionalSortedBy 'INTO' 'UNSIGNED_INTEGER' 'BUCKETS'
+ | 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalSortedBy 'CURSOR'
+   {
+     if (!$4) {
+       parser.suggestKeywords([{ value: 'INTO', weight: 1 }, { value: 'SORTED BY', weight: 2 }]);
+     } else {
+       parser.suggestKeywords(['INTO']);
+     }
+   }
+ | 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalSortedBy 'INTO' 'UNSIGNED_INTEGER' 'CURSOR'
+   {
+     parser.suggestKeywords(['BUCKETS']);
+   }
+ | 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalSortedBy_EDIT 'INTO' 'UNSIGNED_INTEGER' 'BUCKETS'
+ | 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalSortedBy_EDIT
+ ;
+
+OptionalSortedBy
+ :
+ | 'SORTED' 'BY' ParenthesizedSortList
+ ;
+
+OptionalSortedBy_EDIT
+ : 'SORTED' 'CURSOR'
+   {
+     parser.suggestKeywords(['BY']);
+   }
+ | 'SORTED' 'BY' ParenthesizedSortList_EDIT
+ ;
+
+ParenthesizedSortList
+ : '(' SortList ')'
+ ;
+
+ParenthesizedSortList_EDIT
+ : '(' SortList_EDIT RightParenthesisOrError
+ ;
+
+SortList
+ : SortIdentifier
+ | SortList ',' SortIdentifier
+ ;
+
+SortList_EDIT
+ : SortIdentifier_EDIT
+ | SortIdentifier_EDIT ',' SortList
+ | SortList ',' SortIdentifier_EDIT
+ | SortList ',' SortIdentifier_EDIT ',' SortList
+ ;
+
+SortIdentifier
+ : ColumnIdentifier OptionalAscOrDesc
+ ;
+
+SortIdentifier_EDIT
+ : ColumnIdentifier OptionalAscOrDesc 'CURSOR'
+   {
+     parser.checkForKeywords($2);
+   }
+ | ColumnIdentifier_EDIT OptionalAscOrDesc
+ | AnyCursor OptionalAscOrDesc
+   {
+     parser.suggestColumns();
+   }
+ ;

+ 0 - 254
desktop/core/src/desktop/js/parse/sql/hive/jison/create/create_common.jison

@@ -428,82 +428,6 @@ PrimaryKey_EDIT
    }
  ;
 
-ClusteredBy
- : 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalSortedBy 'INTO' 'UNSIGNED_INTEGER' 'BUCKETS'
- ;
-
-ClusteredBy_EDIT
- : 'CLUSTERED' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-   }
- | 'CLUSTERED' 'BY' ParenthesizedColumnList_EDIT OptionalSortedBy
- | 'CLUSTERED' 'BY' ParenthesizedColumnList_EDIT OptionalSortedBy 'INTO' 'UNSIGNED_INTEGER' 'BUCKETS'
- | 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalSortedBy 'CURSOR'
-   {
-     if (!$4) {
-       parser.suggestKeywords([{ value: 'INTO', weight: 1 }, { value: 'SORTED BY', weight: 2 }]);
-     } else {
-       parser.suggestKeywords(['INTO']);
-     }
-   }
- | 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalSortedBy 'INTO' 'UNSIGNED_INTEGER' 'CURSOR'
-   {
-     parser.suggestKeywords(['BUCKETS']);
-   }
- | 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalSortedBy_EDIT 'INTO' 'UNSIGNED_INTEGER' 'BUCKETS'
- | 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalSortedBy_EDIT
- ;
-
-OptionalSortedBy
- :
- | 'SORTED' 'BY' ParenthesizedSortList
- ;
-
-OptionalSortedBy_EDIT
- : 'SORTED' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-   }
- | 'SORTED' 'BY' ParenthesizedSortList_EDIT
- ;
-
-ParenthesizedSortList
- : '(' SortList ')'
- ;
-
-ParenthesizedSortList_EDIT
- : '(' SortList_EDIT RightParenthesisOrError
- ;
-
-SortList
- : SortIdentifier
- | SortList ',' SortIdentifier
- ;
-
-SortList_EDIT
- : SortIdentifier_EDIT
- | SortIdentifier_EDIT ',' SortList
- | SortList ',' SortIdentifier_EDIT
- | SortList ',' SortIdentifier_EDIT ',' SortList
- ;
-
-SortIdentifier
- : ColumnIdentifier OptionalAscOrDesc
- ;
-
-SortIdentifier_EDIT
- : ColumnIdentifier OptionalAscOrDesc 'CURSOR'
-   {
-     parser.checkForKeywords($2);
-   }
- | ColumnIdentifier_EDIT OptionalAscOrDesc
- | AnyCursor OptionalAscOrDesc
-   {
-     parser.suggestColumns();
-   }
- ;
-
 ParenthesizedSkewedValueList
  : '(' SkewedValueList ')'
  ;
@@ -513,30 +437,6 @@ SkewedValueList
  | SkewedValueList ',' ParenthesizedSimpleValueList
  ;
 
-OptionalRowFormat
- :
- | RowFormat
- ;
-
-RowFormat
- : 'ROW' 'FORMAT' RowFormatSpec
-   {
-     $$ = $3
-   }
- ;
-
-RowFormat_EDIT
- : 'ROW' 'CURSOR'
-   {
-     parser.suggestKeywords(['FORMAT']);
-   }
- | 'ROW' 'FORMAT' 'CURSOR'
-   {
-     parser.suggestKeywords(['DELIMITED', 'SERDE']);
-   }
- | 'ROW' 'FORMAT' RowFormatSpec_EDIT
- ;
-
 OptionalStoredAsOrBy
  :
  | StoredAsOrBy
@@ -612,160 +512,6 @@ FileFormat
  | 'TEXTFILE'
  ;
 
-RowFormatSpec
- : DelimitedRowFormat
- | 'SERDE' QuotedValue
- ;
-
-RowFormatSpec_EDIT
- : DelimitedRowFormat_EDIT
- ;
-
-DelimitedRowFormat
- : 'DELIMITED' OptionalFieldsTerminatedBy OptionalCollectionItemsTerminatedBy OptionalMapKeysTerminatedBy OptionalLinesTerminatedBy OptionalNullDefinedAs
-   {
-     if (!$2 && !$3 && !$4 && !$5 && !$6) {
-       $$ = { suggestKeywords: [{ value: 'FIELDS TERMINATED BY', weight: 5 }, { value: 'COLLECTION ITEMS TERMINATED BY', weight: 4 }, { value: 'MAP KEYS TERMINATED BY', weight: 3 }, { value: 'LINES TERMINATED BY', weight: 2 }, { value: 'NULL DEFINED AS', weight: 1 }]};
-     } else if ($2 && $2.suggestKeywords && !$3 && !$4 && !$5 && !$6) {
-       $$ = { suggestKeywords: parser.createWeightedKeywords($2.suggestKeywords, 5).concat([{ value: 'COLLECTION ITEMS TERMINATED BY', weight: 4 }, { value: 'MAP KEYS TERMINATED BY', weight: 3 }, { value: 'LINES TERMINATED BY', weight: 2 }, { value: 'NULL DEFINED AS', weight: 1 }]) };
-     } else if (!$3 && !$4 && !$5 && !$6) {
-       $$ = { suggestKeywords: [{ value: 'COLLECTION ITEMS TERMINATED BY', weight: 4 }, { value: 'MAP KEYS TERMINATED BY', weight: 3 }, { value: 'LINES TERMINATED BY', weight: 2 }, { value: 'NULL DEFINED AS', weight: 1 }] };
-     } else if (!$4 && !$5 && !$6) {
-       $$ = { suggestKeywords: [{ value: 'MAP KEYS TERMINATED BY', weight: 3 }, { value: 'LINES TERMINATED BY', weight: 2 }, { value: 'NULL DEFINED AS', weight: 1 }] };
-     } else if (!$5 && !$6) {
-       $$ = { suggestKeywords: [{ value: 'LINES TERMINATED BY', weight: 2 }, { value: 'NULL DEFINED AS', weight: 1 }] };
-     } else if (!$6) {
-       $$ = { suggestKeywords: [{ value: 'NULL DEFINED AS', weight: 1 }] };
-     }
-   }
- ;
-
-DelimitedRowFormat_EDIT
- : 'DELIMITED' OptionalFieldsTerminatedBy_EDIT OptionalCollectionItemsTerminatedBy OptionalMapKeysTerminatedBy
-   OptionalLinesTerminatedBy OptionalNullDefinedAs
- | 'DELIMITED' OptionalFieldsTerminatedBy OptionalCollectionItemsTerminatedBy_EDIT OptionalMapKeysTerminatedBy
-   OptionalLinesTerminatedBy OptionalNullDefinedAs
- | 'DELIMITED' OptionalFieldsTerminatedBy OptionalCollectionItemsTerminatedBy OptionalMapKeysTerminatedBy_EDIT
-   OptionalLinesTerminatedBy OptionalNullDefinedAs
- | 'DELIMITED' OptionalFieldsTerminatedBy OptionalCollectionItemsTerminatedBy OptionalMapKeysTerminatedBy
-   OptionalLinesTerminatedBy_EDIT OptionalNullDefinedAs
- | 'DELIMITED' OptionalFieldsTerminatedBy OptionalCollectionItemsTerminatedBy OptionalMapKeysTerminatedBy
-   OptionalLinesTerminatedBy OptionalNullDefinedAs_EDIT
- ;
-
-OptionalFieldsTerminatedBy
- :
- | 'FIELDS' 'TERMINATED' 'BY' SingleQuotedValue  -> { suggestKeywords: ['ESCAPED BY'] }
- | 'FIELDS' 'TERMINATED' 'BY' SingleQuotedValue 'ESCAPED' 'BY' SingleQuotedValue
- ;
-
-OptionalFieldsTerminatedBy_EDIT
- : 'FIELDS' 'CURSOR'
-   {
-     parser.suggestKeywords(['TERMINATED BY']);
-   }
- | 'FIELDS' 'TERMINATED' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-   }
- | 'FIELDS' 'TERMINATED' 'BY' SingleQuotedValue 'ESCAPED' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-   }
- ;
-
-OptionalCollectionItemsTerminatedBy
- :
- | 'COLLECTION' 'ITEMS' 'TERMINATED' 'BY' SingleQuotedValue
- ;
-
-OptionalCollectionItemsTerminatedBy_EDIT
- : 'COLLECTION' 'CURSOR'
-   {
-     parser.suggestKeywords(['ITEMS TERMINATED BY']);
-   }
- | 'COLLECTION' 'ITEMS' 'CURSOR'
-   {
-     parser.suggestKeywords(['TERMINATED BY']);
-   }
- | 'COLLECTION' 'ITEMS' 'TERMINATED' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-   }
- ;
-
-OptionalMapKeysTerminatedBy
- :
- | 'MAP' 'KEYS' 'TERMINATED' 'BY' SingleQuotedValue
- ;
-
-OptionalMapKeysTerminatedBy_EDIT
- : 'MAP' 'CURSOR'
-   {
-     parser.suggestKeywords(['KEYS TERMINATED BY']);
-   }
- | 'MAP' 'KEYS' 'CURSOR'
-   {
-     parser.suggestKeywords(['TERMINATED BY']);
-   }
- | 'MAP' 'KEYS' 'TERMINATED' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-   }
- ;
-
-OptionalLinesTerminatedBy
- :
- | 'LINES' 'TERMINATED' 'BY' SingleQuotedValue
- ;
-
-OptionalLinesTerminatedBy_EDIT
- : 'LINES' 'CURSOR'
-   {
-     parser.suggestKeywords(['TERMINATED BY']);
-   }
- | 'LINES' 'TERMINATED' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-   }
- ;
-
-OptionalNullDefinedAs
- :
- | 'NULL' 'DEFINED' 'AS' SingleQuotedValue
- ;
-
-OptionalNullDefinedAs_EDIT
- : 'NULL' 'CURSOR'
-   {
-     parser.suggestKeywords(['DEFINED AS']);
-   }
- | 'NULL' 'DEFINED' 'CURSOR'
-   {
-     parser.suggestKeywords(['AS']);
-   }
- ;
-
-OptionalWithSerdeproperties
- :
- | WithSerdeproperties
- ;
-
-WithSerdeproperties
- :'WITH' 'SERDEPROPERTIES' ParenthesizedPropertyAssignmentList
- ;
-
-WithSerdeproperties_EDIT
- : 'WITH' 'CURSOR'
-   {
-     parser.suggestKeywords(['SERDEPROPERTIES']);
-   }
- | 'WITH' 'CURSOR' ParenthesizedPropertyAssignmentList
-   {
-     parser.suggestKeywords(['SERDEPROPERTIES']);
-   }
- ;
-
 OptionalTblproperties
  :
  | TblProperties

+ 0 - 5
desktop/core/src/desktop/js/parse/sql/hive/jison/create/create_table.jison

@@ -216,11 +216,6 @@ SpecList_EDIT
    }
  ;
 
-OptionalClusteredBy
- :
- | ClusteredBy
- ;
-
 OptionalSkewedBy
  :
  | SkewedBy

+ 194 - 0
desktop/core/src/desktop/js/parse/sql/hive/jison/create/row_format.jison

@@ -0,0 +1,194 @@
+// 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.
+
+OptionalRowFormat
+ :
+ | RowFormat
+ ;
+
+RowFormat
+ : 'ROW' 'FORMAT' RowFormatSpec
+   {
+     $$ = $3
+   }
+ ;
+
+RowFormat_EDIT
+ : 'ROW' 'CURSOR'
+   {
+     parser.suggestKeywords(['FORMAT']);
+   }
+ | 'ROW' 'FORMAT' 'CURSOR'
+   {
+     parser.suggestKeywords(['DELIMITED', 'SERDE']);
+   }
+ | 'ROW' 'FORMAT' RowFormatSpec_EDIT
+ ;
+
+
+RowFormatSpec
+ : DelimitedRowFormat
+ | 'SERDE' QuotedValue
+ ;
+
+RowFormatSpec_EDIT
+ : DelimitedRowFormat_EDIT
+ ;
+
+DelimitedRowFormat
+ : 'DELIMITED' OptionalFieldsTerminatedBy OptionalCollectionItemsTerminatedBy OptionalMapKeysTerminatedBy OptionalLinesTerminatedBy OptionalNullDefinedAs
+   {
+     if (!$2 && !$3 && !$4 && !$5 && !$6) {
+       $$ = { suggestKeywords: [{ value: 'FIELDS TERMINATED BY', weight: 5 }, { value: 'COLLECTION ITEMS TERMINATED BY', weight: 4 }, { value: 'MAP KEYS TERMINATED BY', weight: 3 }, { value: 'LINES TERMINATED BY', weight: 2 }, { value: 'NULL DEFINED AS', weight: 1 }]};
+     } else if ($2 && $2.suggestKeywords && !$3 && !$4 && !$5 && !$6) {
+       $$ = { suggestKeywords: parser.createWeightedKeywords($2.suggestKeywords, 5).concat([{ value: 'COLLECTION ITEMS TERMINATED BY', weight: 4 }, { value: 'MAP KEYS TERMINATED BY', weight: 3 }, { value: 'LINES TERMINATED BY', weight: 2 }, { value: 'NULL DEFINED AS', weight: 1 }]) };
+     } else if (!$3 && !$4 && !$5 && !$6) {
+       $$ = { suggestKeywords: [{ value: 'COLLECTION ITEMS TERMINATED BY', weight: 4 }, { value: 'MAP KEYS TERMINATED BY', weight: 3 }, { value: 'LINES TERMINATED BY', weight: 2 }, { value: 'NULL DEFINED AS', weight: 1 }] };
+     } else if (!$4 && !$5 && !$6) {
+       $$ = { suggestKeywords: [{ value: 'MAP KEYS TERMINATED BY', weight: 3 }, { value: 'LINES TERMINATED BY', weight: 2 }, { value: 'NULL DEFINED AS', weight: 1 }] };
+     } else if (!$5 && !$6) {
+       $$ = { suggestKeywords: [{ value: 'LINES TERMINATED BY', weight: 2 }, { value: 'NULL DEFINED AS', weight: 1 }] };
+     } else if (!$6) {
+       $$ = { suggestKeywords: [{ value: 'NULL DEFINED AS', weight: 1 }] };
+     }
+   }
+ ;
+
+DelimitedRowFormat_EDIT
+ : 'DELIMITED' OptionalFieldsTerminatedBy_EDIT OptionalCollectionItemsTerminatedBy OptionalMapKeysTerminatedBy
+   OptionalLinesTerminatedBy OptionalNullDefinedAs
+ | 'DELIMITED' OptionalFieldsTerminatedBy OptionalCollectionItemsTerminatedBy_EDIT OptionalMapKeysTerminatedBy
+   OptionalLinesTerminatedBy OptionalNullDefinedAs
+ | 'DELIMITED' OptionalFieldsTerminatedBy OptionalCollectionItemsTerminatedBy OptionalMapKeysTerminatedBy_EDIT
+   OptionalLinesTerminatedBy OptionalNullDefinedAs
+ | 'DELIMITED' OptionalFieldsTerminatedBy OptionalCollectionItemsTerminatedBy OptionalMapKeysTerminatedBy
+   OptionalLinesTerminatedBy_EDIT OptionalNullDefinedAs
+ | 'DELIMITED' OptionalFieldsTerminatedBy OptionalCollectionItemsTerminatedBy OptionalMapKeysTerminatedBy
+   OptionalLinesTerminatedBy OptionalNullDefinedAs_EDIT
+ ;
+
+OptionalFieldsTerminatedBy
+ :
+ | 'FIELDS' 'TERMINATED' 'BY' SingleQuotedValue  -> { suggestKeywords: ['ESCAPED BY'] }
+ | 'FIELDS' 'TERMINATED' 'BY' SingleQuotedValue 'ESCAPED' 'BY' SingleQuotedValue
+ ;
+
+OptionalFieldsTerminatedBy_EDIT
+ : 'FIELDS' 'CURSOR'
+   {
+     parser.suggestKeywords(['TERMINATED BY']);
+   }
+ | 'FIELDS' 'TERMINATED' 'CURSOR'
+   {
+     parser.suggestKeywords(['BY']);
+   }
+ | 'FIELDS' 'TERMINATED' 'BY' SingleQuotedValue 'ESCAPED' 'CURSOR'
+   {
+     parser.suggestKeywords(['BY']);
+   }
+ ;
+
+OptionalCollectionItemsTerminatedBy
+ :
+ | 'COLLECTION' 'ITEMS' 'TERMINATED' 'BY' SingleQuotedValue
+ ;
+
+OptionalCollectionItemsTerminatedBy_EDIT
+ : 'COLLECTION' 'CURSOR'
+   {
+     parser.suggestKeywords(['ITEMS TERMINATED BY']);
+   }
+ | 'COLLECTION' 'ITEMS' 'CURSOR'
+   {
+     parser.suggestKeywords(['TERMINATED BY']);
+   }
+ | 'COLLECTION' 'ITEMS' 'TERMINATED' 'CURSOR'
+   {
+     parser.suggestKeywords(['BY']);
+   }
+ ;
+
+OptionalMapKeysTerminatedBy
+ :
+ | 'MAP' 'KEYS' 'TERMINATED' 'BY' SingleQuotedValue
+ ;
+
+OptionalMapKeysTerminatedBy_EDIT
+ : 'MAP' 'CURSOR'
+   {
+     parser.suggestKeywords(['KEYS TERMINATED BY']);
+   }
+ | 'MAP' 'KEYS' 'CURSOR'
+   {
+     parser.suggestKeywords(['TERMINATED BY']);
+   }
+ | 'MAP' 'KEYS' 'TERMINATED' 'CURSOR'
+   {
+     parser.suggestKeywords(['BY']);
+   }
+ ;
+
+OptionalLinesTerminatedBy
+ :
+ | 'LINES' 'TERMINATED' 'BY' SingleQuotedValue
+ ;
+
+OptionalLinesTerminatedBy_EDIT
+ : 'LINES' 'CURSOR'
+   {
+     parser.suggestKeywords(['TERMINATED BY']);
+   }
+ | 'LINES' 'TERMINATED' 'CURSOR'
+   {
+     parser.suggestKeywords(['BY']);
+   }
+ ;
+
+OptionalNullDefinedAs
+ :
+ | 'NULL' 'DEFINED' 'AS' SingleQuotedValue
+ ;
+
+OptionalNullDefinedAs_EDIT
+ : 'NULL' 'CURSOR'
+   {
+     parser.suggestKeywords(['DEFINED AS']);
+   }
+ | 'NULL' 'DEFINED' 'CURSOR'
+   {
+     parser.suggestKeywords(['AS']);
+   }
+ ;
+
+OptionalWithSerdeproperties
+ :
+ | WithSerdeproperties
+ ;
+
+WithSerdeproperties
+ : 'WITH' 'SERDEPROPERTIES' ParenthesizedPropertyAssignmentList
+ ;
+
+WithSerdeproperties_EDIT
+ : 'WITH' 'CURSOR'
+   {
+     parser.suggestKeywords(['SERDEPROPERTIES']);
+   }
+ | 'WITH' 'CURSOR' ParenthesizedPropertyAssignmentList
+   {
+     parser.suggestKeywords(['SERDEPROPERTIES']);
+   }
+ ;

+ 52 - 0
desktop/core/src/desktop/js/parse/sql/hive/jison/create/row_format.test.json

@@ -0,0 +1,52 @@
+[
+  {
+    "namePrefix": "should not report errors",
+    "beforeCursor": "CREATE TABLE foo (id int) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' ESCAPED BY 'q'; ",
+    "afterCursor": "",
+    "noErrors": true,
+    "containsKeywords": [
+      "SELECT"
+    ],
+    "expectedResult": {
+      "lowerCase": false
+    }
+  },
+  {
+    "namePrefix": "should suggest keywords",
+    "beforeCursor": "CREATE TABLE foo (id int) ROW FORMAT ",
+    "afterCursor": "",
+    "containsKeywords": [
+      "DELIMITED",
+      "SERDE"
+    ],
+    "expectedResult": {
+      "lowerCase": false
+    }
+  },
+  {
+    "namePrefix": "should suggest keywords",
+    "beforeCursor": "CREATE TABLE foo (id int) ROW FORMAT DELIMITED ",
+    "afterCursor": "",
+    "containsKeywords": [
+      "FIELDS TERMINATED BY",
+      "COLLECTION ITEMS TERMINATED BY",
+      "MAP KEYS TERMINATED BY",
+      "LINES TERMINATED BY",
+      "NULL DEFINED AS"
+    ],
+    "expectedResult": {
+      "lowerCase": false
+    }
+  },
+  {
+    "namePrefix": "should suggest keywords",
+    "beforeCursor": "CREATE TABLE foo (id int) ROW FORMAT DELIMITED MAP ",
+    "afterCursor": "",
+    "containsKeywords": [
+      "KEYS TERMINATED BY"
+    ],
+    "expectedResult": {
+      "lowerCase": false
+    }
+  }
+]

+ 4 - 0
desktop/core/src/desktop/js/parse/sql/hive/jison/structure.json

@@ -13,6 +13,7 @@
     "alter/alter_table.jison",
     "alter/alter_view.jison",
     "analyze/analyze_table.jison",
+    "create/clustered_by.jison",
     "create/create_common.jison",
     "create/create_connector.jison",
     "create/create_database.jison",
@@ -25,6 +26,7 @@
     "create/create_temporary_function.jison",
     "create/create_temporary_macro.jison",
     "create/create_view.jison",
+    "create/row_format.jison",
     "delete/delete.jison",
     "describe/describe.jison",
     "describe/describe_connector.jison",
@@ -130,6 +132,7 @@
     "alter/alter_table.jison",
     "alter/alter_view.jison",
     "analyze/analyze_table.jison",
+    "create/clustered_by.jison",
     "create/create_common.jison",
     "create/create_connector.jison",
     "create/create_database.jison",
@@ -142,6 +145,7 @@
     "create/create_temporary_function.jison",
     "create/create_temporary_macro.jison",
     "create/create_view.jison",
+    "create/row_format.jison",
     "delete/delete.jison",
     "describe/describe.jison",
     "describe/describe_connector.jison",

+ 2 - 47
desktop/core/src/desktop/js/parse/sql/hive/test/hiveAutocompleteParser.Create.test.js

@@ -1584,58 +1584,13 @@ describe('hiveAutocompleteParser.js CREATE statements', () => {
       });
     });
 
-    it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT |"', () => {
-      assertAutoComplete({
-        beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT ',
-        afterCursor: '',
-        expectedResult: {
-          lowerCase: false,
-          suggestKeywords: ['DELIMITED', 'SERDE']
-        }
-      });
-    });
-
     it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT DELIMITED |"', () => {
       assertAutoComplete({
         beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT DELIMITED ',
         afterCursor: '',
+        containsKeywords: ['STORED AS', 'STORED BY', 'LOCATION', 'TBLPROPERTIES', 'AS'],
         expectedResult: {
-          lowerCase: false,
-          suggestKeywords: [
-            'FIELDS TERMINATED BY',
-            'COLLECTION ITEMS TERMINATED BY',
-            'MAP KEYS TERMINATED BY',
-            'LINES TERMINATED BY',
-            'NULL DEFINED AS',
-            'STORED AS',
-            'STORED BY',
-            'LOCATION',
-            'TBLPROPERTIES',
-            'AS'
-          ]
-        }
-      });
-    });
-
-    it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT DELIMITED MAP |"', () => {
-      assertAutoComplete({
-        beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT DELIMITED MAP ',
-        afterCursor: '',
-        expectedResult: {
-          lowerCase: false,
-          suggestKeywords: ['KEYS TERMINATED BY']
-        }
-      });
-    });
-
-    it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT DELIMITED MAP KEYS TERMINATED BY \'a\' NULL DEFINED |"', () => {
-      assertAutoComplete({
-        beforeCursor:
-          "CREATE TABLE foo (id int) ROW FORMAT DELIMITED MAP KEYS TERMINATED BY 'a' NULL DEFINED ",
-        afterCursor: '',
-        expectedResult: {
-          lowerCase: false,
-          suggestKeywords: ['AS']
+          lowerCase: false
         }
       });
     });

+ 8 - 0
desktop/core/src/desktop/js/parse/sql/hive/test/hiveAutocompleteParser.test.js

@@ -16,7 +16,15 @@
 
 import { assertPartials } from 'parse/sql/sharedParserTests';
 import hiveAutocompleteParser from '../hiveAutocompleteParser';
+import { extractTestCases, runTestCases } from '../../testUtils';
+import structure from '../../hive/jison/structure.json';
+
+const jisonFolder = 'desktop/core/src/desktop/js/parse/sql/hive/jison';
+const groupedTestCases = extractTestCases(jisonFolder, structure.autocomplete);
+
 describe('hiveAutocompleteParser.js', () => {
+  runTestCases(hiveAutocompleteParser, groupedTestCases);
+
   beforeAll(() => {
     hiveAutocompleteParser.yy.parseError = function (msg) {
       throw Error(msg);

+ 2 - 0
desktop/core/src/desktop/js/parse/sql/presto/jison/structure.json

@@ -12,6 +12,7 @@
     "../../hive/jison/alter/alter_view.jison",
     "../../hive/jison/analyze/analyze_table.jison",
     "create/create_common.jison",
+    "../../hive/jison/create/clustered_by.jison",
     "../../hive/jison/create/create_database.jison",
     "create/create_database_no_db.jison",
     "../../hive/jison/create/create_function.jison",
@@ -21,6 +22,7 @@
     "../../hive/jison/create/create_temporary_function.jison",
     "../../hive/jison/create/create_temporary_macro.jison",
     "../../hive/jison/create/create_view.jison",
+    "../../hive/jison/create/row_format.jison",
     "../../hive/jison/delete/delete.jison",
     "../../hive/jison/describe/describe.jison",
     "../../hive/jison/describe/describe_database.jison",

File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/presto/prestoAutocompleteParser.js


File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/presto/prestoSyntaxParser.js


Some files were not shown because too many files changed in this diff