Browse Source

HUE-6835 [autocomplete] Add WITH REPLICATION suggestion to CREATE TABLE

Johan Ahlen 8 years ago
parent
commit
7303070458

+ 11 - 1
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_create.jison

@@ -201,6 +201,8 @@ TableDefinitionRightPart_EDIT
    OptionalSkewedBy OptionalStoredAsOrBy HdfsLocation_EDIT OptionalTblproperties OptionalCachedIn OptionalAsSelectStatement
    OptionalSkewedBy OptionalStoredAsOrBy HdfsLocation_EDIT OptionalTblproperties OptionalCachedIn OptionalAsSelectStatement
  | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalWithSerdeproperties OptionalClusteredBy
  | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalWithSerdeproperties OptionalClusteredBy
    OptionalSkewedBy OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties CachedIn_EDIT OptionalAsSelectStatement
    OptionalSkewedBy OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties CachedIn_EDIT OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalWithSerdeproperties OptionalClusteredBy
+   OptionalSkewedBy OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties CachedIn WithReplication_EDIT OptionalAsSelectStatement
  | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalWithSerdeproperties OptionalClusteredBy
  | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalWithSerdeproperties OptionalClusteredBy
    OptionalSkewedBy OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalCachedIn OptionalAsSelectStatement_EDIT
    OptionalSkewedBy OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalCachedIn OptionalAsSelectStatement_EDIT
  | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalWithSerdeproperties OptionalClusteredBy
  | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalWithSerdeproperties OptionalClusteredBy
@@ -252,6 +254,9 @@ TableDefinitionRightPart_EDIT
        if (parser.isImpala() && !$10) {
        if (parser.isImpala() && !$10) {
          keywords.push({ value: 'CACHED IN', weight: 2 });
          keywords.push({ value: 'CACHED IN', weight: 2 });
        }
        }
+       if (parser.isImpala() && $10 && $10.suggestKeywords) {
+         keywords = keywords.concat(parser.createWeightedKeywords($10.suggestKeywords, 2));
+       }
        keywords.push({ value: 'AS', weight: 1 });
        keywords.push({ value: 'AS', weight: 1 });
      }
      }
 
 
@@ -1165,7 +1170,12 @@ CommitLocations
 
 
 OptionalCachedIn
 OptionalCachedIn
  :
  :
- | CachedIn
+ | CachedIn OptionalWithReplication
+   {
+     if (!$2) {
+       $$ = { suggestKeywords: ['WITH REPLICATION ='] };
+     }
+   }
  ;
  ;
 
 
 CachedIn
 CachedIn

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


+ 36 - 0
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecCreate.js

@@ -1375,6 +1375,42 @@
           });
           });
         });
         });
 
 
+        it('should suggest keywords for "CREATE TABLE foo (id int) CACHED IN \'boo\' |"', function () {
+          assertAutoComplete({
+            beforeCursor: 'CREATE TABLE foo (id int) CACHED IN \'boo\' ',
+            afterCursor: '',
+            dialect: 'impala',
+            expectedResult: {
+              lowerCase: false,
+              suggestKeywords: ['WITH REPLICATION =', 'AS']
+            }
+          });
+        });
+
+        it('should suggest keywords for "CREATE TABLE foo (id int) CACHED IN \'boo\' WITH |"', function () {
+          assertAutoComplete({
+            beforeCursor: 'CREATE TABLE foo (id int) CACHED IN \'boo\' WITH ',
+            afterCursor: '',
+            dialect: 'impala',
+            expectedResult: {
+              lowerCase: false,
+              suggestKeywords: ['REPLICATION =']
+            }
+          });
+        });
+
+        it('should suggest keywords for "CREATE TABLE foo (id int) CACHED IN \'boo\' WITH REPLICATION |"', function () {
+          assertAutoComplete({
+            beforeCursor: 'CREATE TABLE foo (id int) CACHED IN \'boo\' WITH REPLICATION ',
+            afterCursor: '',
+            dialect: 'impala',
+            expectedResult: {
+              lowerCase: false,
+              suggestKeywords: ['=']
+            }
+          });
+        });
+
         it('should suggest keywords for "CREATE ... TABLE ... PARTITIONED BY ... ROW FORMAT ... CACHED |"', function () {
         it('should suggest keywords for "CREATE ... TABLE ... PARTITIONED BY ... ROW FORMAT ... CACHED |"', function () {
           assertAutoComplete({
           assertAutoComplete({
             beforeCursor: 'CREATE EXTERNAL TABLE IF NOT EXISTS dbOne.tableName (id INT, col2 STRING COMMENT \'booo\', col3 BIGINT) ' +
             beforeCursor: 'CREATE EXTERNAL TABLE IF NOT EXISTS dbOne.tableName (id INT, col2 STRING COMMENT \'booo\', col3 BIGINT) ' +

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