Explorar o código

HUE-9464 [editor] Add Hive parser support for DROP SCHEDULED QUERY

Johan Ahlen %!s(int64=5) %!d(string=hai) anos
pai
achega
8a5731c1ba

+ 36 - 0
desktop/core/src/desktop/js/parse/jison/sql/hive/drop/drop_scheduled_query.jison

@@ -0,0 +1,36 @@
+// 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
+ : DropScheduledQuery
+ ;
+
+DataDefinition_EDIT
+ : DropScheduledQuery_EDIT
+   {
+     if ($1 && $1.suggestKeywords) {
+       parser.suggestKeywords($1.suggestKeywords);
+     }
+   }
+ ;
+
+DropScheduledQuery
+ : 'DROP' 'SCHEDULED' 'QUERY' RegularOrBacktickedIdentifier
+ ;
+
+DropScheduledQuery_EDIT
+ : 'DROP' 'SCHEDULED' 'CURSOR' -> { suggestKeywords: ['QUERY'] }
+ ;

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

@@ -33,6 +33,7 @@
     "drop/drop_index.jison",
     "drop/drop_materialized_view.jison",
     "drop/drop_role.jison",
+    "drop/drop_scheduled_query.jison",
     "drop/drop_table.jison",
     "drop/drop_temporary_function.jison",
     "drop/drop_temporary_macro.jison",
@@ -145,6 +146,7 @@
     "drop/drop_index.jison",
     "drop/drop_materialized_view.jison",
     "drop/drop_role.jison",
+    "drop/drop_scheduled_query.jison",
     "drop/drop_table.jison",
     "drop/drop_temporary_function.jison",
     "drop/drop_temporary_macro.jison",

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/hive/hiveAutocompleteParser.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/hive/hiveSyntaxParser.js


+ 1 - 1
desktop/core/src/desktop/js/parse/sql/hive/keywords.json

@@ -1,7 +1,7 @@
 {
   "ALTER": ["DATABASE", "INDEX", "MATERIALIZED VIEW", "SCHEDULED QUERY", "SCHEMA", "TABLE", "VIEW"],
   "ALTER TABLE ADD CONSTRAINT identifier": ["CHECK", "FOREIGN KEY", "PRIMARY KEY", "UNIQUE"],
-  "DROP": ["DATABASE", "FUNCTION", "INDEX", "MATERIALIZED VIEW", "ROLE", "SCHEMA", "TABLE", "TEMPORARY FUNCTION", "TEMPORARY MACRO", "VIEW"],
+  "DROP": ["DATABASE", "FUNCTION", "INDEX", "MATERIALIZED VIEW", "ROLE", "SCHEDULED QUERY", "SCHEMA", "TABLE", "TEMPORARY FUNCTION", "TEMPORARY MACRO", "VIEW"],
   "SHOW": [
     "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"]
 }

+ 71 - 0
desktop/core/src/desktop/js/parse/sql/hive/test/drop/dropScheduledQuery.test.js

@@ -0,0 +1,71 @@
+// 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.
+
+import hiveAutocompleteParser from '../../hiveAutocompleteParser';
+
+describe('hiveAutocompleteParser.js DROP SCHEDULED QUERY statements', () => {
+  beforeAll(() => {
+    hiveAutocompleteParser.yy.parseError = function (msg) {
+      throw Error(msg);
+    };
+  });
+
+  const assertAutoComplete = testDefinition => {
+    const debug = false;
+
+    expect(
+      hiveAutocompleteParser.parseSql(
+        testDefinition.beforeCursor,
+        testDefinition.afterCursor,
+        debug
+      )
+    ).toEqualDefinition(testDefinition);
+  };
+
+  it('should handle "DROP SCHEDULED QUERY foo; |"', () => {
+    assertAutoComplete({
+      beforeCursor: 'DROP SCHEDULED QUERY foo;  ',
+      afterCursor: '',
+      noErrors: true,
+      containsKeywords: ['SELECT'],
+      expectedResult: {
+        lowerCase: false
+      }
+    });
+  });
+
+  it('should suggest keywords for "DROP |"', () => {
+    assertAutoComplete({
+      beforeCursor: 'DROP ',
+      afterCursor: '',
+      containsKeywords: ['SCHEDULED QUERY'],
+      expectedResult: {
+        lowerCase: false
+      }
+    });
+  });
+
+  it('should suggest keywords for "DROP SCHEDULED |"', () => {
+    assertAutoComplete({
+      beforeCursor: 'DROP SCHEDULED ',
+      afterCursor: '',
+      expectedResult: {
+        lowerCase: false,
+        suggestKeywords: ['QUERY']
+      }
+    });
+  });
+});

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

@@ -46,6 +46,7 @@ describe('hiveAutocompleteParser.js DROP statements', () => {
           'INDEX',
           'MATERIALIZED VIEW',
           'ROLE',
+          'SCHEDULED QUERY',
           'SCHEMA',
           'TABLE',
           'TEMPORARY FUNCTION',

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio