Prechádzať zdrojové kódy

HUE-5728 [editor] Update the autocompleter for Impala DESCRIBE statements

Johan Ahlen 8 rokov pred
rodič
commit
e3ae944106

+ 3 - 2
desktop/core/src/desktop/static/desktop/js/aceSqlWorker.js

@@ -14,8 +14,9 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-importScripts('/static/desktop/js/autocomplete/sql.js?version=10');
-importScripts('/static/desktop/js/sqlFunctions.js?version=10');
+var version = 11;
+importScripts('/static/desktop/js/autocomplete/sql.js?version=' + version);
+importScripts('/static/desktop/js/sqlFunctions.js?version=' + version);
 
 (function () {
 

+ 1 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql.jisonlex

@@ -200,6 +200,7 @@
 <impala>'ESCAPED'                          { return '<impala>ESCAPED'; }
 <impala>'EXPLAIN'                          { determineCase(yytext); return '<impala>EXPLAIN'; }
 <impala>'EXTERNAL'                         { return '<impala>EXTERNAL'; }
+<impala>'EXTENDED'                         { return '<impala>EXTENDED'; }
 <impala>'FIELDS'                           { return '<impala>FIELDS'; }
 <impala>'FILEFORMAT'                       { return '<impala>FILEFORMAT'; }
 <impala>'FINALIZE_FN'                      { return '<impala>FINALIZE_FN'; }

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_main.jison


+ 4 - 4
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_valueExpression_dev.jison

@@ -398,12 +398,12 @@ OptionalAggregateOrAnalytic
  | AggregateOrAnalytic
  ;
 
-OptionalExtended
+OptionalHiveExtended
  :
  | '<hive>EXTENDED'
  ;
 
-OptionalExtendedOrFormatted
+OptionalHiveExtendedOrFormatted
  :
  | '<hive>EXTENDED'
  | '<hive>FORMATTED'
@@ -415,8 +415,9 @@ OptionalExternal
  | '<impala>EXTERNAL'
  ;
 
-OptionalFormatted
+OptionalImpalaExtendedOrFormatted
  :
+ | '<impala>EXTENDED'
  | '<impala>FORMATTED'
  ;
 
@@ -687,7 +688,6 @@ DatabaseIdentifier_EDIT
  : PartialBacktickedOrCursor
    {
      suggestDatabases();
-     $$ = { cursorOrPartialIdentifier: true };
    }
  ;
 

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/sql.js


+ 0 - 549
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecDescribe.js

@@ -1,549 +0,0 @@
-// 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.
-
-(function () {
-  describe('sql.js DESCRIBE statements', function() {
-
-    beforeAll(function () {
-      sql.yy.parseError = function (msg) {
-        throw Error(msg);
-      };
-      jasmine.addMatchers(SqlTestUtils.testDefinitionMatcher);
-    });
-
-    var assertAutoComplete = SqlTestUtils.assertAutocomplete;
-
-
-    describe('hive specific', function () {
-      it('should handle "DESCRIBE tbl;|"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE tbl;',
-          afterCursor: '',
-          dialect: 'hive',
-          containsKeywords: ['SELECT'],
-          expectedResult: {
-            lowerCase: false,
-            locations: [
-              {type: 'table', location: { first_line: 1, last_line: 1, first_column: 10, last_column: 13 }, identifierChain: [{ name: 'tbl' }] }
-            ]
-          }
-        });
-      });
-
-      it('should handle "DESCRIBE tbl col.field;|"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE tbl col.field;',
-          afterCursor: '',
-          dialect: 'hive',
-          containsKeywords: ['SELECT'],
-          expectedResult: {
-            lowerCase: false,
-            locations: [
-              {type: 'table', location: { first_line: 1, last_line: 1, first_column: 10, last_column: 13 }, identifierChain: [{ name: 'tbl' }] },
-              {type: 'column', location: { first_line: 1, last_line: 1, first_column: 14, last_column: 23 }, identifierChain: [{ name: 'tbl' }, { name: 'col' }, { name: 'field'}] }
-            ]
-          }
-        });
-      });
-
-      it('should handle "DESCRIBE EXTENDED tbl;|"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE EXTENDED tbl;',
-          afterCursor: '',
-          dialect: 'hive',
-          containsKeywords: ['SELECT'],
-          expectedResult: {
-            lowerCase: false,
-            locations: [
-              {type: 'table', location: { first_line: 1, last_line: 1, first_column: 19, last_column: 22 }, identifierChain: [{ name: 'tbl' }] }
-            ]
-          }
-        });
-      });
-
-      it('should handle "DESCRIBE EXTENDED tbl col.field;|"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE EXTENDED tbl col.field;',
-          afterCursor: '',
-          dialect: 'hive',
-          hasLocations: true,
-          containsKeywords: ['SELECT'],
-          expectedResult: {
-            lowerCase: false
-          }
-        });
-      });
-
-      it('should handle DESCRIBE | tbl;', function () {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE ',
-          afterCursor: ' tbl;',
-          dialect: 'hive',
-          hasLocations: true,
-          containsKeywords: ['EXTENDED', 'FORMATTED'],
-          expectedResult: {
-            lowerCase: false
-          }
-        });
-      });
-
-      it('should handle DESCRIBE ext| db.tbl;', function () {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE ext',
-          afterCursor: ' db.tbl;',
-          dialect: 'hive',
-          hasLocations: true,
-          containsKeywords: ['EXTENDED', 'FORMATTED'],
-          expectedResult: {
-            lowerCase: false
-          }
-        });
-      });
-
-      it('should handle "DESCRIBE FORMATTED tbl;|"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE FORMATTED tbl;',
-          afterCursor: '',
-          dialect: 'hive',
-          hasLocations: true,
-          containsKeywords: ['SELECT'],
-          expectedResult: {
-            lowerCase: false
-          }
-        });
-      });
-
-      it('should handle "DESCRIBE FORMATTED tbl col.field;|"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE FORMATTED tbl col.field;',
-          afterCursor: '',
-          dialect: 'hive',
-          hasLocations: true,
-          containsKeywords: ['SELECT'],
-          expectedResult: {
-            lowerCase: false
-          }
-        });
-      });
-
-      it('should handle "DESCRIBE FUNCTION cos;|"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE FUNCTION cos;',
-          afterCursor: '',
-          dialect: 'hive',
-          containsKeywords: ['SELECT'],
-          expectedResult: {
-            lowerCase: false
-          }
-        });
-      });
-
-      it('should handle "DESCRIBE FUNCTION EXTENDED cos;|"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE FUNCTION EXTENDED cos;',
-          afterCursor: '',
-          dialect: 'hive',
-          containsKeywords: ['SELECT'],
-          expectedResult: {
-            lowerCase: false
-          }
-        });
-      });
-
-      it('should handle "DESCRIBE DATABASE db;|"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE DATABASE db;',
-          afterCursor: '',
-          dialect: 'hive',
-          hasLocations: true,
-          containsKeywords: ['SELECT'],
-          expectedResult: {
-            lowerCase: false
-          }
-        });
-      });
-
-      it('should handle "DESCRIBE DATABASE EXTENDED db;|"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE DATABASE EXTENDED db;',
-          afterCursor: '',
-          dialect: 'hive',
-          hasLocations: true,
-          containsKeywords: ['SELECT'],
-          expectedResult: {
-            lowerCase: false
-          }
-        });
-      });
-
-      it('should handle "DESCRIBE SCHEMA db;|"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE SCHEMA db;',
-          afterCursor: '',
-          dialect: 'hive',
-          hasLocations: true,
-          containsKeywords: ['SELECT'],
-          expectedResult: {
-            lowerCase: false
-          }
-        });
-      });
-
-      it('should handle "DESCRIBE SCHEMA EXTENDED db;|"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE SCHEMA EXTENDED db;',
-          afterCursor: '',
-          dialect: 'hive',
-          hasLocations: true,
-          containsKeywords: ['SELECT'],
-          expectedResult: {
-            lowerCase: false
-          }
-        });
-      });
-
-      it('should suggest tables for "DESCRIBE |"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE ',
-          afterCursor: '',
-          dialect: 'hive',
-          expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['DATABASE', 'EXTENDED', 'FORMATTED', 'FUNCTION', 'SCHEMA'],
-            suggestTables: {},
-            suggestDatabases: { appendDot: true }
-          }
-        });
-      });
-
-      it('should suggest tables for "DESCRIBE tbl|"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE tbl',
-          afterCursor: '',
-          dialect: 'hive',
-          expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['DATABASE', 'EXTENDED', 'FORMATTED', 'FUNCTION', 'SCHEMA'],
-            suggestTables: {},
-            suggestDatabases: { appendDot: true }
-          }
-        });
-      });
-
-      it('should suggest tables for "DESCRIBE db.|"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE db.',
-          afterCursor: '',
-          dialect: 'hive',
-          expectedResult: {
-            lowerCase: false,
-            suggestTables: { identifierChain: [{ name: 'db' }] }
-          }
-        });
-      });
-
-      it('should suggest columns for "DESCRIBE db.tbl |"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE db.tbl ',
-          afterCursor: '',
-          dialect: 'hive',
-          hasLocations: true,
-          expectedResult: {
-            lowerCase: false,
-            suggestColumns: { tables: [{ identifierChain: [{ name: 'db' }, { name: 'tbl' }] }] }
-          }
-        });
-      });
-
-      it('should suggest keywords for "DESCRIBE FUNCTION |"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE FUNCTION ',
-          afterCursor: '',
-          dialect: 'hive',
-          expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['EXTENDED']
-          }
-        });
-      });
-
-      it('should suggest keywords for "DESCRIBE FUNCTION | cos"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE FUNCTION ',
-          afterCursor: ' cos',
-          dialect: 'hive',
-          expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['EXTENDED']
-          }
-        });
-      });
-
-      it('should suggest databases for "DESCRIBE DATABASE |"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE DATABASE ',
-          afterCursor: '',
-          dialect: 'hive',
-          expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['EXTENDED'],
-            suggestDatabases: {}
-          }
-        });
-      });
-
-      it('should suggest databases for "DESCRIBE DATABASE db|"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE DATABASE db',
-          afterCursor: '',
-          dialect: 'hive',
-          expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['EXTENDED'],
-            suggestDatabases: {}
-          }
-        });
-      });
-
-      it('should suggest databases for "DESCRIBE DATABASE EXTENDED |"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE DATABASE EXTENDED ',
-          afterCursor: '',
-          dialect: 'hive',
-          expectedResult: {
-            lowerCase: false,
-            suggestDatabases: {}
-          }
-        });
-      });
-
-      it('should suggest databases for "DESCRIBE SCHEMA |"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE SCHEMA ',
-          afterCursor: '',
-          dialect: 'hive',
-          expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['EXTENDED'],
-            suggestDatabases: {}
-          }
-        });
-      });
-
-      it('should suggest databases for "DESCRIBE SCHEMA db|"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE SCHEMA db',
-          afterCursor: '',
-          dialect: 'hive',
-          expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['EXTENDED'],
-            suggestDatabases: {}
-          }
-        });
-      });
-
-      it('should suggest databases for "DESCRIBE SCHEMA EXTENDED |"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE SCHEMA EXTENDED ',
-          afterCursor: '',
-          dialect: 'hive',
-          expectedResult: {
-            lowerCase: false,
-            suggestDatabases: {}
-          }
-        });
-      });
-
-      it('should suggest tables for "DESCRIBE EXTENDED |"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE EXTENDED ',
-          afterCursor: '',
-          dialect: 'hive',
-          expectedResult: {
-            lowerCase: false,
-            suggestTables: {},
-            suggestDatabases: { appendDot: true }
-          }
-        });
-      });
-
-      it('should suggest tables for "describe extended db.|"', function() {
-        assertAutoComplete({
-          beforeCursor: 'describe extended db.',
-          afterCursor: '',
-          dialect: 'hive',
-          expectedResult: {
-            lowerCase: true,
-            suggestTables: { identifierChain: [{ name: 'db' }] }
-          }
-        });
-      });
-
-      it('should suggest columns for "DESCRIBE EXTENDED db.tbl |"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE EXTENDED db.tbl ',
-          afterCursor: '',
-          dialect: 'hive',
-          hasLocations: true,
-          expectedResult: {
-            lowerCase: false,
-            suggestColumns: { tables: [{ identifierChain: [{ name: 'db' }, { name: 'tbl' }] }] }
-          }
-        });
-      });
-
-      it('should suggest tables for "DESCRIBE FORMATTED |"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE FORMATTED ',
-          afterCursor: '',
-          dialect: 'hive',
-          expectedResult: {
-            lowerCase: false,
-            suggestTables: {},
-            suggestDatabases: { appendDot: true }
-          }
-        });
-      });
-
-      it('should suggest tables for "DESCRIBE FORMATTED db.|"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE FORMATTED db.',
-          afterCursor: '',
-          dialect: 'hive',
-          expectedResult: {
-            lowerCase: false,
-            suggestTables: {
-              identifierChain: [{ name: 'db' }]
-            }
-          }
-        });
-      });
-
-      it('should suggest columns for "DESCRIBE FORMATTED db.tbl |"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE FORMATTED db.tbl ',
-          afterCursor: '',
-          dialect: 'hive',
-          hasLocations: true,
-          expectedResult: {
-            lowerCase: false,
-            suggestColumns: { tables: [{ identifierChain: [{ name: 'db' }, { name: 'tbl' }] }] }
-          }
-        });
-      });
-
-      it('should suggest fields for "DESCRIBE FORMATTED db.tbl col.|"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE FORMATTED db.tbl col.',
-          afterCursor: '',
-          dialect: 'hive',
-          hasLocations: true,
-          expectedResult: {
-            lowerCase: false,
-            suggestColumns: { tables: [{ identifierChain: [{ name: 'db' }, { name: 'tbl' }, { name: 'col' }] }] }
-          }
-        });
-      });
-    });
-
-    describe('impala specific', function () {
-      it('should handle "DESCRIBE tbl;|"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE tbl;',
-          afterCursor: '',
-          dialect: 'impala',
-          containsKeywords: ['SELECT'],
-          expectedResult: {
-            lowerCase: false,
-            locations: [
-              {type: 'table', location: { first_line: 1, last_line: 1, first_column: 10, last_column: 13}, identifierChain: [{ name: 'tbl' }] }
-            ]
-          }
-        });
-      });
-
-      it('should handle "DESCRIBE db.tbl;|"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE db.tbl;',
-          afterCursor: '',
-          dialect: 'impala',
-          containsKeywords: ['SELECT'],
-          expectedResult: {
-            lowerCase: false,
-            locations: [
-              {type: 'database', location: { first_line: 1, last_line: 1, first_column: 10, last_column: 12 }, identifierChain: [{ name: 'db' }]},
-              {type: 'table', location: { first_line: 1, last_line: 1, first_column: 13, last_column: 16}, identifierChain: [{ name: 'db' }, { name: 'tbl' }] }
-            ]
-          }
-        });
-      });
-
-      it('should handle "DESCRIBE FORMATTED db.tbl;|"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE FORMATTED db.tbl;',
-          afterCursor: '',
-          dialect: 'impala',
-          hasLocations: true,
-          containsKeywords: ['SELECT'],
-          expectedResult: {
-            lowerCase: false
-          }
-        });
-      });
-
-      it('should suggest tables for "DESCRIBE |"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE ',
-          afterCursor: '',
-          dialect: 'impala',
-          expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['FORMATTED'],
-            suggestTables: {},
-            suggestDatabases: { appendDot: true }
-          }
-        });
-      });
-
-      it('should suggest tables for "DESCRIBE db|"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE db',
-          afterCursor: '',
-          dialect: 'impala',
-          expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['FORMATTED'],
-            suggestTables: {},
-            suggestDatabases: { appendDot: true }
-          }
-        });
-      });
-
-      it('should suggest tables for "DESCRIBE db.|"', function() {
-        assertAutoComplete({
-          beforeCursor: 'DESCRIBE db.',
-          afterCursor: '',
-          dialect: 'impala',
-          expectedResult: {
-            lowerCase: false,
-            suggestTables: { identifierChain: [{ name: 'db' }] }
-          }
-        });
-      });
-    });
-  });
-})();

