Эх сурвалжийг харах

HUE-5463 [autocomplete] Add autocomplete support for partitions in Hive describe table statements

Johan Ahlen 8 жил өмнө
parent
commit
d02e484

+ 19 - 7
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_main.jison

@@ -1117,12 +1117,12 @@ DescribeStatement_EDIT
  ;
 
 HiveDescribeStatement
- : '<hive>DESCRIBE' OptionalHiveExtendedOrFormatted SchemaQualifiedTableIdentifier DerivedColumnChain
+ : '<hive>DESCRIBE' OptionalHiveExtendedOrFormatted SchemaQualifiedTableIdentifier DerivedColumnChain OptionalPartitionSpec
    {
      parser.addTablePrimary($3);
      parser.addColumnLocation(@4, $4);
    }
- | '<hive>DESCRIBE' OptionalHiveExtendedOrFormatted SchemaQualifiedTableIdentifier
+ | '<hive>DESCRIBE' OptionalHiveExtendedOrFormatted SchemaQualifiedTableIdentifier OptionalPartitionSpec
    {
      parser.addTablePrimary($3);
    }
@@ -1134,28 +1134,40 @@ HiveDescribeStatement
  ;
 
 HiveDescribeStatement_EDIT
- : '<hive>DESCRIBE' OptionalHiveExtendedOrFormatted SchemaQualifiedTableIdentifier_EDIT
- | '<hive>DESCRIBE' OptionalHiveExtendedOrFormatted SchemaQualifiedTableIdentifier DerivedColumnChain_EDIT
+ : '<hive>DESCRIBE' OptionalHiveExtendedOrFormatted SchemaQualifiedTableIdentifier_EDIT OptionalPartitionSpec
+ | '<hive>DESCRIBE' OptionalHiveExtendedOrFormatted SchemaQualifiedTableIdentifier DerivedColumnChain_EDIT OptionalPartitionSpec
    {
      parser.addTablePrimary($3);
    }
- | '<hive>DESCRIBE' OptionalHiveExtendedOrFormatted 'CURSOR' SchemaQualifiedTableIdentifier DerivedColumnChain
+ | '<hive>DESCRIBE' OptionalHiveExtendedOrFormatted 'CURSOR' SchemaQualifiedTableIdentifier DerivedColumnChain OptionalPartitionSpec
    {
      if (!$2) {
        parser.suggestKeywords(['EXTENDED', 'FORMATTED']);
      }
    }
- | '<hive>DESCRIBE' OptionalHiveExtendedOrFormatted 'CURSOR' SchemaQualifiedTableIdentifier
+ | '<hive>DESCRIBE' OptionalHiveExtendedOrFormatted 'CURSOR' SchemaQualifiedTableIdentifier OptionalPartitionSpec
    {
      if (!$2) {
        parser.suggestKeywords(['EXTENDED', 'FORMATTED']);
      }
    }
- | '<hive>DESCRIBE' OptionalHiveExtendedOrFormatted SchemaQualifiedTableIdentifier 'CURSOR'
+ | '<hive>DESCRIBE' OptionalHiveExtendedOrFormatted SchemaQualifiedTableIdentifier 'CURSOR' OptionalPartitionSpec
    {
      parser.addTablePrimary($3);
      parser.suggestColumns();
+     if (!$5) {
+       parser.suggestKeywords(['PARTITION']);
+     }
+   }
+ | '<hive>DESCRIBE' OptionalHiveExtendedOrFormatted SchemaQualifiedTableIdentifier DerivedColumnChain 'CURSOR' OptionalPartitionSpec
+   {
+     if (!$6) {
+       parser.suggestKeywords(['PARTITION']);
+     }
    }
