Browse Source

HUE-4591 [editor] The new autocompleter should support REFRESH

Johan Ahlen 9 years ago
parent
commit
8f311f7101

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

@@ -219,6 +219,7 @@
 <impala>'PREPARE_FN'                       { return '<impala>PREPARE_FN'; }
 <impala>'RCFILE'                           { return '<impala>RCFILE'; }
 <impala>'REAL'                             { return '<impala>REAL'; }
+<impala>'REFRESH'                          { determineCase(yytext); return '<impala>REFRESH'; }
 <impala>'RENAME'                           { return '<impala>RENAME'; }
 <impala>'REPLACE'                          { return '<impala>REPLACE'; }
 <impala>'RETURNS'                          { return '<impala>RETURNS'; }

+ 18 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_analyze.jison

@@ -16,10 +16,12 @@
 
 DataDefinition
  : AnalyzeStatement
+ | RefreshStatement
  ;
 
 DataDefinition_EDIT
  : AnalyzeStatement_EDIT
+ | RefreshStatement_EDIT
  ;
 
 AnalyzeStatement
@@ -122,4 +124,20 @@ CacheMetadata_EDIT
 OptionalNoscan
  :
  | '<hive>NOSCAN'
+ ;
+
+RefreshStatement
+ : '<impala>REFRESH' SchemaQualifiedTableIdentifier
+   {
+     addTablePrimary($2);
+   }
+ ;
+
+RefreshStatement_EDIT
+ : '<impala>REFRESH' 'CURSOR'
+   {
+     suggestTables();
+     suggestDatabases({ appendDot: true });
+   }
+ | '<impala>REFRESH' SchemaQualifiedTableIdentifier_EDIT
  ;

File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/sql.js


+ 56 - 0
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecAnalyze.js

@@ -252,5 +252,61 @@ define([
         });
       });
     });
+
+    describe('REFRESH', function () {
+      it('should handle "REFRESH db.tbl;|"', function() {
+        assertAutoComplete({
+          beforeCursor: 'REFRESH db.tbl;',
+          afterCursor: '',
+          dialect: 'impala',
+          noErrors:true,
+          containsKeywords: ['SELECT'],
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false
+          }
+        });
+      });
+
+      it('should suggest keywords for "|"', function() {
+        assertAutoComplete({
+          beforeCursor: '',
+          afterCursor: '',
+          dialect: 'impala',
+          noErrors:true,
+          containsKeywords: ['REFRESH'],
+          expectedResult: {
+            lowerCase: false
+          }
+        });
+      });
+
+      it('should suggest tables for "REFRESH |"', function() {
+        assertAutoComplete({
+          beforeCursor: 'REFRESH ',
+          afterCursor: '',
+          dialect: 'impala',
+          noErrors:true,
+          expectedResult: {
+            lowerCase: false,
+            suggestTables: {},
+            suggestDatabases: { appendDot: true }
+          }
+        });
+      });
+
+      it('should suggest tables for "REFRESH db.|"', function() {
+        assertAutoComplete({
+          beforeCursor: 'REFRESH db.',
+          afterCursor: '',
+          dialect: 'impala',
+          noErrors:true,
+          expectedResult: {
+            lowerCase: false,
+            suggestTables: { identifierChain: [{ name: 'db' }]}
+          }
+        });
+      });
+    })
   });
 });

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