+ 430 - 0
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecDescribe_hive.js

@@ -0,0 +1,430 @@
+// 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.
+
+(function () {
+  describe('sql.js Hive DESCRIBE statements', function() {
+
+    beforeAll(function () {
+      sql.yy.parseError = function (msg) {
+        throw Error(msg);
+      };
+      jasmine.addMatchers(SqlTestUtils.testDefinitionMatcher);
+    });
+
+    var assertAutoComplete = function (spec) {
+      spec.dialect = 'hive';
+      return SqlTestUtils.assertAutocomplete(spec);
+    };
+
+    it('should handle "DESCRIBE tbl;|"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE tbl;',
+        afterCursor: '',
+        containsKeywords: ['SELECT'],
+        expectedResult: {
+          lowerCase: false,
+          locations: [
+            {type: 'table', location: { first_line: 1, last_line: 1, first_column: 10, last_column: 13 }, identifierChain: [{ name: 'tbl' }] }
+          ]
+        }
+      });
+    });
+
+    it('should handle "DESCRIBE tbl col.field;|"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE tbl col.field;',
+        afterCursor: '',
+        containsKeywords: ['SELECT'],
+        expectedResult: {
+          lowerCase: false,
+          locations: [
+            {type: 'table', location: { first_line: 1, last_line: 1, first_column: 10, last_column: 13 }, identifierChain: [{ name: 'tbl' }] },
+            {type: 'column', location: { first_line: 1, last_line: 1, first_column: 14, last_column: 23 }, identifierChain: [{ name: 'tbl' }, { name: 'col' }, { name: 'field'}] }
+          ]
+        }
+      });
+    });
+
+    it('should handle "DESCRIBE EXTENDED tbl;|"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE EXTENDED tbl;',
+        afterCursor: '',
+        containsKeywords: ['SELECT'],
+        expectedResult: {
+          lowerCase: false,
+          locations: [
+            {type: 'table', location: { first_line: 1, last_line: 1, first_column: 19, last_column: 22 }, identifierChain: [{ name: 'tbl' }] }
+          ]
+        }
+      });
+    });
+
+    it('should handle "DESCRIBE EXTENDED tbl col.field;|"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE EXTENDED tbl col.field;',
+        afterCursor: '',
+        hasLocations: true,
+        containsKeywords: ['SELECT'],
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
+    it('should handle DESCRIBE | tbl;', function () {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE ',
+        afterCursor: ' tbl;',
+        hasLocations: true,
+        containsKeywords: ['EXTENDED', 'FORMATTED'],
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
+    it('should handle DESCRIBE ext| db.tbl;', function () {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE ext',
+        afterCursor: ' db.tbl;',
+        hasLocations: true,
+        containsKeywords: ['EXTENDED', 'FORMATTED'],
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
+    it('should handle "DESCRIBE FORMATTED tbl;|"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE FORMATTED tbl;',
+        afterCursor: '',
+        hasLocations: true,
+        containsKeywords: ['SELECT'],
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
+    it('should handle "DESCRIBE FORMATTED tbl col.field;|"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE FORMATTED tbl col.field;',
+        afterCursor: '',
+        hasLocations: true,
+        containsKeywords: ['SELECT'],
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
+    it('should handle "DESCRIBE FUNCTION cos;|"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE FUNCTION cos;',
+        afterCursor: '',
+        containsKeywords: ['SELECT'],
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
+    it('should handle "DESCRIBE FUNCTION EXTENDED cos;|"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE FUNCTION EXTENDED cos;',
+        afterCursor: '',
+        containsKeywords: ['SELECT'],
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
+    it('should handle "DESCRIBE DATABASE db;|"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE DATABASE db;',
+        afterCursor: '',
+        hasLocations: true,
+        containsKeywords: ['SELECT'],
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
+    it('should handle "DESCRIBE DATABASE EXTENDED db;|"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE DATABASE EXTENDED db;',
+        afterCursor: '',
+        hasLocations: true,
+        containsKeywords: ['SELECT'],
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
+    it('should handle "DESCRIBE SCHEMA db;|"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE SCHEMA db;',
+        afterCursor: '',
+        hasLocations: true,
+        containsKeywords: ['SELECT'],
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
+    it('should handle "DESCRIBE SCHEMA EXTENDED db;|"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE SCHEMA EXTENDED db;',
+        afterCursor: '',
+        hasLocations: true,
+        containsKeywords: ['SELECT'],
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
+    it('should suggest tables for "DESCRIBE |"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE ',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestKeywords: ['DATABASE', 'EXTENDED', 'FORMATTED', 'FUNCTION', 'SCHEMA'],
+          suggestTables: {},
+          suggestDatabases: { appendDot: true }
+        }
+      });
+    });
+
+    it('should suggest tables for "DESCRIBE tbl|"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE tbl',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestKeywords: ['DATABASE', 'EXTENDED', 'FORMATTED', 'FUNCTION', 'SCHEMA'],
+          suggestTables: {},
+          suggestDatabases: { appendDot: true }
+        }
+      });
+    });
+
+    it('should suggest tables for "DESCRIBE db.|"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE db.',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestTables: { identifierChain: [{ name: 'db' }] }
+        }
+      });
+    });
+
+    it('should suggest columns for "DESCRIBE db.tbl |"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE db.tbl ',
+        afterCursor: '',
+        hasLocations: true,
+        expectedResult: {
+          lowerCase: false,
+          suggestColumns: { tables: [{ identifierChain: [{ name: 'db' }, { name: 'tbl' }] }] }
+        }
+      });
+    });
+
+    it('should suggest keywords for "DESCRIBE FUNCTION |"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE FUNCTION ',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestKeywords: ['EXTENDED']
+        }
+      });
+    });
+
+    it('should suggest keywords for "DESCRIBE FUNCTION | cos"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE FUNCTION ',
+        afterCursor: ' cos',
+        expectedResult: {
+          lowerCase: false,
+          suggestKeywords: ['EXTENDED']
+        }
+      });
+    });
+
+    it('should suggest databases for "DESCRIBE DATABASE |"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE DATABASE ',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestKeywords: ['EXTENDED'],
+          suggestDatabases: {}
+        }
+      });
+    });
+
+    it('should suggest databases for "DESCRIBE DATABASE db|"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE DATABASE db',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestKeywords: ['EXTENDED'],
+          suggestDatabases: {}
+        }
+      });
+    });
+
+    it('should suggest databases for "DESCRIBE DATABASE EXTENDED |"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE DATABASE EXTENDED ',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestDatabases: {}
+        }
+      });
+    });
+
+    it('should suggest databases for "DESCRIBE SCHEMA |"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE SCHEMA ',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestKeywords: ['EXTENDED'],
+          suggestDatabases: {}
+        }
+      });
+    });
+
+    it('should suggest databases for "DESCRIBE SCHEMA db|"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE SCHEMA db',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestKeywords: ['EXTENDED'],
+          suggestDatabases: {}
+        }
+      });
+    });
+
+    it('should suggest databases for "DESCRIBE SCHEMA EXTENDED |"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE SCHEMA EXTENDED ',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestDatabases: {}
+        }
+      });
+    });
+
+    it('should suggest tables for "DESCRIBE EXTENDED |"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE EXTENDED ',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestTables: {},
+          suggestDatabases: { appendDot: true }
+        }
+      });
+    });
+
+    it('should suggest tables for "describe extended db.|"', function() {
+      assertAutoComplete({
+        beforeCursor: 'describe extended db.',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: true,
+          suggestTables: { identifierChain: [{ name: 'db' }] }
+        }
+      });
+    });
+
+    it('should suggest columns for "DESCRIBE EXTENDED db.tbl |"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE EXTENDED db.tbl ',
+        afterCursor: '',
+        hasLocations: true,
+        expectedResult: {
+          lowerCase: false,
+          suggestColumns: { tables: [{ identifierChain: [{ name: 'db' }, { name: 'tbl' }] }] }
+        }
+      });
+    });
+
+    it('should suggest tables for "DESCRIBE FORMATTED |"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE FORMATTED ',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestTables: {},
+          suggestDatabases: { appendDot: true }
+        }
+      });
+    });
+
+    it('should suggest tables for "DESCRIBE FORMATTED db.|"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE FORMATTED db.',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestTables: {
+            identifierChain: [{ name: 'db' }]
+          }
+        }
+      });
+    });
+
+    it('should suggest columns for "DESCRIBE FORMATTED db.tbl |"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE FORMATTED db.tbl ',
+        afterCursor: '',
+        hasLocations: true,
+        expectedResult: {
+          lowerCase: false,
+          suggestColumns: { tables: [{ identifierChain: [{ name: 'db' }, { name: 'tbl' }] }] }
+        }
+      });
+    });
+
+    it('should suggest fields for "DESCRIBE FORMATTED db.tbl col.|"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE FORMATTED db.tbl col.',
+        afterCursor: '',
+        hasLocations: true,
+        expectedResult: {
+          lowerCase: false,
+          suggestColumns: { tables: [{ identifierChain: [{ name: 'db' }, { name: 'tbl' }, { name: 'col' }] }] }
+        }
+      });
+    });
+  });
+})();