+ | '<hive>DESCRIBE' OptionalHiveExtendedOrFormatted SchemaQualifiedTableIdentifier DerivedColumnChain OptionalPartitionSpec_EDIT
+ | '<hive>DESCRIBE' OptionalHiveExtendedOrFormatted SchemaQualifiedTableIdentifier OptionalPartitionSpec_EDIT
+
  | '<hive>DESCRIBE' OptionalHiveExtendedOrFormatted 'CURSOR'
    {
      if (!$2) {

+ 35 - 3
desktop/core/src/desktop/static/desktop/js/autocomplete/spec/sqlSpecDescribe_hive.js

@@ -33,6 +33,7 @@
       assertAutoComplete({
         beforeCursor: 'DESCRIBE tbl;',
         afterCursor: '',
+        noErrors:true,
         containsKeywords: ['SELECT'],
         expectedResult: {
           lowerCase: false,
@@ -44,11 +45,13 @@
       });
     });
 
+
     it('should handle "DESCRIBE tbl col.field;|"', function() {
       assertAutoComplete({
         beforeCursor: 'DESCRIBE tbl col.field;',
         afterCursor: '',
         containsKeywords: ['SELECT'],
+        noErrors:true,
         expectedResult: {
           locations: [
             { type: 'statement', location: { 'first_line': 1, 'last_line': 1, 'first_column': 1, 'last_column': 23 } },
@@ -64,6 +67,7 @@
       assertAutoComplete({
         beforeCursor: 'DESCRIBE EXTENDED tbl;',
         afterCursor: '',
+        noErrors:true,
         containsKeywords: ['SELECT'],
         expectedResult: {
           lowerCase: false,
@@ -79,6 +83,19 @@
       assertAutoComplete({
         beforeCursor: 'DESCRIBE EXTENDED tbl col.field;',
         afterCursor: '',
+        noErrors:true,
+        containsKeywords: ['SELECT'],
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
+    it('should handle "DESCRIBE EXTENDED tbl col.field PARTITION (id = 1);|"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE EXTENDED tbl col.field PARTITION (id = 1);',
+        afterCursor: '',
+        noErrors:true,
         containsKeywords: ['SELECT'],
         expectedResult: {
           lowerCase: false
@@ -86,7 +103,7 @@
       });
     });
 
-    it('should handle DESCRIBE | tbl;', function () {
+    it('should suggest keywords for DESCRIBE | tbl;', function () {
       assertAutoComplete({
         beforeCursor: 'DESCRIBE ',
         afterCursor: ' tbl;',
@@ -97,7 +114,7 @@
       });
     });
 
-    it('should handle DESCRIBE ext| db.tbl;', function () {
+    it('should suggest keywords for DESCRIBE ext| db.tbl;', function () {
       assertAutoComplete({
         beforeCursor: 'DESCRIBE ext',
         afterCursor: ' db.tbl;',
@@ -112,6 +129,7 @@
       assertAutoComplete({
         beforeCursor: 'DESCRIBE FORMATTED tbl;',
         afterCursor: '',
+        noErrors: true,
         containsKeywords: ['SELECT'],
         expectedResult: {
           lowerCase: false
@@ -239,7 +257,8 @@
         afterCursor: '',
         expectedResult: {
           lowerCase: false,
-          suggestColumns: { tables: [{ identifierChain: [{ name: 'db' }, { name: 'tbl' }] }] }
+          suggestColumns: { tables: [{ identifierChain: [{ name: 'db' }, { name: 'tbl' }] }] },
+          suggestKeywords: ['PARTITION']
         }
       });
     });
@@ -363,6 +382,18 @@
       assertAutoComplete({
         beforeCursor: 'DESCRIBE EXTENDED db.tbl ',
         afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestColumns: { tables: [{ identifierChain: [{ name: 'db' }, { name: 'tbl' }] }] },
+          suggestKeywords: ['PARTITION']
+        }
+      });
+    });
+
+    it('should suggest columns for "DESCRIBE EXTENDED db.tbl | PARTITION (id = 1);"', function() {
+      assertAutoComplete({
+        beforeCursor: 'DESCRIBE EXTENDED db.tbl ',
+        afterCursor: ' PARTITION (id = 1);',
         expectedResult: {
           lowerCase: false,
           suggestColumns: { tables: [{ identifierChain: [{ name: 'db' }, { name: 'tbl' }] }] }
@@ -401,6 +432,7 @@
         afterCursor: '',
         expectedResult: {
           lowerCase: false,
+          suggestKeywords: ['PARTITION'],
           suggestColumns: { tables: [{ identifierChain: [{ name: 'db' }, { name: 'tbl' }] }] }
         }
       });

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/sqlAutocompleteParser.js


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/sqlSyntaxParser.js


Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно