Prechádzať zdrojové kódy

HUE-4588 [editor] The new autocompleter should support SET

No completions in this one, the intention is to prevent errors autocompleting subsequent statements. It can be extended to suggest options later.
Johan Ahlen 10 rokov pred
rodič
commit
704ac40e35

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

@@ -64,6 +64,10 @@ SelectList_ERROR_EDIT
    }
    }
  ;
  ;
 
 
+SetSpecification
+ : 'SET' SetOption '=' error
+ ;
+
 ErrorList
 ErrorList
  : error
  : error
  | Errors ',' error
  | Errors ',' error

+ 20 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_main.jison

@@ -178,6 +178,7 @@ SqlStatements
  | DataDefinition
  | DataDefinition
  | DataManipulation
  | DataManipulation
  | QuerySpecification
  | QuerySpecification
+ | SetSpecification
  | ExplainClause DataDefinition
  | ExplainClause DataDefinition
  | ExplainClause DataManipulation
  | ExplainClause DataManipulation
  | ExplainClause QuerySpecification
  | ExplainClause QuerySpecification
@@ -222,6 +223,25 @@ SqlStatement_EDIT
  | ExplainClause_EDIT QuerySpecification
  | ExplainClause_EDIT QuerySpecification
  ;
  ;
 
 
+SetSpecification
+ : 'SET' SetOption '=' SetValue
+ ;
+
+SetOption
+ : RegularIdentifier
+ | SetOption AnyDot RegularIdentifier
+ ;
+
+SetValue
+ : RegularIdentifier
+ | SignedInteger
+ | SignedInteger RegularIdentifier
+ | QuotedValue
+ | 'TRUE'
+ | 'FALSE'
+ | 'NULL'
+ ;
+
 ExplainClause
 ExplainClause
  : '<hive>EXPLAIN' OptionalHiveExplainTypes
  : '<hive>EXPLAIN' OptionalHiveExplainTypes
  | '<impala>EXPLAIN'
  | '<impala>EXPLAIN'

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


+ 74 - 0
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpec.js

@@ -322,6 +322,80 @@ define([
       });
       });
     });
     });
 
 
+    describe('SET', function () {
+      it('should handle "set hive.exec.compress.output=true;|"', function () {
+        assertAutoComplete({
+          beforeCursor: 'set hive.exec.compress.output=true;',
+          afterCursor: '',
+          noErrors: true,
+          containsKeywords: ['SELECT'],
+          expectedResult: {
+            lowerCase: true
+          }
+        });
+      });
+
+      it('should handle "set bla.bla="ble";|"', function () {
+        assertAutoComplete({
+          beforeCursor: 'set bla.bla="ble";',
+          afterCursor: '',
+          noErrors: true,
+          containsKeywords: ['SELECT'],
+          expectedResult: {
+            lowerCase: true
+          }
+        });
+      });
+
+      it('should handle "set bla.bla=\'ble\';|"', function () {
+        assertAutoComplete({
+          beforeCursor: 'set bla.bla=\'ble\';',
+          afterCursor: '',
+          noErrors: true,
+          containsKeywords: ['SELECT'],
+          expectedResult: {
+            lowerCase: true
+          }
+        });
+      });
+
+      it('should handle "set mem_limit=64g;|"', function () {
+        assertAutoComplete({
+          beforeCursor: 'set mem_limit=64g;',
+          afterCursor: '',
+          noErrors: true,
+          containsKeywords: ['SELECT'],
+          expectedResult: {
+            lowerCase: true
+          }
+        });
+      });
+
+      it('should handle "set DISABLE_UNSAFE_SPILLS=true;|"', function () {
+        assertAutoComplete({
+          beforeCursor: 'set DISABLE_UNSAFE_SPILLS=true;',
+          afterCursor: '',
+          noErrors: true,
+          containsKeywords: ['SELECT'],
+          expectedResult: {
+            lowerCase: true
+          }
+        });
+      });
+
+      it('should handle "set RESERVATION_REQUEST_TIMEOUT=900000;|"', function () {
+        assertAutoComplete({
+          beforeCursor: 'set RESERVATION_REQUEST_TIMEOUT=900000;',
+          afterCursor: '',
+          noErrors: true,
+          containsKeywords: ['SELECT'],
+          expectedResult: {
+            lowerCase: true
+          }
+        });
+      });
+    });
+
     describe('Impala specific', function () {
     describe('Impala specific', function () {
       it('should suggest keywords for "|"', function() {
       it('should suggest keywords for "|"', function() {
         assertAutoComplete({
         assertAutoComplete({

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