+ 170 - 0
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecDescribe_impala.js

@@ -0,0 +1,170 @@
+// 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.
+
+(function () {
+  describe('sql.js Impala DESCRIBE statements', function() {
+
+    beforeAll(function () {
+      sql.yy.parseError = function (msg) {
+        throw Error(msg);
+      };
+      jasmine.addMatchers(SqlTestUtils.testDefinitionMatcher);
+    });
+
+    var assertAutoComplete = function (spec) {
+      spec.dialect = 'impala';
+      return SqlTestUtils.assertAutocomplete(spec);
+    };
+
+    it('should handle "DESCRIBE tbl;|"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE tbl;',
+        afterCursor: '',
+        containsKeywords: ['SELECT'],
+        expectedResult: {
+          lowerCase: false,
+          locations: [
+            {type: 'table', location: { first_line: 1, last_line: 1, first_column: 10, last_column: 13}, identifierChain: [{ name: 'tbl' }] }
+          ]
+        }
+      });
+    });
+
+    it('should handle "DESCRIBE db.tbl;|"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE db.tbl;',
+        afterCursor: '',
+        containsKeywords: ['SELECT'],
+        expectedResult: {
+          lowerCase: false,
+          locations: [
+            {type: 'database', location: { first_line: 1, last_line: 1, first_column: 10, last_column: 12 }, identifierChain: [{ name: 'db' }]},
+            {type: 'table', location: { first_line: 1, last_line: 1, first_column: 13, last_column: 16}, identifierChain: [{ name: 'db' }, { name: 'tbl' }] }
+          ]
+        }
+      });
+    });
+
+    it('should handle "DESCRIBE DATABASE db;|"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE DATABASE db;',
+        afterCursor: '',
+        hasLocations: true,
+        containsKeywords: ['SELECT'],
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
+    it('should handle "DESCRIBE EXTENDED db.tbl;|"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE EXTENDED db.tbl;',
+        afterCursor: '',
+        hasLocations: true,
+        containsKeywords: ['SELECT'],
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
+    it('should handle "DESCRIBE FORMATTED db.tbl;|"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE FORMATTED db.tbl;',
+        afterCursor: '',
+        hasLocations: true,
+        containsKeywords: ['SELECT'],
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
+    it('should suggest tables for "DESCRIBE |"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE ',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestKeywords: ['DATABASE', 'EXTENDED', 'FORMATTED'],
+          suggestTables: {},
+          suggestDatabases: { appendDot: true }
+        }
+      });
+    });
+
+    it('should suggest databases for "DESCRIBE DATABASE |"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE DATABASE ',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestKeywords: ['EXTENDED', 'FORMATTED'],
+          suggestDatabases: { }
+        }
+      });
+    });
+
+    it('should suggest tables for "DESCRIBE db|"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE db',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestKeywords: ['DATABASE', 'EXTENDED', 'FORMATTED'],
+          suggestTables: {},
+          suggestDatabases: { appendDot: true }
+        }
+      });
+    });
+
+    it('should suggest tables for "DESCRIBE FORMATTED db|"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE FORMATTED db',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestTables: {},
+          suggestDatabases: { appendDot: true }
+        }
+      });
+    });
+
+    it('should suggest tables for "DESCRIBE EXTENDED db|"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE EXTENDED db',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestTables: {},
+          suggestDatabases: { appendDot: true }
+        }
+      });
+    });
+
+    it('should suggest tables for "DESCRIBE db.|"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE db.',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestTables: { identifierChain: [{ name: 'db' }] }
+        }
+      });
+    });
+  });
+})();

+ 4 - 4
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecSelect.js

@@ -2498,12 +2498,12 @@
           dialect: 'hive',
           hasLocations: true,
           expectedResult: {
-            lowerCase: false,
             suggestJoins: { prependJoin: true, tables: [{ identifierChain: [{ name: 'foo' }] }] },
             suggestFilters: { prefix: 'WHERE', tables: [{ identifierChain: [{ name: 'foo' }] }] },
             suggestGroupBys: { prefix: 'GROUP BY', tables: [{ identifierChain: [{ name: 'foo' }] }] },
             suggestOrderBys: { prefix: 'ORDER BY', tables: [{ identifierChain: [{ name: 'foo' }] }] },
-            suggestKeywords: ['TABLESAMPLE', 'AS', 'LATERAL VIEW', 'WHERE', 'GROUP BY', 'HAVING', 'WINDOW', 'ORDER BY', 'CLUSTER BY', 'DISTRIBUTE BY', 'SORT BY', 'LIMIT', 'UNION', 'CROSS JOIN', 'FULL JOIN', 'FULL OUTER JOIN', 'JOIN', 'LEFT JOIN', 'LEFT OUTER JOIN', 'LEFT SEMI JOIN', 'RIGHT JOIN', 'RIGHT OUTER JOIN']
+            suggestKeywords: ['AS', 'WHERE', 'GROUP BY', 'HAVING', 'WINDOW', 'ORDER BY', 'CLUSTER BY', 'DISTRIBUTE BY', 'SORT BY', 'LIMIT', 'UNION', 'LATERAL VIEW', 'TABLESAMPLE', 'CROSS JOIN', 'FULL JOIN', 'FULL OUTER JOIN', 'JOIN', 'LEFT JOIN', 'LEFT OUTER JOIN', 'LEFT SEMI JOIN', 'RIGHT JOIN', 'RIGHT OUTER JOIN'],
+            lowerCase: false
           }
         });
       });
@@ -2515,12 +2515,12 @@
           dialect: 'hive',
           hasLocations: true,
           expectedResult: {
-            lowerCase: false,
             suggestJoins: { prependJoin: true, tables: [{ identifierChain: [{ name: 'db' }, { name: 'foo' }], alias: 'f' }] },
             suggestFilters: { prefix: 'WHERE', tables: [{ identifierChain: [{ name: 'db' }, { name: 'foo' }], alias: 'f' }] },
             suggestGroupBys: { prefix: 'GROUP BY', tables: [{ identifierChain: [{ name: 'db' }, { name: 'foo' }], alias: 'f' }] },
             suggestOrderBys: { prefix: 'ORDER BY', tables: [{ identifierChain: [{ name: 'db' }, { name: 'foo' }], alias: 'f' }] },
-            suggestKeywords: ['LATERAL VIEW', 'WHERE', 'GROUP BY', 'HAVING', 'WINDOW', 'ORDER BY', 'CLUSTER BY', 'DISTRIBUTE BY', 'SORT BY', 'LIMIT', 'UNION', 'CROSS JOIN', 'FULL JOIN', 'FULL OUTER JOIN', 'JOIN', 'LEFT JOIN', 'LEFT OUTER JOIN', 'LEFT SEMI JOIN', 'RIGHT JOIN', 'RIGHT OUTER JOIN']
+            suggestKeywords: ['WHERE', 'GROUP BY', 'HAVING', 'WINDOW', 'ORDER BY', 'CLUSTER BY', 'DISTRIBUTE BY', 'SORT BY', 'LIMIT', 'UNION', 'LATERAL VIEW', 'CROSS JOIN', 'FULL JOIN', 'FULL OUTER JOIN', 'JOIN', 'LEFT JOIN', 'LEFT OUTER JOIN', 'LEFT SEMI JOIN', 'RIGHT JOIN', 'RIGHT OUTER JOIN'],
+            lowerCase: false
           }
         });
       });

+ 2 - 1
desktop/core/src/desktop/templates/jasmineRunner.html

@@ -58,7 +58,8 @@
   <script type="text/javascript" src="../static/desktop/spec/autocomplete/sqlSpecAlter.js"></script>
   <script type="text/javascript" src="../static/desktop/spec/autocomplete/sqlSpecAnalyze.js"></script>
   <script type="text/javascript" src="../static/desktop/spec/autocomplete/sqlSpecCreate.js"></script>
-  <script type="text/javascript" src="../static/desktop/spec/autocomplete/sqlSpecDescribe.js"></script>
+  <script type="text/javascript" src="../static/desktop/spec/autocomplete/sqlSpecDescribe_hive.js"></script>
+  <script type="text/javascript" src="../static/desktop/spec/autocomplete/sqlSpecDescribe_impala.js"></script>
   <script type="text/javascript" src="../static/desktop/spec/autocomplete/sqlSpecDrop.js"></script>
   <script type="text/javascript" src="../static/desktop/spec/autocomplete/sqlSpecError.js"></script>
   <script type="text/javascript" src="../static/desktop/spec/autocomplete/sqlSpecGrant.js"></script>

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov