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

HUE-4535 [editor] Add additional autocompletion for ALTER, CREATE and DROP

With this the only ones left for DDL are related to roles and privileges. This one covers:

- ALTER/DROP INDEX
- ALTER/DROP VIEW
- DROP TABLE
- CREATE/DROP TEMPORARY MACRO
- MSCK, RELOAD, TRUNCATE
Johan Ahlen 9 жил өмнө
parent
commit
2384b6781d

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

@@ -98,6 +98,7 @@
 <hive>'LOAD'                               { determineCase(yytext); return '<hive>LOAD'; }
 <hive>'LOCATION'                           { this.begin('hdfs'); return '<hive>LOCATION'; }
 <hive>'LOCKS'                              { return '<hive>LOCKS'; }
+<hive>'MSCK'                               { return '<hive>MSCK'; }
 <hive>'NO_DROP'                            { return '<hive>NO_DROP'; }
 <hive>'OFFLINE'                            { return '<hive>OFFLINE'; }
 <hive>'ORC'                                { return '<hive>ORC'; }
@@ -107,11 +108,13 @@
 <hive>'PARTITIONS'                         { return '<hive>PARTITIONS'; }
 <hive>'PURGE'                              { return '<hive>PURGE'; }
 <hive>'RCFILE'                             { return '<hive>RCFILE'; }
+<hive>'REBUILD'                            { return '<hive>REBUILD'; }
+<hive>'RELOAD'                             { determineCase(yytext); return '<hive>RELOAD'; }
+<hive>'REPAIR'                             { return '<hive>REPAIR'; }
 <hive>'RECOVER'                            { return '<hive>RECOVER'; }
 <hive>'RENAME'                             { return '<hive>RENAME'; }
 <hive>'REPLACE'                            { return '<hive>REPLACE'; }
 <hive>'RESTRICT'                           { return '<hive>RESTRICT'; }
-<hive>'REBUILD'                            { return '<hive>REBUILD'; }
 <hive>'ROLE'                               { return '<hive>ROLE'; }
 <hive>'ROLES'                              { return '<hive>ROLES'; }
 <hive>'SCHEMA'                             { return '<hive>SCHEMA'; }
@@ -294,6 +297,7 @@
 'TINYINT'                                  { return 'TINYINT'; }
 'TO'                                       { return 'TO'; }
 'TRUE'                                     { return 'TRUE'; }
+'TRUNCATE'                                 { determineCase(yytext); return 'TRUNCATE'; }
 'UNBOUNDED'                                { return 'UNBOUNDED'; }
 'UPDATE'                                   { determineCase(yytext); return 'UPDATE'; }
 'USE'                                      { determineCase(yytext); return 'USE'; }

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

@@ -23,14 +23,59 @@ DataDefinition_EDIT
  ;
 
 AlterStatement
- : AlterTable
+ : AlterIndex
+ | AlterTable
+ | AlterView
+ | Msck
+ | ReloadFunction
  ;
 
 AlterStatement_EDIT
- : AlterTable_EDIT
+ : AlterIndex_EDIT
+ | AlterTable_EDIT
+ | AlterView_EDIT
+ | Msck_EDIT
+ | ReloadFunction_EDIT
  | 'ALTER' 'CURSOR'
    {
-     suggestKeywords(['TABLE']);
+     if (isHive()) {
+       suggestKeywords(['INDEX', 'TABLE', 'VIEW']);
+     } else {
+       suggestKeywords(['TABLE', 'VIEW']);
+     }
+   }
+ ;
+
+AlterIndex
+ : 'ALTER' '<hive>INDEX' RegularOrBacktickedIdentifier 'ON' SchemaQualifiedTableIdentifier OptionalPartitionSpec '<hive>REBUILD'
+   {
+     addTablePrimary($5);
+   }
+ ;
+
+AlterIndex_EDIT
+ : 'ALTER' '<hive>INDEX' RegularOrBacktickedIdentifier 'CURSOR'
+   {
+     suggestKeywords(['ON']);
+   }
+ | 'ALTER' '<hive>INDEX' RegularOrBacktickedIdentifier 'ON' 'CURSOR'
+   {
+     suggestTables();
+     suggestDatabases({ appendDot: true });
+   }
+ | 'ALTER' '<hive>INDEX' RegularOrBacktickedIdentifier 'ON' SchemaQualifiedTableIdentifier_EDIT
+ | 'ALTER' '<hive>INDEX' RegularOrBacktickedIdentifier 'ON' SchemaQualifiedTableIdentifier OptionalPartitionSpec_EDIT
+   {
+     addTablePrimary($5);
+   }
+ | 'ALTER' '<hive>INDEX' RegularOrBacktickedIdentifier 'ON' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'CURSOR'
+   {
+     addTablePrimary($5);
+     if (!$6) {
+       suggestKeywords(['PARTITION', 'REBUILD']);
+     } else {
+       suggestKeywords(['REBUILD']);
+     }
    }
  ;
 
@@ -400,9 +445,14 @@ AlterTableLeftSide
 
 AlterTableLeftSide_EDIT
  : 'ALTER' AnyTable SchemaQualifiedTableIdentifier_EDIT
+   {
+     if (parser.yy.result.suggestTables) {
+       parser.yy.result.suggestTables.onlyTables = true;
+     }
+   }
  | 'ALTER' AnyTable 'CURSOR'
    {
-     suggestTables();
+     suggestTables({ onlyTables: true });
      suggestDatabases({ appendDot: true });
    }
  ;
@@ -604,4 +654,106 @@ OptionalCascadeOrRestrict
  :
  | '<hive>CASCADE'
  | '<hive>RESTRICT'
+ ;
+
+AlterView
+ : AlterViewLeftSide 'SET' '<hive>TBLPROPERTIES' ParenthesizedPropertyAssignmentList
+ | AlterViewLeftSide AnyAs QuerySpecification
+ | AlterViewLeftSide '<impala>RENAME' 'TO' RegularOrBacktickedIdentifier
+ | AlterViewLeftSide '<impala>RENAME' 'TO' RegularOrBacktickedIdentifier '<impala>.' RegularOrBacktickedIdentifier
+ ;
+
+AlterView_EDIT
+ : AlterViewLeftSide_EDIT
+ | AlterViewLeftSide 'CURSOR'
+   {
+     if (isHive()) {
+       suggestKeywords(['AS', 'SET TBLPROPERTIES']);
+     } else if (isImpala()) {
+       suggestKeywords(['AS', 'RENAME TO']);
+     } else {
+       suggestKeywords(['AS']);
+     }
+   }
+ | AlterViewLeftSide 'SET' 'CURSOR'
+   {
+     if (isHive()) {
+       suggestKeywords(['TBLPROPERTIES']);
+     }
+   }
+ | AlterViewLeftSide AnyAs 'CURSOR'
+   {
+     suggestKeywords(['SELECT']);
+   }
+ | AlterViewLeftSide AnyAs QuerySpecification_EDIT
+ | AlterViewLeftSide '<impala>RENAME' 'CURSOR'
+   {
+     suggestKeywords(['TO']);
+   }
+ | AlterViewLeftSide '<impala>RENAME' 'TO' 'CURSOR'
+   {
+     suggestDatabases({ appendDot: true });
+   }
+ ;
+
+
+AlterViewLeftSide
+ : 'ALTER' AnyView SchemaQualifiedTableIdentifier
+   {
+     addTablePrimary($3);
+   }
+ ;
+
+AlterViewLeftSide_EDIT
+ : 'ALTER' AnyView SchemaQualifiedTableIdentifier_EDIT
+   {
+     if (parser.yy.result.suggestTables) {
+       parser.yy.result.suggestTables.onlyViews = true;
+     }
+   }
+ | 'ALTER' AnyView 'CURSOR'
+   {
+     suggestTables({ onlyViews: true });
+     suggestDatabases({ appendDot: true });
+   }
+ ;
+
+Msck
+ : '<hive>MSCK' '<hive>REPAIR' '<hive>TABLE' SchemaQualifiedTableIdentifier
+   {
+     addTablePrimary($4);
+   }
+ ;
+
+Msck_EDIT
+ : '<hive>MSCK' 'CURSOR'
+   {
+     suggestKeywords(['REPAIR TABLE']);
+   }
+ | '<hive>MSCK' '<hive>REPAIR' 'CURSOR'
+   {
+     suggestKeywords(['TABLE']);
+   }
+ | '<hive>MSCK' '<hive>REPAIR' '<hive>TABLE' 'CURSOR'
+   {
+     suggestTables({ onlyTables: true });
+     suggestDatabases({ appendDot: true });
+   }
+ | '<hive>MSCK' '<hive>REPAIR' '<hive>TABLE' SchemaQualifiedTableIdentifier_EDIT
+   {
+     if (parser.yy.result.suggestTables) {
+       parser.yy.result.suggestTables.onlyViews = true;
+     }
+   }
+ ;
+
+ReloadFunction
+ : '<hive>RELOAD' '<hive>FUNCTION'
+ ;
+
+ReloadFunction_EDIT
+ : '<hive>RELOAD' 'CURSOR'
+   {
+     suggestKeywords(['FUNCTION']);
+   }
  ;

+ 52 - 2
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_create.jison

@@ -29,6 +29,7 @@ CreateStatement
  | RoleDefinition
  | FunctionDefinition
  | IndexDefinition
+ | MacroDefinition
  ;
 
 CreateStatement_EDIT
@@ -37,15 +38,16 @@ CreateStatement_EDIT
  | ViewDefinition_EDIT
  | FunctionDefinition_EDIT
  | IndexDefinition_EDIT
+ | MacroDefinition_EDIT
  | AnyCreate OptionalHiveTemporary OptionalExternal 'CURSOR'
    {
      if ($3) {
        suggestKeywords(['TABLE']);
      } else if (isHive()) {
        if ($2) {
-         suggestKeywords(['EXTERNAL TABLE', 'FUNCTION', 'TABLE']);
+         suggestKeywords(['EXTERNAL TABLE', 'FUNCTION', 'MACRO', 'TABLE']);
        } else {
-         suggestKeywords(['DATABASE', 'EXTERNAL TABLE', 'FUNCTION', 'INDEX', 'ROLE', 'SCHEMA', 'TABLE', 'TEMPORARY EXTERNAL TABLE', 'TEMPORARY FUNCTION', 'TEMPORARY TABLE', 'VIEW']);
+         suggestKeywords(['DATABASE', 'EXTERNAL TABLE', 'FUNCTION', 'INDEX', 'ROLE', 'SCHEMA', 'TABLE', 'TEMPORARY EXTERNAL TABLE', 'TEMPORARY FUNCTION', 'TEMPORARY MACRO', 'TEMPORARY TABLE', 'VIEW']);
        }
      } else if (isImpala()) {
        suggestKeywords(['AGGREGATE FUNCTION', 'DATABASE', 'EXTERNAL TABLE', 'FUNCTION', 'ROLE', 'SCHEMA', 'TABLE', 'VIEW']);
@@ -1514,3 +1516,51 @@ IndexColumnList_EDIT
  | AnyCursor ',' IndexColumnList
  | IndexColumnList ',' AnyCursor ',' IndexColumnList
  ;
+
+MacroDefinition
+ : AnyCreate '<hive>TEMPORARY' '<hive>MACRO' RegularIdentifier MacroArguments ValueExpression
+ ;
+
+MacroDefinition_EDIT
+ : AnyCreate '<hive>TEMPORARY' '<hive>MACRO' RegularIdentifier MacroArguments_EDIT
+ | AnyCreate '<hive>TEMPORARY' '<hive>MACRO' RegularIdentifier MacroArguments_EDIT ValueExpression
+ | AnyCreate '<hive>TEMPORARY' '<hive>MACRO' RegularIdentifier MacroArguments 'CURSOR'
+   {
+     suggestFunctions();
+   }
+ | AnyCreate '<hive>TEMPORARY' '<hive>MACRO' RegularIdentifier MacroArguments ValueExpression_EDIT
+ ;
+
+MacroArguments
+ : '(' ')'
+ | '(' MacroArgumentList ')'
+ ;
+
+MacroArguments_EDIT
+ : '(' MacroArgumentList_EDIT RightParenthesisOrError
+ ;
+
+
+MacroArgumentList
+ : MacroArgument
+ | MacroArgumentList ',' MacroArgument
+ ;
+
+MacroArgumentList_EDIT
+ : MacroArgument_EDIT
+ | MacroArgumentList ',' MacroArgument_EDIT
+ | MacroArgument_EDIT ',' MacroArgumentList
+ | MacroArgumentList ',' MacroArgument_EDIT ',' MacroArgumentList
+ ;
+
+MacroArgument
+ : RegularIdentifier ColumnDataType
+ ;
+
+MacroArgument_EDIT
+ : RegularIdentifier 'CURSOR'
+   {
+     suggestKeywords(getColumnDataTypeKeywords());
+   }
+ | RegularIdentifier ColumnDataType_EDIT
+ ;

+ 133 - 14
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_drop.jison

@@ -25,21 +25,29 @@ DataDefinition_EDIT
 DropStatement
  : DropDatabaseStatement
  | DropTableStatement
+ | DropIndexStatement
+ | DropMacroStatement
+ | DropViewStatement
+ | TruncateTableStatement
  ;
 
 DropStatement_EDIT
- : 'DROP' 'CURSOR'
+ : DropDatabaseStatement_EDIT
+ | DropTableStatement_EDIT
+ | DropIndexStatement_EDIT
+ | DropMacroStatement_EDIT
+ | DropViewStatement_EDIT
+ | TruncateTableStatement_EDIT
+ | 'DROP' 'CURSOR'
    {
      if (isHive()) {
-       suggestKeywords(['DATABASE', 'FUNCTION', 'INDEX', 'MACRO', 'ROLE', 'SCHEMA', 'TABLE', 'TEMPORARY FUNCTION', 'TEMPORARY MACRO', 'VIEW']);
+       suggestKeywords(['DATABASE', 'FUNCTION', 'INDEX', 'ROLE', 'SCHEMA', 'TABLE', 'TEMPORARY FUNCTION', 'TEMPORARY MACRO', 'VIEW']);
      } else if (isImpala()) {
        suggestKeywords(['AGGREGATE FUNCTION', 'DATABASE', 'FUNCTION', 'INCREMENTAL STATS', 'ROLE', 'SCHEMA', 'STATS', 'TABLE', 'VIEW']);
      } else {
        suggestKeywords(['ROLE', 'SCHEMA', 'TABLE', 'VIEW']);
      }
    }
- | DropDatabaseStatement_EDIT
- | DropTableStatement_EDIT
  ;
 
 DropDatabaseStatement
@@ -72,7 +80,10 @@ DropDatabaseStatement_EDIT
  ;
 
 DropTableStatement
- : 'DROP' AnyTable OptionalIfExists TablePrimary
+ : 'DROP' AnyTable OptionalIfExists SchemaQualifiedTableIdentifier
+   {
+     addTablePrimary($4);
+   }
  ;
 
 DropTableStatement_EDIT
@@ -82,25 +93,133 @@ DropTableStatement_EDIT
      if (!$3) {
        suggestKeywords(['IF EXISTS']);
      }
-     suggestTables();
+     suggestTables({ onlyTables: true });
      suggestDatabases({
        appendDot: true
      });
    }
- | 'DROP' AnyTable OptionalIfExists TablePrimary_EDIT
+ | 'DROP' AnyTable OptionalIfExists SchemaQualifiedTableIdentifier_EDIT
    {
-     if ($4.identifierChain && $4.identifierChain.length === 1) {
-       suggestTablesOrColumns($4.identifierChain[0].name);
-     } else if ($4.identifierChain && $4.identifierChain.length === 0) {
-       suggestTables();
-       suggestDatabases({ appendDot: true });
+     if (parser.yy.result.suggestTables) {
+       parser.yy.result.suggestTables.onlyTables = true;
      }
    }
- | 'DROP' AnyTable OptionalIfExists_EDIT TablePrimary
- | 'DROP' AnyTable OptionalIfExists TablePrimary 'CURSOR'
+ | 'DROP' AnyTable OptionalIfExists_EDIT SchemaQualifiedTableIdentifier
+ | 'DROP' AnyTable OptionalIfExists SchemaQualifiedTableIdentifier 'CURSOR'
    {
+     addTablePrimary($4);
      if (isHive()) {
        suggestKeywords(['PURGE']);
      }
    }
+ ;
+
+DropIndexStatement
+ : 'DROP' '<hive>INDEX' OptionalIfExists RegularOrBacktickedIdentifier 'ON' SchemaQualifiedTableIdentifier
+   {
+     addTablePrimary($6);
+   }
+ ;
+
+DropIndexStatement_EDIT
+ : 'DROP' '<hive>INDEX' OptionalIfExists 'CURSOR'
+   {
+     suggestKeywords(['IF EXISTS']);
+   }
+ | 'DROP' '<hive>INDEX' OptionalIfExists_EDIT
+ | 'DROP' '<hive>INDEX' OptionalIfExists RegularOrBacktickedIdentifier 'CURSOR'
+   {
+     suggestKeywords(['ON']);
+   }
+ | 'DROP' '<hive>INDEX' OptionalIfExists RegularOrBacktickedIdentifier 'ON' 'CURSOR'
+   {
+     suggestTables();
+     suggestDatabases({ appendDot: true });
+   }
+ | 'DROP' '<hive>INDEX' OptionalIfExists RegularOrBacktickedIdentifier 'ON' SchemaQualifiedTableIdentifier_EDIT
+ ;
+
+DropMacroStatement
+ : 'DROP' '<hive>TEMPORARY' '<hive>MACRO' OptionalIfExists RegularIdentifier
+ ;
+
+DropMacroStatement_EDIT
+ : 'DROP' '<hive>TEMPORARY' 'CURSOR'
+   {
+     suggestKeywords(['MACRO']);
+   }
+ | 'DROP' '<hive>TEMPORARY' '<hive>MACRO' OptionalIfExists 'CURSOR'
+   {
+     if (!$4) {
+       suggestKeywords(['IF EXISTS']);
+     }
+   }
+ | 'DROP' '<hive>TEMPORARY' '<hive>MACRO' OptionalIfExists_EDIT
+ ;
+
+DropViewStatement
+ : 'DROP' AnyView OptionalIfExists SchemaQualifiedTableIdentifier
+   {
+     addTablePrimary($4);
+   }
+ ;
+
+DropViewStatement_EDIT
+ : 'DROP' AnyView OptionalIfExists 'CURSOR'
+   {
+     if (!$3) {
+       suggestKeywords(['IF EXISTS']);
+     }
+     suggestTables({ onlyViews: true });
+     suggestDatabases({ appendDot: true });
+   }
+ | 'DROP' AnyView OptionalIfExists 'CURSOR' SchemaQualifiedTableIdentifier
+   {
+     addTablePrimary($5);
+     if (!$3) {
+       suggestKeywords(['IF EXISTS']);
+     }
+   }
+ | 'DROP' AnyView OptionalIfExists_EDIT
+ | 'DROP' AnyView OptionalIfExists_EDIT SchemaQualifiedTableIdentifier
+   {
+     addTablePrimary($4);
+   }
+ | 'DROP' AnyView OptionalIfExists SchemaQualifiedTableIdentifier_EDIT
+   {
+     if (parser.yy.result.suggestTables) {
+       parser.yy.result.suggestTables.onlyViews = true;
+     }
+   }
+ ;
+
+TruncateTableStatement
+ : 'TRUNCATE' AnyTable SchemaQualifiedTableIdentifier OptionalPartitionSpec
+   {
+     addTablePrimary($3);
+   }
+ ;
+
+TruncateTableStatement_EDIT
+ : 'TRUNCATE' 'CURSOR'
+   {
+     suggestKeywords(['TABLE']);
+   }
+ | 'TRUNCATE' AnyTable 'CURSOR' OptionalPartitionSpec
+   {
+     suggestTables();
+     suggestDatabases({ appendDot: true });
+   }
+ | 'TRUNCATE' AnyTable SchemaQualifiedTableIdentifier_EDIT OptionalPartitionSpec
+ | 'TRUNCATE' AnyTable SchemaQualifiedTableIdentifier OptionalPartitionSpec 'CURSOR'
+   {
+     addTablePrimary($3);
+     if (isHive() && !$4) {
+       suggestKeywords(['PARTITION']);
+     }
+   }
+ | 'TRUNCATE' AnyTable SchemaQualifiedTableIdentifier OptionalPartitionSpec_EDIT
+   {
+     addTablePrimary($3);
+   }
  ;

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

@@ -68,6 +68,7 @@ NonReservedKeyword
  | '<hive>LOAD'
  | '<hive>LOCATION'
  | '<hive>LOCKS'
+ | '<hive>MSCK'
  | '<hive>NO_DROP'
  | '<hive>OFFLINE'
  | '<hive>ORC'
@@ -78,6 +79,8 @@ NonReservedKeyword
  | '<hive>PURGE'
  | '<hive>RCFILE'
  | '<hive>REBUILD'
+ | '<hive>RELOAD'
+ | '<hive>REPAIR'
  | '<hive>RECOVER'
  | '<hive>RENAME'
  | '<hive>REPLACE'
@@ -190,7 +193,7 @@ SqlStatement_EDIT
 // This is a work-around for error handling when a statement starts with some token that the parser can understand but
 // it's not a valid statement (see ErrorStatement). It contains everything except valid starting tokens ('SELECT', 'USE' etc.)
 NonStartingToken
- : '<hive>ALL' | '<hive>ARRAY' | '<hive>AVRO' | '<hive>BINARY' | '<hive>BUCKETS' | '<hive>AS' | '<hive>CLUSTER' | '<hive>CLUSTERED' | '<hive>COLLECTION' | '<hive>CONF' | '<hive>CROSS' | '<hive>CURRENT' | '<hive>DATE' | '<hive>DEFERRED' | '<hive>DELIMITED' | '<hive>DISTRIBUTE' | '<hive>DISTRIBUTED' | '<hive>ESCAPED' | '<hive>EXTENDED' | '<hive>EXTERNAL' | '<hive>FIELDS' | '<hive>FILE' | '<hive>FORMAT' | '<hive>FUNCTION' | '<hive>GRANT' | '<hive>IDXPROPERTIES' | '<hive>LATERAL' | '<hive>MACRO' | '<hive>PARTITION' | '<hive>REBUILD' | '<hive>TABLE' | '<hive>USER' | '<hive>ASC' | '<hive>COLUMNS' | '<hive>COMMENT' | '<hive>COMPACTIONS' | '<hive>DATA' | '<hive>DATABASES' | '<hive>DEFINED' | '<hive>DESC' | '<hive>STORED_AS_DIRECTORIES' | '<hive>FORMATTED' | '<hive>FUNCTIONS' | '<hive>INDEX' | '<hive>INDEXES' | '<hive>INPATH' | '<hive>INPUTFORMAT' | '<hive>ITEMS' | '<hive>JAR' | '<hive>LIMIT' | '<hive>KEYS' | '<hive>LINES' | '<hive>LOCATION' | '<hive>LOCKS' | '<hive>MAP' | '<hive>ORC' | '<hive>OUTPUTFORMAT' | '<hive>PARQUET' | '<hive>PARTITIONED' | '<hive>PARTITIONS' | '<hive>RCFILE' | '<hive>ROLE' | '<hive>ROLES' | '<hive>SCHEMA' | '<hive>SCHEMAS' | '<hive>SEQUENCEFILE' | '<hive>SERDE' | '<hive>SERDEPROPERTIES' | '<hive>SKEWED' | '<hive>SORTED' | '<hive>STORED' | '<hive>STRING' | '<hive>STRUCT' | '<hive>TABLES' | '<hive>TBLPROPERTIES' | '<hive>TEMPORARY' | '<hive>TERMINATED' | '<hive>TEXTFILE' | '<hive>TINYINT' | '<hive>TRANSACTIONS' | '<hive>UNIONTYPE' | '<hive>USING' | '<hive>VIEW' | '<hive>WINDOW' | '<hive>.' | '<hive>[' | '<hive>]'
+ : '<hive>ALL' | '<hive>ARRAY' | '<hive>AVRO' | '<hive>BINARY' | '<hive>BUCKETS' | '<hive>AS' | '<hive>CLUSTER' | '<hive>CLUSTERED' | '<hive>COLLECTION' | '<hive>CONF' | '<hive>CROSS' | '<hive>CURRENT' | '<hive>DATE' | '<hive>DEFERRED' | '<hive>DELIMITED' | '<hive>DISTRIBUTE' | '<hive>DISTRIBUTED' | '<hive>ESCAPED' | '<hive>EXTENDED' | '<hive>EXTERNAL' | '<hive>FIELDS' | '<hive>FILE' | '<hive>FORMAT' | '<hive>FUNCTION' | '<hive>GRANT' | '<hive>IDXPROPERTIES' | '<hive>LATERAL' | '<hive>MACRO' | '<hive>PARTITION' | '<hive>REBUILD' | '<hive>REPAIR' |'<hive>TABLE' | '<hive>USER' | '<hive>ASC' | '<hive>COLUMNS' | '<hive>COMMENT' | '<hive>COMPACTIONS' | '<hive>DATA' | '<hive>DATABASES' | '<hive>DEFINED' | '<hive>DESC' | '<hive>STORED_AS_DIRECTORIES' | '<hive>FORMATTED' | '<hive>FUNCTIONS' | '<hive>INDEX' | '<hive>INDEXES' | '<hive>INPATH' | '<hive>INPUTFORMAT' | '<hive>ITEMS' | '<hive>JAR' | '<hive>LIMIT' | '<hive>KEYS' | '<hive>LINES' | '<hive>LOCATION' | '<hive>LOCKS' | '<hive>MAP' | '<hive>ORC' | '<hive>OUTPUTFORMAT' | '<hive>PARQUET' | '<hive>PARTITIONED' | '<hive>PARTITIONS' | '<hive>RCFILE' | '<hive>ROLE' | '<hive>ROLES' | '<hive>SCHEMA' | '<hive>SCHEMAS' | '<hive>SEQUENCEFILE' | '<hive>SERDE' | '<hive>SERDEPROPERTIES' | '<hive>SKEWED' | '<hive>SORTED' | '<hive>STORED' | '<hive>STRING' | '<hive>STRUCT' | '<hive>TABLES' | '<hive>TBLPROPERTIES' | '<hive>TEMPORARY' | '<hive>TERMINATED' | '<hive>TEXTFILE' | '<hive>TINYINT' | '<hive>TRANSACTIONS' | '<hive>UNIONTYPE' | '<hive>USING' | '<hive>VIEW' | '<hive>WINDOW' | '<hive>.' | '<hive>[' | '<hive>]'
  | '<impala>AGGREGATE' | '<impala>AVRO' | '<impala>CACHED' | '<impala>CLOSE_FN' | '<impala>COLUMN' | '<impala>COMMENT' | '<impala>DATA' | '<impala>DATABASES' | '<impala>DELIMITED' | '<impala>ESCAPED' | '<impala>EXTERNAL' | '<impala>FIELDS' | '<impala>FINALIZE_FN' | '<impala>FIRST' | '<impala>FORMAT' | '<impala>FORMATTED' | '<impala>FUNCTION' | '<impala>FUNCTIONS' | '<impala>GROUP' | '<impala>INCREMENTAL' | '<impala>INTERVAL' | '<impala>INIT_FN' | '<impala>INPATH' | '<impala>LAST' | '<impala>LINES' | '<impala>LOCATION' | '<impala>MERGE_FN' | '<impala>NULLS' | '<impala>PARTITIONS' | '<impala>PREPARE_FN' | '<impala>REAL' | '<impala>RETURNS' | '<impala>SCHEMAS' | '<impala>SERIALIZE_FN' | '<impala>STATS' | '<impala>SYMBOL' | '<impala>TABLE' | '<impala>TABLES' | '<impala>USING' | '<impala>ANALYTIC' | '<impala>ANTI' | '<impala>CURRENT' | '<impala>GRANT' | '<impala>PARQUET' | '<impala>PARTITIONED' | '<impala>RCFILE' | '<impala>ROLE' | '<impala>ROLES' | '<impala>SEQUENCEFILE' | '<impala>SERDEPROPERTIES' | '<impala>SHUFFLE' | '<impala>STORED' | '<impala>TBLPROPERTIES' | '<impala>TERMINATED' | '<impala>TEXTFILE' | '<impala>UPDATE_FN' | '<impala>BROADCAST' | '<impala>...' | '<impala>.' | '<impala>[' | '<impala>]'
  | 'ALL' | 'AS' | 'ASC' | 'BETWEEN' | 'BIGINT' | 'BOOLEAN' | 'BY' | 'CASE' | 'CHAR' | 'CURRENT' | 'DATABASE' | 'DECIMAL' | 'DISTINCT' | 'DOUBLE' | 'DESC' | 'ELSE' | 'END' | 'EXISTS' | 'FALSE' | 'FLOAT' | 'FOLLOWING' | 'FROM' | 'FULL' | 'GROUP' | 'GROUPING' | 'HAVING' | 'IF' | 'IN' | 'INNER' | 'INT' | 'INTO' | 'IS' | 'JOIN' | 'LEFT' | 'LIKE' | 'LIMIT' | 'NOT' | 'NULL' | 'ON' | 'ORDER' | 'OUTER' | 'OVER' | 'PARTITION' | 'PRECEDING' | 'RANGE' | 'REGEXP' | 'RIGHT' | 'RLIKE' | 'ROW' | 'ROWS' | 'SCHEMA' | 'SEMI' | 'SET' | 'SMALLINT' | 'STRING' | 'TABLE' | 'THEN' | 'TIMESTAMP' | 'TINYINT' | 'TRUE' | 'UNION' | 'VARCHAR' | 'WHEN' | 'WHERE' | 'WITH' | 'ROLE'
  | 'AVG' | 'CAST' | 'COUNT' | 'MAX' | 'MIN' | 'STDDEV_POP' | 'STDDEV_SAMP' | 'SUM' | 'VARIANCE' | 'VAR_POP' | 'VAR_SAMP'

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


+ 1 - 1
desktop/core/src/desktop/static/desktop/js/autocomplete/sql_support.js

@@ -620,7 +620,7 @@ var suggestDdlAndDmlKeywords = function () {
   var keywords = ['ALTER', 'CREATE', 'DELETE', 'DESCRIBE', 'DROP', 'EXPLAIN', 'INSERT', 'REVOKE', 'SELECT', 'SET', 'SHOW', 'TRUNCATE', 'UPDATE', 'USE', 'WITH'];
 
   if (isHive()) {
-    keywords = keywords.concat(['ANALYZE', 'EXPORT', 'IMPORT', 'LOAD', 'MSCK', 'RESET']);
+    keywords = keywords.concat(['ANALYZE', 'EXPORT', 'IMPORT', 'LOAD', 'MSCK', 'RELOAD FUNCTION', 'RESET']);
   }
 
   if (isImpala()) {

+ 4 - 0
desktop/core/src/desktop/static/desktop/js/sqlAutocompleter2.js

@@ -264,6 +264,10 @@
       databaseName: parseResult.suggestTables.database || database,
       successCallback: function (data) {
         data.tables_meta.forEach(function (tablesMeta) {
+          if (parseResult.suggestTables.onlyTables && tablesMeta.type.toLowerCase() !== 'table' ||
+              parseResult.suggestTables.onlyViews && tablesMeta.type.toLowerCase() !== 'view') {
+            return;
+          }
           completions.push({
             value: prefix + self.backTickIfNeeded(tablesMeta.name),
             meta: tablesMeta.type.toLowerCase(),

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

@@ -221,7 +221,7 @@ define([
             lowerCase: false,
             suggestKeywords: ['ALTER', 'ANALYZE', 'CREATE', 'DELETE', 'DESCRIBE',
               'DROP', 'EXPLAIN', 'EXPORT', 'IMPORT', 'INSERT', 'LOAD', 'MSCK',
-              'RESET', 'REVOKE', 'SELECT', 'SET', 'SHOW', 'TRUNCATE', 'UPDATE', 'USE', 'WITH']
+              'RELOAD FUNCTION', 'RESET', 'REVOKE', 'SELECT', 'SET', 'SHOW', 'TRUNCATE', 'UPDATE', 'USE', 'WITH']
           }
         });
       });

+ 369 - 3
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecAlter.js

@@ -30,7 +30,86 @@ define([
 
     var assertAutoComplete = testUtils.assertAutocomplete;
 
-    describe('ALTER TABLE statements', function () {
+    describe('ALTER INDEX', function () {
+      it('should handle "ALTER INDEX baa ON boo.ba PARTITION (bla=1) REBUILD;|"', function() {
+        assertAutoComplete({
+          beforeCursor: 'ALTER INDEX baa ON boo.ba PARTITION (bla=1) REBUILD;',
+          afterCursor: '',
+          dialect: 'hive',
+          noErrors:true,
+          containsKeywords: ['SELECT'],
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false
+          }
+        });
+      });
+
+      it('should suggest keywords for "ALTER INDEX |"', function() {
+        assertAutoComplete({
+          beforeCursor: 'ALTER ',
+          afterCursor: '',
+          dialect: 'hive',
+          containsKeywords: ['INDEX'],
+          expectedResult: {
+            lowerCase: false
+          }
+        });
+      });
+
+      it('should suggest keywords for "ALTER INDEX boo |"', function() {
+        assertAutoComplete({
+          beforeCursor: 'ALTER INDEX boo ',
+          afterCursor: '',
+          dialect: 'hive',
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['ON']
+          }
+        });
+      });
+
+      it('should suggest tables for "ALTER INDEX boo ON |"', function() {
+        assertAutoComplete({
+          beforeCursor: 'ALTER INDEX boo ON ',
+          afterCursor: '',
+          dialect: 'hive',
+          expectedResult: {
+            lowerCase: false,
+            suggestTables: {},
+            suggestDatabases: { appendDot: true }
+          }
+        });
+      });
+
+      it('should suggest keywords for "ALTER INDEX boo ON bla |"', function() {
+        assertAutoComplete({
+          beforeCursor: 'ALTER INDEX boo ON bla ',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['PARTITION', 'REBUILD']
+          }
+        });
+      });
+
+      it('should suggest keywords for "ALTER INDEX boo ON bla PARTITION (baa = 1) |"', function() {
+        assertAutoComplete({
+          beforeCursor: 'ALTER INDEX boo ON bla PARTITION (baa = 1) ',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['REBUILD']
+          }
+        });
+      });
+    });
+
+    describe('ALTER TABLE', function () {
       it('should suggest keywords for "ALTER |"', function() {
         assertAutoComplete({
           beforeCursor: 'ALTER ',
@@ -48,7 +127,7 @@ define([
           afterCursor: '',
           expectedResult: {
             lowerCase: false,
-            suggestTables: {},
+            suggestTables: { onlyTables: true },
             suggestDatabases: { appendDot: true }
           }
         });
@@ -60,7 +139,7 @@ define([
           afterCursor: '',
           expectedResult: {
             lowerCase: false,
-            suggestTables: { database: 'foo' }
+            suggestTables: { database: 'foo', onlyTables: true  }
           }
         });
       });
@@ -1566,5 +1645,292 @@ define([
         });
       });
     });
+
+    describe('ALTER VIEW', function () {
+      it('should handle "ALTER VIEW baa.boo AS SELECT * FROM bla;|"', function() {
+        assertAutoComplete({
+          beforeCursor: 'ALTER VIEW baa.boo AS SELECT * FROM bla;',
+          afterCursor: '',
+          noErrors: true,
+          containsKeywords: ['SELECT'],
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false
+          }
+        });
+      });
+
+      it('should suggest keywords for "ALTER |"', function() {
+        assertAutoComplete({
+          beforeCursor: 'ALTER ',
+          afterCursor: '',
+          containsKeywords: ['VIEW'],
+          expectedResult: {
+            lowerCase: false
+          }
+        });
+      });
+
+      it('should suggest views for "ALTER VIEW |"', function() {
+        assertAutoComplete({
+          beforeCursor: 'ALTER VIEW ',
+          afterCursor: '',
+          expectedResult: {
+            lowerCase: false,
+            suggestTables: { onlyViews: true },
+            suggestDatabases: { appendDot: true }
+          }
+        });
+      });
+
+      it('should suggest views for "ALTER VIEW boo.|"', function() {
+        assertAutoComplete({
+          beforeCursor: 'ALTER VIEW boo.',
+          afterCursor: '',
+          expectedResult: {
+            lowerCase: false,
+            suggestTables: { database: 'boo', onlyViews: true }
+          }
+        });
+      });
+
+      it('should suggest keywords for "ALTER VIEW boo |"', function() {
+        assertAutoComplete({
+          beforeCursor: 'ALTER VIEW boo ',
+          afterCursor: '',
+          hasLocations: true,
+          containsKeywords: ['AS'],
+          expectedResult: {
+            lowerCase: false
+          }
+        });
+      });
+
+      it('should suggest keywords for "ALTER VIEW baa.boo AS |"', function() {
+        assertAutoComplete({
+          beforeCursor: 'ALTER VIEW baa.boo AS ',
+          afterCursor: '',
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['SELECT']
+          }
+        });
+      });
+
+      it('should suggest databases for "ALTER VIEW baa.boo AS SELECT * FROM |"', function() {
+        assertAutoComplete({
+          beforeCursor: 'ALTER VIEW baa.boo AS SELECT * FROM ',
+          afterCursor: '',
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestTables: {},
+            suggestDatabases: { appendDot: true }
+          }
+        });
+      });
+
+      describe('Hive specific', function () {
+        it('should handle "ALTER VIEW boo SET TBLPROPERTIES ("baa"=\'boo\');|"', function() {
+          assertAutoComplete({
+            beforeCursor: 'ALTER VIEW boo SET TBLPROPERTIES ("baa"=\'boo\');',
+            afterCursor: '',
+            dialect: 'hive',
+            noErrors: true,
+            hasLocations: true,
+            containsKeywords: ['SELECT'],
+            expectedResult: {
+              lowerCase: false
+            }
+          });
+        });
+
+        it('should suggest keywords for "ALTER VIEW boo |"', function() {
+          assertAutoComplete({
+            beforeCursor: 'ALTER VIEW boo ',
+            afterCursor: '',
+            dialect: 'hive',
+            hasLocations: true,
+            expectedResult: {
+              lowerCase: false,
+              suggestKeywords: ['AS', 'SET TBLPROPERTIES']
+            }
+          });
+        });
+
+        it('should suggest keywords for "ALTER VIEW boo SET |"', function() {
+          assertAutoComplete({
+            beforeCursor: 'ALTER VIEW boo SET ',
+            afterCursor: '',
+            dialect: 'hive',
+            hasLocations: true,
+            expectedResult: {
+              lowerCase: false,
+              suggestKeywords: ['TBLPROPERTIES']
+            }
+          });
+        });
+      });
+
+      describe('Impala specific', function () {
+        it('should suggest handle "ALTER VIEW bloo.boo RENAME TO baa.bla;|"', function() {
+          assertAutoComplete({
+            beforeCursor: 'ALTER VIEW bloo.boo RENAME TO baa.bla;',
+            afterCursor: '',
+            dialect: 'impala',
+            noErrors: true,
+            hasLocations: true,
+            containsKeywords: ['SELECT'],
+            expectedResult: {
+              lowerCase: false
+            }
+          });
+        });
+
+        it('should suggest keywords for "ALTER VIEW boo |"', function() {
+          assertAutoComplete({
+            beforeCursor: 'ALTER VIEW boo ',
+            afterCursor: '',
+            dialect: 'impala',
+            hasLocations: true,
+            expectedResult: {
+              lowerCase: false,
+              suggestKeywords: ['AS', 'RENAME TO']
+            }
+          });
+        });
+
+        it('should suggest keywords for "ALTER VIEW boo RENAME |"', function() {
+          assertAutoComplete({
+            beforeCursor: 'ALTER VIEW boo RENAME ',
+            afterCursor: '',
+            dialect: 'impala',
+            hasLocations: true,
+            expectedResult: {
+              lowerCase: false,
+              suggestKeywords: ['TO']
+            }
+          });
+        });
+
+        it('should suggest databases for "ALTER VIEW boo RENAME TO |"', function() {
+          assertAutoComplete({
+            beforeCursor: 'ALTER VIEW boo RENAME TO ',
+            afterCursor: '',
+            dialect: 'impala',
+            hasLocations: true,
+            expectedResult: {
+              lowerCase: false,
+              suggestDatabases: { appendDot: true }
+            }
+          });
+        });
+      });
+    });
+
+    describe('MSCK', function () {
+      it('should handle "MSCK REPAIR TABLE boo.baa;|"', function() {
+        assertAutoComplete({
+          beforeCursor: 'MSCK REPAIR TABLE boo.baa;',
+          afterCursor: '',
+          dialect: 'hive',
+          noErrors: true,
+          hasLocations: true,
+          containsKeywords: ['SELECT'],
+          expectedResult: {
+            lowerCase: false
+          }
+        });
+      });
+
+      it('should suggest keywords for "|"', function() {
+        assertAutoComplete({
+          beforeCursor: '',
+          afterCursor: '',
+          dialect: 'hive',
+          containsKeywords: ['MSCK'],
+          expectedResult: {
+            lowerCase: false
+          }
+        });
+      });
+
+      it('should suggest keywords for "MSCK |"', function() {
+        assertAutoComplete({
+          beforeCursor: 'MSCK ',
+          afterCursor: '',
+          dialect: 'hive',
+          containsKeywords: ['REPAIR TABLE'],
+          expectedResult: {
+            lowerCase: false
+          }
+        });
+      });
+
+      it('should suggest keywords for "MSCK REPAIR |"', function() {
+        assertAutoComplete({
+          beforeCursor: 'MSCK REPAIR ',
+          afterCursor: '',
+          dialect: 'hive',
+          containsKeywords: ['TABLE'],
+          expectedResult: {
+            lowerCase: false
+          }
+        });
+      });
+
+      it('should suggest tables for "MSCK REPAIR TABLE |"', function() {
+        assertAutoComplete({
+          beforeCursor: 'MSCK REPAIR TABLE ',
+          afterCursor: '',
+          dialect: 'hive',
+          expectedResult: {
+            lowerCase: false,
+            suggestTables: { onlyTables: true },
+            suggestDatabases: { appendDot: true }
+          }
+        });
+      });
+    });
+
+    describe('RELOAD FUNCTION', function () {
+      it('should handle "RELOAD FUNCTION;|"', function() {
+        assertAutoComplete({
+          beforeCursor: 'RELOAD FUNCTION;',
+          afterCursor: '',
+          dialect: 'hive',
+          noErrors: true,
+          containsKeywords: ['SELECT'],
+          expectedResult: {
+            lowerCase: false
+          }
+        });
+      });
+
+      it('should suggest keywords for "|"', function() {
+        assertAutoComplete({
+          beforeCursor: '',
+          afterCursor: '',
+          dialect: 'hive',
+          containsKeywords: ['RELOAD FUNCTION'],
+          expectedResult: {
+            lowerCase: false
+          }
+        });
+      });
+
+      it('should suggest keywords for "reload |"', function() {
+        assertAutoComplete({
+          beforeCursor: 'reload ',
+          afterCursor: '',
+          dialect: 'hive',
+          expectedResult: {
+            lowerCase: true,
+            suggestKeywords: ['FUNCTION']
+          }
+        });
+      });
+    })
   });
 });

+ 1144 - 1053
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecCreate.js

@@ -61,7 +61,7 @@ define([
           dialect: 'hive',
           expectedResult: {
             lowerCase: false,
-            suggestKeywords: ['DATABASE', 'EXTERNAL TABLE', 'FUNCTION', 'INDEX', 'ROLE', 'SCHEMA', 'TABLE', 'TEMPORARY EXTERNAL TABLE', 'TEMPORARY FUNCTION', 'TEMPORARY TABLE', 'VIEW']
+            suggestKeywords: ['DATABASE', 'EXTERNAL TABLE', 'FUNCTION', 'INDEX', 'ROLE', 'SCHEMA', 'TABLE', 'TEMPORARY EXTERNAL TABLE', 'TEMPORARY FUNCTION', 'TEMPORARY MACRO', 'TEMPORARY TABLE', 'VIEW']
           }
         });
       });
@@ -179,2124 +179,2215 @@ define([
       })
     });
 
-    describe('CREATE TABLE', function () {
-      it('should suggest keywords for "CREATE TABLE |"', function () {
-        assertAutoComplete({
-          beforeCursor: 'CREATE TABLE ',
-          afterCursor: '',
-          expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['IF NOT EXISTS']
-          }
-        });
-      });
-
-      it('should suggest keywords for "CREATE TABLE IF |"', function () {
-        assertAutoComplete({
-          beforeCursor: 'CREATE TABLE IF ',
-          afterCursor: '',
-          expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['NOT EXISTS']
-          }
-        });
-      });
-
-      it('should suggest keywords for "CREATE TABLE IF NOT |"', function () {
-        assertAutoComplete({
-          beforeCursor: 'CREATE TABLE IF NOT ',
-          afterCursor: '',
-          expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['EXISTS']
-          }
-        });
-      });
-
-      it('should handle for "CREATE TABLE foo (id INT);|"', function () {
-        assertAutoComplete({
-          beforeCursor: 'CREATE TABLE foo (id INT);',
-          afterCursor: '',
-          containsKeywords: ['SELECT'],
-          expectedResult: {
-            lowerCase: false
-          }
-        });
-      });
-
-      it('should suggest keywords for "CREATE TABLE foo (id |"', function () {
-        assertAutoComplete({
-          beforeCursor: 'CREATE TABLE foo (id ',
-          afterCursor: '',
-          containsKeywords: ['BOOLEAN'],
-          expectedResult: {
-            lowerCase: false
-          }
-        });
-      });
-
-      it('should suggest keywords for "CREATE TABLE foo (id INT, some FLOAT, bar |"', function () {
-        assertAutoComplete({
-          beforeCursor: 'CREATE TABLE foo (id INT, some FLOAT, bar ',
-          afterCursor: '',
-          containsKeywords: ['BOOLEAN'],
-          expectedResult: {
-            lowerCase: false
-          }
+    describe('CREATE FUNCTION', function () {
+      describe('Hive specific', function () {
+        it('should handle "CREATE TEMPORARY FUNCTION baaa AS \'boo.baa\'; |"', function () {
+          assertAutoComplete({
+            beforeCursor: 'CREATE TEMPORARY FUNCTION baaa AS \'boo.baa\'; ',
+            afterCursor: '',
+            dialect: 'hive',
+            containsKeywords: ['SELECT'],
+            expectedResult: {
+              lowerCase: false
+            }
+          });
         });
-      });
 
-      describe('Impala specific', function () {
-        it('should suggest keywords for "CREATE EXTERNAL |"', function () {
+        it('should handle "CREATE FUNCTION boo.baaa AS \'boo.baa\' USING JAR \'boo.jar\', FILE \'booo\', ARCHIVE \'baa\'; |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE EXTERNAL ',
+            beforeCursor: 'CREATE FUNCTION boo.baaa AS \'boo.baa\' USING JAR \'boo.jar\', FILE \'booo\', ARCHIVE \'baa\'; ',
             afterCursor: '',
-            dialect: 'impala',
+            dialect: 'hive',
+            containsKeywords: ['SELECT'],
             expectedResult: {
-              lowerCase: false,
-              suggestKeywords: ['TABLE']
+              lowerCase: false
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE boo |"', function () {
+        it('should suggest keywords for "CREATE FUNCTION boo.baa |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE boo ',
+            beforeCursor: 'CREATE FUNCTION boo.baa ',
             afterCursor: '',
-            dialect: 'impala',
+            dialect: 'hive',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['LIKE', 'LIKE PARQUET']
+              suggestKeywords: ['AS']
             }
           });
         });
 
-        it('should suggest tables for "CREATE TABLE boo LIKE |"', function () {
+        it('should suggest keywords for "CREATE FUNCTION boo.baa AS \'baa.boo\' |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE boo LIKE ',
+            beforeCursor: 'CREATE FUNCTION boo.baa AS \'baa.boo\' ',
             afterCursor: '',
-            dialect: 'impala',
+            dialect: 'hive',
             expectedResult: {
               lowerCase: false,
-              suggestTables: {},
-              suggestDatabases: { appendDot: true },
-              suggestKeywords: ['PARQUET']
+              suggestKeywords: ['USING']
             }
           });
         });
 
-        it('should suggest tables for "CREATE TABLE boo LIKE dbOne.|"', function () {
+        it('should suggest keywords for "CREATE FUNCTION boo.baa AS \'baa.boo\' USING |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE boo LIKE dbOne.',
+            beforeCursor: 'CREATE FUNCTION boo.baa AS \'baa.boo\' USING ',
             afterCursor: '',
-            dialect: 'impala',
+            dialect: 'hive',
             expectedResult: {
               lowerCase: false,
-              suggestTables: { database: 'dbOne' }
+              suggestKeywords: ['ARCHIVE', 'FILE', 'JAR']
             }
           });
         });
 
-        it('should suggest hdfs for "CREATE TABLE boo LIKE PARQUET \'|"', function () {
+        xit('should suggest hdfs for "CREATE FUNCTION boo.baa AS \'baa.boo\' USING FILE \'|"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE boo LIKE PARQUET \'',
+            beforeCursor: 'CREATE FUNCTION boo.baa AS \'baa.boo\' USING FILE \'',
             afterCursor: '',
-            dialect: 'impala',
+            dialect: 'hive',
             expectedResult: {
               lowerCase: false,
-              suggestHdfs: { path: ''}
+              suggestHdfs: { path: '' }
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) LOCATION \'|"', function () {
+        it('should suggest keywords for "CREATE FUNCTION boo.baa AS \'baa.boo\' USING FILE \'boo\' |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE boo LOCATION \'',
+            beforeCursor: 'CREATE FUNCTION boo.baa AS \'baa.boo\' USING FILE \'boo\' ',
             afterCursor: '',
-            dialect: 'impala',
+            dialect: 'hive',
             expectedResult: {
               lowerCase: false,
-              suggestHdfs: { path: ''}
+              suggestKeywords: ['ARCHIVE', 'FILE', 'JAR']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo LIKE PARQUET \'/blabla/\' |"', function () {
+        it('should suggest keywords for "CREATE TEMPORARY FUNCTION boo |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo LIKE PARQUET \'/blabla/\' ',
+            beforeCursor: 'CREATE TEMPORARY FUNCTION boo ',
             afterCursor: '',
-            dialect: 'impala',
-            containsKeywords: ['COMMENT', 'CACHED IN'],
+            dialect: 'hive',
             expectedResult: {
-              lowerCase: false
+              lowerCase: false,
+              suggestKeywords: ['AS']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) LOCATION \'/baa\' |"', function () {
+        it('should not suggest keywords for "CREATE TEMPORARY FUNCTION boo AS \'boo.baa\' |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) LOCATION \'/baa\' ',
+            beforeCursor: 'CREATE TEMPORARY FUNCTION boo AS \'boo.baa\' ',
             afterCursor: '',
-            dialect: 'impala',
+            dialect: 'hive',
             expectedResult: {
-              lowerCase: false,
-              suggestKeywords: ['TBLPROPERTIES', 'CACHED IN', 'AS']
+              lowerCase: false
             }
           });
         });
+      });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) PARTITIONED |"', function () {
+      describe('Impala specific', function () {
+        it('should handle "CREATE FUNCTION foo.boo(INT, BOOLEAN) RETURNS INT LOCATION \'/boo\' SYMBOL=\'baaa\'; |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) PARTITIONED ',
+            beforeCursor: 'CREATE FUNCTION boo(INT, BOOLEAN) RETURNS INT LOCATION \'/boo\' SYMBOL=\'baaa\'; ',
             afterCursor: '',
             dialect: 'impala',
+            containsKeywords: ['SELECT'],
             expectedResult: {
-              lowerCase: false,
-              suggestKeywords: ['BY']
+              lowerCase: false
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) PARTITIONED BY (boo |"', function () {
+        it('should handle "CREATE AGGREGATE FUNCTION baa.boo(INT, DOUBLE) RETURNS INT LOCATION \'/boo\' INIT_FN=\'cos\' UPDATE_FN=\'sin\' ' +
+            'MERGE_FN=\'cos\' PREPARE_FN=\'cos\' CLOSE_FN=\'cos\' SERIALIZE_FN=\'cos\' FINALIZE_FN=\'cos\'; |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) PARTITIONED BY (boo ',
+            beforeCursor: 'CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' INIT_FN=\'cos\' UPDATE_FN=\'sin\' MERGE_FN=\'cos\' PREPARE_FN=\'cos\' CLOSE_FN=\'cos\' SERIALIZE_FN=\'cos\' FINALIZE_FN=\'cos\'; ',
             afterCursor: '',
             dialect: 'impala',
-            containsKeywords: ['INT'],
+            containsKeywords: ['SELECT'],
             expectedResult: {
               lowerCase: false
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) WITH |"', function () {
+        it('should suggest keywords for "CREATE AGGREGATE |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) WITH ',
+            beforeCursor: 'CREATE AGGREGATE ',
             afterCursor: '',
             dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['SERDEPROPERTIES']
+              suggestKeywords: ['FUNCTION']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) PARTITIONED BY (boo INT, baa BIGINT |, boo INT) AS SELECT * FROM baa;"', function () {
+        it('should suggest keywords for "CREATE AGGREGATE FUNCTION |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) PARTITIONED BY (boo INT, baa BIGINT ',
-            afterCursor: ', boo INT) AS SELECT * FROM baa;',
+            beforeCursor: 'CREATE AGGREGATE FUNCTION ',
+            afterCursor: '',
             dialect: 'impala',
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['COMMENT']
+              suggestKeywords: ['IF NOT EXISTS'],
+              suggestDatabases: { appendDot: true }
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) STORED |"', function () {
+        it('should suggest keywords for "CREATE AGGREGATE FUNCTION IF |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) STORED ',
+            beforeCursor: 'CREATE AGGREGATE FUNCTION IF ',
             afterCursor: '',
             dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['AS']
+              suggestKeywords: ['NOT EXISTS']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) STORED |"', function () {
+        it('should suggest keywords for "CREATE AGGREGATE FUNCTION IF NOT |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) STORED AS ',
+            beforeCursor: 'CREATE AGGREGATE FUNCTION IF NOT ',
             afterCursor: '',
             dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['AVRO', 'PARQUET', 'RCFILE', 'SEQUENCEFILE', 'TEXTFILE']
+              suggestKeywords: ['EXISTS']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) ROW |"', function () {
+        it('should suggest keywords for "CREATE AGGREGATE FUNCTION boo(|"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) ROW ',
+            beforeCursor: 'CREATE AGGREGATE FUNCTION boo(',
             afterCursor: '',
             dialect: 'impala',
+            containsKeywords: ['INT'],
             expectedResult: {
-              lowerCase: false,
-              suggestKeywords: ['FORMAT']
+              lowerCase: false
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT |"', function () {
+        it('should suggest keywords for "CREATE AGGREGATE FUNCTION boo() |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT ',
+            beforeCursor: 'CREATE AGGREGATE FUNCTION boo() ',
             afterCursor: '',
             dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['DELIMITED']
+              suggestKeywords: ['RETURNS']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT DELIMITED |"', function () {
+        it('should suggest keywords for "CREATE AGGREGATE FUNCTION boo() RETURNS |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT DELIMITED ',
+            beforeCursor: 'CREATE AGGREGATE FUNCTION boo() RETURNS ',
             afterCursor: '',
             dialect: 'impala',
-            containsKeywords: ['AS', 'FIELDS TERMINATED BY', 'LINES TERMINATED BY' ],
-            doestNotContainKeywords: ['ROW FORMAT'],
+            containsKeywords: ['INT'],
             expectedResult: {
               lowerCase: false
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT DELIMITED FIELDS |"', function () {
+        it('should suggest keywords for "CREATE AGGREGATE FUNCTION boo() RETURNS INT |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT DELIMITED FIELDS ',
+            beforeCursor: 'CREATE AGGREGATE FUNCTION boo() RETURNS INT ',
             afterCursor: '',
             dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['TERMINATED BY']
+              suggestKeywords: ['LOCATION']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT DELIMITED FIELDS TERMINATED |"', function () {
+        it('should suggest keywords for "CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT DELIMITED FIELDS TERMINATED ',
+            beforeCursor: 'CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' ',
             afterCursor: '',
             dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['BY']
+              suggestKeywords: ['INIT_FN', 'UPDATE_FN']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT DELIMITED FIELDS TERMINATED BY \'b\' |"', function () {
+        it('should suggest functions for "CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' INIT_FN=\'|"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT DELIMITED FIELDS TERMINATED BY \'b\' ',
+            beforeCursor: 'CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' INIT_FN=\'',
             afterCursor: '',
             dialect: 'impala',
-            containsKeywords: ['AS', 'LINES TERMINATED BY' ],
-            doestNotContainKeywords: ['FIELDS TERMINATED BY', 'ROW FORMAT'],
             expectedResult: {
-              lowerCase: false
+              lowerCase: false,
+              suggestAnalyticFunctions: true,
+              suggestAggregateFunctions: true,
+              suggestFunctions: {}
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT DELIMITED FIELDS TERMINATED BY \'b\' LINES TERMINATED BY \'c\' |"', function () {
+        it('should suggest keywords for "CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' INIT_FN=\'cos\' |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT DELIMITED FIELDS TERMINATED BY \'b\' LINES TERMINATED BY \'c\' ',
+            beforeCursor: 'CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' INIT_FN=\'cos\' ',
             afterCursor: '',
             dialect: 'impala',
-            containsKeywords: ['AS' ],
-            doestNotContainKeywords: ['FIELDS TERMINATED BY', 'LINES TERMINATED BY', 'ROW FORMAT'],
             expectedResult: {
-              lowerCase: false
+              lowerCase: false,
+              suggestKeywords: ['UPDATE_FN']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT DELIMITED LINES TERMINATED |"', function () {
+        it('should suggest functions for "CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' INIT_FN=\'cos\' UPDATE_FN=\'|"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT DELIMITED LINES TERMINATED ',
+            beforeCursor: 'CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' INIT_FN=\'cos\' UPDATE_FN=\'',
             afterCursor: '',
             dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['BY']
+              suggestAnalyticFunctions: true,
+              suggestAggregateFunctions: true,
+              suggestFunctions: {}
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT DELIMITED LINES TERMINATED BY \'z\' STORED AS |"', function () {
+        it('should suggest keywords for "CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' INIT_FN=\'cos\' UPDATE_FN=\'sin\' |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT DELIMITED LINES TERMINATED BY \'z\' STORED AS ',
+            beforeCursor: 'CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' INIT_FN=\'cos\' UPDATE_FN=\'sin\' ',
             afterCursor: '',
             dialect: 'impala',
-            containsKeywords: ['PARQUET'],
-            doesNotContainKeywords: ['ORC'],
             expectedResult: {
-              lowerCase: false
+              lowerCase: false,
+              suggestKeywords: ['MERGE_FN']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) CACHED |"', function () {
+        it('should suggest keywords for "CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' INIT_FN=\'cos\' UPDATE_FN=\'sin\' MERGE_FN=\'tan\' ' +
+            'PREPARE_FN=\'boo\' SERIALIZE_FN=\'baa\' |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) CACHED ',
+            beforeCursor: 'CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' INIT_FN=\'cos\' UPDATE_FN=\'sin\' MERGE_FN=\'tan\' PREPARE_FN=\'boo\' SERIALIZE_FN=\'baa\' ',
             afterCursor: '',
             dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['IN']
+              suggestKeywords: ['FINALIZE_FN']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE ... TABLE ... PARTITIONED BY ... ROW FORMAT ... CACHED |"', function () {
+        it('should suggest keywords for "CREATE FUNCTION |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE EXTERNAL TABLE IF NOT EXISTS dbOne.tableName (id INT, col2 STRING COMMENT \'booo\', col3 BIGINT) ' +
-            'COMMENT \'Table comment...\' PARTITIONED BY (boo DOUBLE COMMENT \'booo boo\', baa INT) ' +
-            'WITH SERDEPROPERTIES ( \'key\' = \'value\', \'key2\' = \'value 2\' ) ' +
-            'ROW FORMAT DELIMITED FIELDS TERMINATED BY \'a\' ESCAPED BY \'c\' LINES TERMINATED BY \'q\' STORED AS PARQUET ' +
-            'LOCATION \'/baa/baa\' TBLPROPERTIES (\'key\' = \'value\', \'key2\' = \'value 2\') ' +
-            'CACHED ',
+            beforeCursor: 'CREATE FUNCTION ',
             afterCursor: '',
             dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['IN']
+              suggestKeywords: ['IF NOT EXISTS'],
+              suggestDatabases: { appendDot: true }
             }
           });
         });
 
-        it('should suggest keywords for "CREATE ... TABLE ... LIKE PARQUET ... PARTITIONED BY ... ROW FORMAT ... CACHED |"', function () {
+        it('should suggest keywords for "CREATE FUNCTION IF |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE EXTERNAL TABLE IF NOT EXISTS dbOne.tableName LIKE PARQUET \'/boo/baa\' ' +
-            'COMMENT \'Table comment...\' PARTITIONED BY (boo DOUBLE COMMENT \'booo boo\', baa INT) ' +
-            'WITH SERDEPROPERTIES ( \'key\' = \'value\', \'key2\' = \'value 2\' ) ' +
-            'ROW FORMAT DELIMITED FIELDS TERMINATED BY \'a\' ESCAPED BY \'c\' LINES TERMINATED BY \'q\' STORED AS PARQUET ' +
-            'LOCATION \'/baa/baa\' TBLPROPERTIES (\'key\' = \'value\', \'key2\' = \'value 2\') ' +
-            'CACHED ',
+            beforeCursor: 'CREATE FUNCTION IF ',
             afterCursor: '',
             dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['IN']
+              suggestKeywords: ['NOT EXISTS']
             }
           });
         });
 
-        it('should suggest tables for "CREATE EXTERNAL TABLE IF NOT EXISTS dbOne.tableName LIKE boo|"', function () {
+        it('should suggest keywords for "CREATE FUNCTION IF NOT |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE EXTERNAL TABLE IF NOT EXISTS dbOne.tableName LIKE boo',
+            beforeCursor: 'CREATE FUNCTION IF NOT ',
             afterCursor: '',
             dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['PARQUET'],
-              suggestTables: {},
-              suggestDatabases: {
-                appendDot: true
-              }
+              suggestKeywords: ['EXISTS']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE EXTERNAL TABLE IF NOT EXISTS dbOne.tableName LIKE boo.baa COMMENT \'Table comment...\' STORED |"', function () {
+        it('should suggest keywords for "CREATE FUNCTION boo(|"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE EXTERNAL TABLE IF NOT EXISTS dbOne.tableName LIKE boo.baa COMMENT \'Table comment...\' STORED ',
+            beforeCursor: 'CREATE FUNCTION boo(',
             afterCursor: '',
             dialect: 'impala',
+            containsKeywords: ['INT'],
+            doesNotContainKeywords: ['ARRAY<>', '...'],
             expectedResult: {
-              lowerCase: false,
-              suggestKeywords: ['AS']
+              lowerCase: false
             }
           });
         });
 
-        it('should suggest keywords for "CREATE ... TABLE ... ROW FORMAT ... CACHED IN ... AS |"', function () {
+        it('should suggest keywords for "CREATE FUNCTION boo(INT, BOOLEAN |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE dbOne.tableName ' +
-            'COMMENT \'Table comment...\' ' +
-            'WITH SERDEPROPERTIES ( \'key\' = \'value\', \'key2\' = \'value 2\' ) ' +
-            'ROW FORMAT DELIMITED FIELDS TERMINATED BY \'a\' ESCAPED BY \'c\' LINES TERMINATED BY \'q\' STORED AS PARQUET ' +
-            'LOCATION \'/baa/baa\' TBLPROPERTIES (\'key\' = \'value\', \'key2\' = \'value 2\') ' +
-            'CACHED IN \'boo\' AS ',
+            beforeCursor: 'CREATE FUNCTION boo(INT, BOOLEAN ',
             afterCursor: '',
             dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['SELECT']
+              suggestKeywords: ['...']
             }
           });
         });
 
-        it('should handle "create table four_k as select 4096 as x;|"', function () {
+        it('should not suggest keywords for "CREATE FUNCTION boo(INT |, BOOLEAN"', function () {
           assertAutoComplete({
-            beforeCursor: 'create table four_k as select 4096 as x;',
-            afterCursor: '',
+            beforeCursor: 'CREATE FUNCTION boo(INT ',
+            afterCursor: ', BOOLEAN',
             dialect: 'impala',
-            containsKeywords: ['SELECT'],
-            noErrors: true,
             expectedResult: {
-              lowerCase: true
+              lowerCase: false
             }
           });
         });
-      });
 
-      describe('Hive specific', function () {
-        it('should suggest keywords for "CREATE EXTERNAL |"', function () {
+        it('should suggest keywords for "CREATE FUNCTION boo(INT, BOOLEAN, |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE EXTERNAL ',
+            beforeCursor: 'CREATE FUNCTION  boo(INT, BOOLEAN, ',
             afterCursor: '',
-            dialect: 'hive',
+            dialect: 'impala',
+            containsKeywords: ['INT'],
+            doesNotContainKeywords: ['ARRAY<>', '...'],
             expectedResult: {
-              lowerCase: false,
-              suggestKeywords: ['TABLE']
+              lowerCase: false
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TEMPORARY |"', function () {
+        it('should suggest keywords for "CREATE FUNCTION boo(INT, BOOLEAN, STRING |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TEMPORARY ',
+            beforeCursor: 'CREATE FUNCTION  boo(INT, BOOLEAN, STRING ',
             afterCursor: '',
-            dialect: 'hive',
+            dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['EXTERNAL TABLE', 'FUNCTION', 'TABLE']
+              suggestKeywords: ['...']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TEMPORARY EXTERNAL |"', function () {
+        it('should suggest keywords for "CREATE FUNCTION boo(INT, BOOLEAN) |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TEMPORARY EXTERNAL ',
+            beforeCursor: 'CREATE FUNCTION boo(INT, BOOLEAN) ',
             afterCursor: '',
-            dialect: 'hive',
+            dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['TABLE']
+              suggestKeywords: ['RETURNS']
             }
           });
         });
 
-        it('should suggest tables for "CREATE TEMPORARY TABLE foo.boo |"', function () {
+        it('should suggest keywords for "CREATE FUNCTION boo(INT, BOOLEAN) RETURNS |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TEMPORARY TABLE foo.boo ',
+            beforeCursor: 'CREATE FUNCTION boo(INT, BOOLEAN) RETURNS ',
             afterCursor: '',
-            dialect: 'hive',
+            dialect: 'impala',
+            containsKeywords: ['INT'],
             expectedResult: {
-              lowerCase: false,
-              suggestKeywords: ['LIKE']
+              lowerCase: false
             }
           });
         });
 
-        it('should suggest tables for "CREATE TABLE boo LIKE |"', function () {
+        it('should suggest keywords for "CREATE FUNCTION boo(INT, BOOLEAN) RETURNS INT |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE boo LIKE dbOne.',
+            beforeCursor: 'CREATE FUNCTION boo(INT, BOOLEAN) RETURNS INT ',
             afterCursor: '',
-            dialect: 'hive',
+            dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestTables: { database: 'dbOne' }
+              suggestKeywords: ['LOCATION']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE EXTERNAL TABLE foo (id int |"', function () {
+        it('should suggest hdfs for "CREATE FUNCTION boo(INT, BOOLEAN) RETURNS INT LOCATION \'|"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE EXTERNAL TABLE foo (id int ',
+            beforeCursor: 'CREATE FUNCTION boo(INT, BOOLEAN) RETURNS INT LOCATION \'',
             afterCursor: '',
-            dialect: 'hive',
+            dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['COMMENT']
+              suggestHdfs: { path: '' }
             }
           });
         });
 
-        it('should suggest keywords for "CREATE EXTERNAL TABLE foo (id int) |"', function () {
+        it('should suggest keywords for "CREATE FUNCTION boo(INT, BOOLEAN) RETURNS INT LOCATION \'/boo\' |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE EXTERNAL TABLE foo (id int) ',
+            beforeCursor: 'CREATE FUNCTION boo(INT, BOOLEAN) RETURNS INT LOCATION \'/boo\' ',
             afterCursor: '',
-            dialect: 'hive',
-            containsKeywords: ['COMMENT', 'CLUSTERED BY'],
+            dialect: 'impala',
             expectedResult: {
-              lowerCase: false
+              lowerCase: false,
+              suggestKeywords: ['SYMBOL']
             }
           });
         });
+      });
+    });
 
-        it('should suggest keywords for "CREATE EXTERNAL TABLE foo (id int) COMMENT \'boo\' |"', function () {
-          assertAutoComplete({
-            beforeCursor: 'CREATE EXTERNAL TABLE foo (id int) COMMENT \'boo\' ',
-            afterCursor: '',
-            dialect: 'hive',
-            containsKeywords: ['PARTITIONED BY', 'CLUSTERED BY'],
-            doesNotContainKeywords: ['COMMENT'],
-            expectedResult: {
-              lowerCase: false
-            }
-          });
+    describe('CREATE INDEX', function () {
+      it('should handle "CREATE INDEX bla ON TABLE db.tbl (a, b, c) AS \'COMPACT\' WITH DEFERRED REBUILD IDXPROPERTIES ("boo.baa"="ble", "blaa"=1) IN TABLE dbTwo.tblTwo ROW FORMAT DELIMITED STORED AS PARQUET LOCATION \'/baa/boo\' TBLPROPERTIES ("bla"=1) COMMENT \"booo\"; |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE INDEX bla ON TABLE db.tbl (a, b, c) AS \'COMPACT\' WITH DEFERRED REBUILD IDXPROPERTIES ' +
+          '("boo.baa"="ble", "blaa"=1) IN TABLE dbTwo.tblTwo ROW FORMAT DELIMITED STORED AS PARQUET LOCATION \'/baa/boo\' ' +
+          'TBLPROPERTIES ("bla"=1) COMMENT \"booo\"; ',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          containsKeywords: ['SELECT'],
+          expectedResult: {
+            lowerCase: false
+          }
         });
+      });
 
-        it('should suggest keywords for "CREATE EXTERNAL TABLE foo (id int) PARTITIONED BY (boo INT) |"', function () {
-          assertAutoComplete({
-            beforeCursor: 'CREATE EXTERNAL TABLE foo (id int) PARTITIONED BY (boo INT) ',
-            afterCursor: '',
-            dialect: 'hive',
-            containsKeywords: ['CLUSTERED BY', 'SKEWED BY'],
-            doesNotContainKeywords: ['COMMENT', 'PARTITIONED BY'],
-            expectedResult: {
-              lowerCase: false
-            }
-          });
+      it('should handle "CREATE INDEX bla ON TABLE db.tbl (a, b, c) AS \'boo.baa.bitmap\'; |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE INDEX bla ON TABLE db.tbl (a, b, c) AS \'boo.baa.bitmap\'; ',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          containsKeywords: ['SELECT'],
+          expectedResult: {
+            lowerCase: false
+          }
         });
+      });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) CLUSTERED BY (a, b, c) INTO 10 BUCKETS |"', function () {
-          assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) CLUSTERED BY (a, b, c) INTO 10 BUCKETS ',
-            afterCursor: '',
-            dialect: 'hive',
-            containsKeywords: ['SKEWED BY'],
-            doesNotContainKeywords: ['CLUSTERED BY', 'PARTITIONED BY'],
-            expectedResult: {
-              lowerCase: false
-            }
-          });
+      it('should suggest keywords for "CREATE INDEX bla  |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE INDEX bla ',
+          afterCursor: '',
+          dialect: 'hive',
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['ON TABLE']
+          }
         });
+      });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) LOCATION \'/baa\' |"', function () {
-          assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) LOCATION \'/baa\' ',
-            afterCursor: '',
-            dialect: 'hive',
-            expectedResult: {
-              lowerCase: false,
-              suggestKeywords: ['TBLPROPERTIES', 'AS']
-            }
-          });
+      it('should suggest keywords for "CREATE INDEX bla ON |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE INDEX bla ON ',
+          afterCursor: '',
+          dialect: 'hive',
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['TABLE']
+          }
         });
+      });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) CLUSTERED |"', function () {
-          assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) CLUSTERED ',
-            afterCursor: '',
-            dialect: 'hive',
-            expectedResult: {
-              lowerCase: false,
-              suggestKeywords: ['BY']
-            }
-          });
+      it('should suggest tables for "CREATE INDEX bla ON TABLE |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE INDEX bla ON TABLE ',
+          afterCursor: '',
+          dialect: 'hive',
+          expectedResult: {
+            lowerCase: false,
+            suggestTables: {},
+            suggestDatabases: { appendDot: true }
+          }
         });
+      });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) CLUSTERED BY (a, b, c) |"', function () {
-          assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) CLUSTERED BY (a, b, c) ',
-            afterCursor: '',
-            dialect: 'hive',
-            expectedResult: {
-              lowerCase: false,
-              suggestKeywords: ['SORTED BY', 'INTO']
-            }
-          });
+      it('should suggest columns for "CREATE INDEX bla ON TABLE foo.bar (|"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE INDEX bla ON TABLE foo.bar (',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestColumns: { database: 'foo', table: 'bar' }
+          }
+        });
+      });
+
+      it('should suggest columns for "CREATE INDEX bla ON TABLE foo.bar (a, b, c, |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE INDEX bla ON TABLE foo.bar (a, b, c, ',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestColumns: { database: 'foo', table: 'bar' }
+          }
+        });
+      });
+
+      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) ',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['AS']
+          }
+        });
+      });
+
+      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS ',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['\'BITMAP\'', '\'COMPACT\'']
+          }
+        });
+      });
+
+      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BIT|"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BIT',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['\'BITMAP\'', '\'COMPACT\'']
+          }
+        });
+      });
+
+      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' ',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['WITH DEFERRED REBUILD', 'IDXPROPERTIES', 'IN TABLE', 'ROW FORMAT', 'STORED AS', 'STORED BY', 'LOCATION', 'TBLPROPERTIES', 'COMMENT']
+          }
+        });
+      });
+
+      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' WITH |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' WITH ',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['DEFERRED REBUILD']
+          }
+        });
+      });
+
+      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' WITH DEFERRED |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' WITH DEFERRED ',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['REBUILD']
+          }
+        });
+      });
+
+      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' WITH DEFERRED REBUILD |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' WITH DEFERRED REBUILD ',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['IDXPROPERTIES', 'IN TABLE', 'ROW FORMAT', 'STORED AS', 'STORED BY', 'LOCATION', 'TBLPROPERTIES', 'COMMENT']
+          }
+        });
+      });
+
+      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' IDXPROPERTIES ("baa"="boo") |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' IDXPROPERTIES ("baa"="boo") ',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['IN TABLE', 'ROW FORMAT', 'STORED AS', 'STORED BY', 'LOCATION', 'TBLPROPERTIES', 'COMMENT']
+          }
+        });
+      });
+
+      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' IN |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' IN ',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['TABLE']
+          }
+        });
+      });
+
+      it('should suggest tables for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' IN TABLE |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' IN TABLE ',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestTables: {},
+            suggestDatabases: { appendDot: true }
+          }
+        });
+      });
+
+      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' IN TABLE boo |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' IN TABLE boo ',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['ROW FORMAT', 'STORED AS', 'STORED BY', 'LOCATION', 'TBLPROPERTIES', 'COMMENT']
+          }
+        });
+      });
+
+      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' ROW |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' ROW ',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['FORMAT']
+          }
+        });
+      });
+
+      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' ROW FORMAT |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' ROW FORMAT ',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['DELIMITED', 'SERDE']
+          }
+        });
+      });
+
+      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' ROW FORMAT DELIMITED |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' ROW FORMAT DELIMITED ',
+          afterCursor: '',
+          dialect: 'hive',
+          containsKeywords: ['MAP KEYS TERMINATED BY', 'NULL DEFINED AS', 'LOCATION', 'TBLPROPERTIES', 'COMMENT'],
+          doesNotContainKeywords: ['AS'],
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false
+          }
+        });
+      });
+
+      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' ROW FORMAT DELIMITED NULL |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' ROW FORMAT DELIMITED NULL ',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['DEFINED AS']
+          }
+        });
+      });
+
+      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'COMPACT\' ROW FORMAT DELIMITED STORED |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'COMPACT\' ROW FORMAT DELIMITED STORED ',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['AS']
+          }
+        });
+      });
+
+      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'COMPACT\' STORED |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'COMPACT\' STORED ',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['AS', 'BY']
+          }
+        });
+      });
+
+      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'COMPACT\' ROW FORMAT DELIMITED STORED AS |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'COMPACT\' ROW FORMAT DELIMITED STORED AS ',
+          afterCursor: '',
+          dialect: 'hive',
+          containsKeywords: ['ORC', 'PARQUET'],
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false
+          }
+        });
+      });
+
+      it('should suggest hdfs for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'COMPACT\' LOCATION \'|"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'COMPACT\' LOCATION \'',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestHdfs: { path: '' }
+          }
+        });
+      });
+
+      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'COMPACT\' LOCATION \'/baa\' |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'COMPACT\' LOCATION \'/baa\' ',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['TBLPROPERTIES', 'COMMENT']
+          }
+        });
+      });
+
+      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'COMPACT\' TBLPROPERTIES ("baa"="boo") |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'COMPACT\' TBLPROPERTIES ("baa"="boo") ',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['COMMENT']
+          }
+        });
+      });
+    });
+
+    describe('CREATE ROLE', function () {
+      it('should handle "CREATE ROLE boo; |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE ROLE boo; ',
+          afterCursor: '',
+          containsKeywords: ['SELECT'],
+          expectedResult: {
+            lowerCase: false
+          }
+        });
+      });
+    });
+
+    describe('CREATE TABLE', function () {
+      it('should suggest keywords for "CREATE TABLE |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE TABLE ',
+          afterCursor: '',
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['IF NOT EXISTS']
+          }
+        });
+      });
+
+      it('should suggest keywords for "CREATE TABLE IF |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE TABLE IF ',
+          afterCursor: '',
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['NOT EXISTS']
+          }
+        });
+      });
+
+      it('should suggest keywords for "CREATE TABLE IF NOT |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE TABLE IF NOT ',
+          afterCursor: '',
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['EXISTS']
+          }
+        });
+      });
+
+      it('should handle for "CREATE TABLE foo (id INT);|"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE TABLE foo (id INT);',
+          afterCursor: '',
+          containsKeywords: ['SELECT'],
+          expectedResult: {
+            lowerCase: false
+          }
+        });
+      });
+
+      it('should suggest keywords for "CREATE TABLE foo (id |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE TABLE foo (id ',
+          afterCursor: '',
+          containsKeywords: ['BOOLEAN'],
+          expectedResult: {
+            lowerCase: false
+          }
+        });
+      });
+
+      it('should suggest keywords for "CREATE TABLE foo (id INT, some FLOAT, bar |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'CREATE TABLE foo (id INT, some FLOAT, bar ',
+          afterCursor: '',
+          containsKeywords: ['BOOLEAN'],
+          expectedResult: {
+            lowerCase: false
+          }
         });
+      });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) CLUSTERED (a, b, c) SORTED |"', function () {
+      describe('Impala specific', function () {
+        it('should suggest keywords for "CREATE EXTERNAL |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) CLUSTERED BY (a, b, c) SORTED ',
+            beforeCursor: 'CREATE EXTERNAL ',
             afterCursor: '',
-            dialect: 'hive',
+            dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['BY']
+              suggestKeywords: ['TABLE']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) CLUSTERED (a, b, c) SORTED BY (a |"', function () {
+        it('should suggest keywords for "CREATE TABLE boo |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) CLUSTERED BY (a, b, c) SORTED BY (a ',
+            beforeCursor: 'CREATE TABLE boo ',
             afterCursor: '',
-            dialect: 'hive',
+            dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['ASC', 'DESC']
+              suggestKeywords: ['LIKE', 'LIKE PARQUET']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) CLUSTERED (a, b, c) SORTED BY (a ASC, b |, c)"', function () {
+        it('should suggest tables for "CREATE TABLE boo LIKE |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) CLUSTERED BY (a, b, c) SORTED BY (a ASC, b ',
-            afterCursor: ', c)',
-            dialect: 'hive',
+            beforeCursor: 'CREATE TABLE boo LIKE ',
+            afterCursor: '',
+            dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['ASC', 'DESC']
+              suggestTables: {},
+              suggestDatabases: { appendDot: true },
+              suggestKeywords: ['PARQUET']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) CLUSTERED (a, b, c) SORTED BY (a ASC, b DESC, c) |"', function () {
+        it('should suggest tables for "CREATE TABLE boo LIKE dbOne.|"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) CLUSTERED BY (a, b, c) SORTED BY (a ASC, b DESC, c) ',
+            beforeCursor: 'CREATE TABLE boo LIKE dbOne.',
             afterCursor: '',
-            dialect: 'hive',
+            dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['INTO']
+              suggestTables: { database: 'dbOne' }
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) CLUSTERED (a, b, c) INTO 10 |"', function () {
+        it('should suggest hdfs for "CREATE TABLE boo LIKE PARQUET \'|"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) CLUSTERED BY (a, b, c) INTO 10 ',
+            beforeCursor: 'CREATE TABLE boo LIKE PARQUET \'',
             afterCursor: '',
-            dialect: 'hive',
+            dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['BUCKETS']
+              suggestHdfs: { path: ''}
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) CLUSTERED (a, b, c) SORTED BY (a ASC, b DESC, c) INTO 10 |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) LOCATION \'|"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) CLUSTERED BY (a, b, c) SORTED BY (a ASC, b DESC, c) INTO 10 ',
+            beforeCursor: 'CREATE TABLE boo LOCATION \'',
             afterCursor: '',
-            dialect: 'hive',
+            dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['BUCKETS']
+              suggestHdfs: { path: ''}
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) SKEWED |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo LIKE PARQUET \'/blabla/\' |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) SKEWED ',
+            beforeCursor: 'CREATE TABLE foo LIKE PARQUET \'/blabla/\' ',
             afterCursor: '',
-            dialect: 'hive',
+            dialect: 'impala',
+            containsKeywords: ['COMMENT', 'CACHED IN'],
             expectedResult: {
-              lowerCase: false,
-              suggestKeywords: ['BY']
+              lowerCase: false
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) SKEWED BY (a, b, c) |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) LOCATION \'/baa\' |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) SKEWED BY (a, b, c) ',
+            beforeCursor: 'CREATE TABLE foo (id int) LOCATION \'/baa\' ',
             afterCursor: '',
-            dialect: 'hive',
+            dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['ON']
+              suggestKeywords: ['TBLPROPERTIES', 'CACHED IN', 'AS']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) SKEWED BY (a, b, c) ON ((1,2), (2,3)) |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) PARTITIONED |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) SKEWED BY (a, b, c) ON ((1,2), (2,3)) ',
+            beforeCursor: 'CREATE TABLE foo (id int) PARTITIONED ',
             afterCursor: '',
-            dialect: 'hive',
-            containsKeywords: ['STORED AS DIRECTORIES'],
+            dialect: 'impala',
             expectedResult: {
-              lowerCase: false
+              lowerCase: false,
+              suggestKeywords: ['BY']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) STORED |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) PARTITIONED BY (boo |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) STORED ',
+            beforeCursor: 'CREATE TABLE foo (id int) PARTITIONED BY (boo ',
             afterCursor: '',
-            dialect: 'hive',
+            dialect: 'impala',
+            containsKeywords: ['INT'],
             expectedResult: {
-              lowerCase: false,
-              suggestKeywords: ['AS', 'BY']
+              lowerCase: false
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) STORED AS |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) WITH |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) STORED AS ',
+            beforeCursor: 'CREATE TABLE foo (id int) WITH ',
             afterCursor: '',
-            dialect: 'hive',
+            dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['AVRO', 'INPUTFORMAT', 'ORC', 'PARQUET', 'RCFILE', 'SEQUENCEFILE', 'TEXTFILE']
+              suggestKeywords: ['SERDEPROPERTIES']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) ROW |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) PARTITIONED BY (boo INT, baa BIGINT |, boo INT) AS SELECT * FROM baa;"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) ROW ',
-            afterCursor: '',
-            dialect: 'hive',
+            beforeCursor: 'CREATE TABLE foo (id int) PARTITIONED BY (boo INT, baa BIGINT ',
+            afterCursor: ', boo INT) AS SELECT * FROM baa;',
+            dialect: 'impala',
+            hasLocations: true,
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['FORMAT']
+              suggestKeywords: ['COMMENT']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) STORED |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT ',
+            beforeCursor: 'CREATE TABLE foo (id int) STORED ',
             afterCursor: '',
-            dialect: 'hive',
+            dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['DELIMITED', 'SERDE']
+              suggestKeywords: ['AS']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT DELIMITED |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) STORED |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT DELIMITED ',
+            beforeCursor: 'CREATE TABLE foo (id int) STORED AS ',
             afterCursor: '',
-            dialect: 'hive',
+            dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['FIELDS TERMINATED BY', 'COLLECTION ITEMS TERMINATED BY', 'MAP KEYS TERMINATED BY', 'LINES TERMINATED BY', 'NULL DEFINED AS', 'STORED AS', 'LOCATION', 'TBLPROPERTIES', 'AS']
+              suggestKeywords: ['AVRO', 'PARQUET', 'RCFILE', 'SEQUENCEFILE', 'TEXTFILE']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT DELIMITED MAP |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) ROW |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT DELIMITED MAP ',
+            beforeCursor: 'CREATE TABLE foo (id int) ROW ',
             afterCursor: '',
-            dialect: 'hive',
+            dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['KEYS TERMINATED BY']
+              suggestKeywords: ['FORMAT']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT DELIMITED MAP KEYS TERMINATED BY \'a\' NULL DEFINED |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT DELIMITED MAP KEYS TERMINATED BY \'a\' NULL DEFINED ',
+            beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT ',
             afterCursor: '',
-            dialect: 'hive',
+            dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['AS']
+              suggestKeywords: ['DELIMITED']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT DELIMITED MAP KEYS TERMINATED BY \'a\' |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT DELIMITED |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT DELIMITED MAP KEYS TERMINATED BY \'a\' ',
+            beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT DELIMITED ',
             afterCursor: '',
-            dialect: 'hive',
-            containsKeywords: ['STORED AS'],
-            doesNotContainKeywords: ['STORED BY'],
+            dialect: 'impala',
+            containsKeywords: ['AS', 'FIELDS TERMINATED BY', 'LINES TERMINATED BY' ],
+            doestNotContainKeywords: ['ROW FORMAT'],
             expectedResult: {
               lowerCase: false
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT DELIMITED MAP KEYS TERMINATED BY \'a\' STORED |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT DELIMITED FIELDS |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT DELIMITED MAP KEYS TERMINATED BY \'a\' STORED ',
+            beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT DELIMITED FIELDS ',
             afterCursor: '',
-            dialect: 'hive',
+            dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['AS']
+              suggestKeywords: ['TERMINATED BY']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT DELIMITED MAP KEYS TERMINATED BY \'a\' STORED AS |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT DELIMITED FIELDS TERMINATED |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT DELIMITED MAP KEYS TERMINATED BY \'a\' STORED AS ',
+            beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT DELIMITED FIELDS TERMINATED ',
             afterCursor: '',
-            dialect: 'hive',
-            containsKeywords: ['ORC'],
+            dialect: 'impala',
             expectedResult: {
-              lowerCase: false
+              lowerCase: false,
+              suggestKeywords: ['BY']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) STORED BY \'handler\' |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT DELIMITED FIELDS TERMINATED BY \'b\' |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) STORED BY \'handler\' ',
+            beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT DELIMITED FIELDS TERMINATED BY \'b\' ',
             afterCursor: '',
-            dialect: 'hive',
-            containsKeywords: ['WITH SERDEPROPERTIES'],
-            doesNotContainKeywords: ['STORED BY'],
+            dialect: 'impala',
+            containsKeywords: ['AS', 'LINES TERMINATED BY' ],
+            doestNotContainKeywords: ['FIELDS TERMINATED BY', 'ROW FORMAT'],
             expectedResult: {
               lowerCase: false
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id int) STORED BY \'handler\' WITH |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT DELIMITED FIELDS TERMINATED BY \'b\' LINES TERMINATED BY \'c\' |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id int) STORED BY \'handler\' WITH ',
+            beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT DELIMITED FIELDS TERMINATED BY \'b\' LINES TERMINATED BY \'c\' ',
             afterCursor: '',
-            dialect: 'hive',
+            dialect: 'impala',
+            containsKeywords: ['AS' ],
+            doestNotContainKeywords: ['FIELDS TERMINATED BY', 'LINES TERMINATED BY', 'ROW FORMAT'],
             expectedResult: {
-              lowerCase: false,
-              suggestKeywords: ['SERDEPROPERTIES']
+              lowerCase: false
             }
           });
         });
 
-        it('should suggest keywords for "CREATE ... TABLE ... PARTITIONED BY ... ROW FORMAT ... AS |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT DELIMITED LINES TERMINATED |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TEMPORARY EXTERNAL TABLE IF NOT EXISTS db.foo (id INT COMMENT \'an int\', baa ARRAY<BIGINT>) COMMENT \'a table\' ' +
-              'PARTITIONED BY (boo DOUBLE, baa INT) ' +
-              'CLUSTERED BY (boo, baa) SORTED BY (boo ASC, baa) INTO 10 BUCKETS ' +
-              'SKEWED BY (a, b, c) ON ((\'val1\', \'val2\'), (1, 2, 3)) STORED AS DIRECTORIES ' +
-              'ROW FORMAT DELIMITED FIELDS TERMINATED BY \'b\' ESCAPED BY \'o\' COLLECTION ITEMS TERMINATED BY \'d\' ' +
-              'MAP KEYS TERMINATED BY \'a\' LINES TERMINATED BY \'a\' NULL DEFINED AS \'o\' ' +
-              'STORED AS ORC LOCATION \'/asdf/boo/\' TBLPROPERTIES ("comment"="boo") AS ',
+            beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT DELIMITED LINES TERMINATED ',
             afterCursor: '',
-            dialect: 'hive',
+            dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['SELECT']
+              suggestKeywords: ['BY']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE boo PARTITIONED BY ... STORED BY \'storage.handler\' WITH SERDEPROPERTIES ... AS |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT DELIMITED LINES TERMINATED BY \'z\' STORED AS |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE boo PARTITIONED BY (boo DOUBLE, baa INT) STORED BY \'storage.handler\' ' +
-              'WITH SERDEPROPERTIES (\'foo.bar\' = \'booo\', \'bar.foo\' = \'bla\') ' +
-              'LOCATION \'/asdf/boo/\' TBLPROPERTIES ("comment"="boo") AS ',
+            beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT DELIMITED LINES TERMINATED BY \'z\' STORED AS ',
             afterCursor: '',
-            dialect: 'hive',
-            expectedResult: {
-              lowerCase: false,
-              suggestKeywords: ['SELECT']
-            }
-          });
-        });
-
-        it('should suggest tables for "CREATE TEMPORARY EXTERNAL TABLE IF NOT EXISTS db.boo LIKE | LOCATION \'/some/loc\';"', function () {
-          assertAutoComplete({
-            beforeCursor: 'CREATE TEMPORARY EXTERNAL TABLE IF NOT EXISTS db.boo LIKE ',
-            afterCursor: ' LOCATION \'/some/loc\';',
-            dialect: 'hive',
+            dialect: 'impala',
+            containsKeywords: ['PARQUET'],
+            doesNotContainKeywords: ['ORC'],
             expectedResult: {
-              lowerCase: false,
-              suggestTables: {},
-              suggestDatabases: { appendDot: true }
+              lowerCase: false
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) CACHED |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id ',
+            beforeCursor: 'CREATE TABLE foo (id int) CACHED ',
             afterCursor: '',
-            dialect: 'hive',
-            containsKeywords: ['BIGINT', 'MAP<>'],
+            dialect: 'impala',
             expectedResult: {
-              lowerCase: false
+              lowerCase: false,
+              suggestKeywords: ['IN']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo(id |"', function () {
+        it('should suggest keywords for "CREATE ... TABLE ... PARTITIONED BY ... ROW FORMAT ... CACHED |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo(id ',
+            beforeCursor: 'CREATE EXTERNAL TABLE IF NOT EXISTS dbOne.tableName (id INT, col2 STRING COMMENT \'booo\', col3 BIGINT) ' +
+            'COMMENT \'Table comment...\' PARTITIONED BY (boo DOUBLE COMMENT \'booo boo\', baa INT) ' +
+            'WITH SERDEPROPERTIES ( \'key\' = \'value\', \'key2\' = \'value 2\' ) ' +
+            'ROW FORMAT DELIMITED FIELDS TERMINATED BY \'a\' ESCAPED BY \'c\' LINES TERMINATED BY \'q\' STORED AS PARQUET ' +
+            'LOCATION \'/baa/baa\' TBLPROPERTIES (\'key\' = \'value\', \'key2\' = \'value 2\') ' +
+            'CACHED ',
             afterCursor: '',
-            dialect: 'hive',
-            containsKeywords: ['BIGINT', 'MAP<>'],
+            dialect: 'impala',
             expectedResult: {
-              lowerCase: false
+              lowerCase: false,
+              suggestKeywords: ['IN']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (bla ARRAY<INT>, boo |"', function () {
+        it('should suggest keywords for "CREATE ... TABLE ... LIKE PARQUET ... PARTITIONED BY ... ROW FORMAT ... CACHED |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (bla ARRAY<INT>, boo ',
+            beforeCursor: 'CREATE EXTERNAL TABLE IF NOT EXISTS dbOne.tableName LIKE PARQUET \'/boo/baa\' ' +
+            'COMMENT \'Table comment...\' PARTITIONED BY (boo DOUBLE COMMENT \'booo boo\', baa INT) ' +
+            'WITH SERDEPROPERTIES ( \'key\' = \'value\', \'key2\' = \'value 2\' ) ' +
+            'ROW FORMAT DELIMITED FIELDS TERMINATED BY \'a\' ESCAPED BY \'c\' LINES TERMINATED BY \'q\' STORED AS PARQUET ' +
+            'LOCATION \'/baa/baa\' TBLPROPERTIES (\'key\' = \'value\', \'key2\' = \'value 2\') ' +
+            'CACHED ',
             afterCursor: '',
-            dialect: 'hive',
-            containsKeywords: ['BIGINT', 'MAP<>'],
+            dialect: 'impala',
             expectedResult: {
-              lowerCase: false
+              lowerCase: false,
+              suggestKeywords: ['IN']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (bla ARRAY<|"', function () {
+        it('should suggest tables for "CREATE EXTERNAL TABLE IF NOT EXISTS dbOne.tableName LIKE boo|"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (bla ARRAY<',
+            beforeCursor: 'CREATE EXTERNAL TABLE IF NOT EXISTS dbOne.tableName LIKE boo',
             afterCursor: '',
-            dialect: 'hive',
-            containsKeywords: ['BIGINT', 'MAP<>'],
+            dialect: 'impala',
             expectedResult: {
-              lowerCase: false
+              lowerCase: false,
+              suggestKeywords: ['PARQUET'],
+              suggestTables: {},
+              suggestDatabases: {
+                appendDot: true
+              }
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (bla MAP<|"', function () {
+        it('should suggest keywords for "CREATE EXTERNAL TABLE IF NOT EXISTS dbOne.tableName LIKE boo.baa COMMENT \'Table comment...\' STORED |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (bla MAP<',
+            beforeCursor: 'CREATE EXTERNAL TABLE IF NOT EXISTS dbOne.tableName LIKE boo.baa COMMENT \'Table comment...\' STORED ',
             afterCursor: '',
-            dialect: 'hive',
-            containsKeywords: ['BIGINT'],
-            doesNotContainKeywords: ['MAP<>'],
+            dialect: 'impala',
             expectedResult: {
-              lowerCase: false
+              lowerCase: false,
+              suggestKeywords: ['AS']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (bla MAP<STRING, STRING>, boo |"', function () {
+        it('should suggest keywords for "CREATE ... TABLE ... ROW FORMAT ... CACHED IN ... AS |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (bla MAP<STRING, STRING>, boo ',
+            beforeCursor: 'CREATE TABLE dbOne.tableName ' +
+            'COMMENT \'Table comment...\' ' +
+            'WITH SERDEPROPERTIES ( \'key\' = \'value\', \'key2\' = \'value 2\' ) ' +
+            'ROW FORMAT DELIMITED FIELDS TERMINATED BY \'a\' ESCAPED BY \'c\' LINES TERMINATED BY \'q\' STORED AS PARQUET ' +
+            'LOCATION \'/baa/baa\' TBLPROPERTIES (\'key\' = \'value\', \'key2\' = \'value 2\') ' +
+            'CACHED IN \'boo\' AS ',
             afterCursor: '',
-            dialect: 'hive',
-            containsKeywords: ['BIGINT'],
+            dialect: 'impala',
             expectedResult: {
-              lowerCase: false
+              lowerCase: false,
+              suggestKeywords: ['SELECT']
             }
           });
         });
 
-        it('should not suggest keywords for "CREATE TABLE boo (baa STRUCT<foo:INT, |"', function () {
+        it('should handle "create table four_k as select 4096 as x;|"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE boo (baa STRUCT<foo:INT, ',
+            beforeCursor: 'create table four_k as select 4096 as x;',
             afterCursor: '',
-            dialect: 'hive',
+            dialect: 'impala',
+            containsKeywords: ['SELECT'],
+            noErrors: true,
             expectedResult: {
-              lowerCase: false
+              lowerCase: true
             }
           });
         });
+      });
 
-        it('should suggest keywords for "CREATE TABLE foo (id INT, bla MAP<|, boo BIGINT, bla INT"', function () {
+      describe('Hive specific', function () {
+        it('should suggest keywords for "CREATE EXTERNAL |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id INT, bla MAP<',
-            afterCursor: ', boo BIGINT, bla INT)',
+            beforeCursor: 'CREATE EXTERNAL ',
+            afterCursor: '',
             dialect: 'hive',
-            containsKeywords: ['BIGINT'],
-            doesNotContainKeywords: ['MAP<>'],
             expectedResult: {
-              lowerCase: false
+              lowerCase: false,
+              suggestKeywords: ['TABLE']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id INT, bla MAP<|>, boo BIGINT, bla INT"', function () {
+        it('should suggest keywords for "CREATE TEMPORARY |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id INT, bla MAP<',
-            afterCursor: '>, boo BIGINT, bla INT)',
+            beforeCursor: 'CREATE TEMPORARY ',
+            afterCursor: '',
             dialect: 'hive',
-            containsKeywords: ['BIGINT'],
-            doesNotContainKeywords: ['MAP<>'],
             expectedResult: {
-              lowerCase: false
+              lowerCase: false,
+              suggestKeywords: ['EXTERNAL TABLE', 'FUNCTION', 'MACRO', 'TABLE']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (bla STRUCT<foo:|"', function () {
+        it('should suggest keywords for "CREATE TEMPORARY EXTERNAL |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (bla STRUCT<foo:',
+            beforeCursor: 'CREATE TEMPORARY EXTERNAL ',
             afterCursor: '',
             dialect: 'hive',
-            containsKeywords: ['BIGINT', 'MAP<>'],
             expectedResult: {
-              lowerCase: false
+              lowerCase: false,
+              suggestKeywords: ['TABLE']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (bla MAP<BIGINT, STRUCT<foo:ARRAY<|, bla DOUBLE"', function () {
+        it('should suggest tables for "CREATE TEMPORARY TABLE foo.boo |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (bla MAP<BIGINT, STRUCT<foo:ARRAY<',
-            afterCursor: ', bla DOUBLE',
+            beforeCursor: 'CREATE TEMPORARY TABLE foo.boo ',
+            afterCursor: '',
             dialect: 'hive',
-            containsKeywords: ['BIGINT', 'MAP<>'],
             expectedResult: {
-              lowerCase: false
+              lowerCase: false,
+              suggestKeywords: ['LIKE']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (bla MAP<BIGINT, STRUCT<boo: INT, foo:STRUCT<blo:DOUBLE |, bla:DOUBLE>"', function () {
+        it('should suggest tables for "CREATE TABLE boo LIKE |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (bla MAP<BIGINT, STRUCT<boo: INT, foo:STRUCT<blo:DOUBLE ',
-            afterCursor: ', bla:DOUBLE>',
+            beforeCursor: 'CREATE TABLE boo LIKE dbOne.',
+            afterCursor: '',
             dialect: 'hive',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['COMMENT']
+              suggestTables: { database: 'dbOne' }
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (bla MAP<|, STRUCT<boo: INT, foo:STRUCT<blo:DOUBLE, doo:VARCHAR, bla:DOUBLE>"', function () {
+        it('should suggest keywords for "CREATE EXTERNAL TABLE foo (id int |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (bla MAP<',
-            afterCursor: ', STRUCT<boo: INT, foo:STRUCT<blo:DOUBLE, doo:VARCHAR, bla:DOUBLE>',
+            beforeCursor: 'CREATE EXTERNAL TABLE foo (id int ',
+            afterCursor: '',
             dialect: 'hive',
-            containsKeywords: ['BIGINT'],
-            doesNotContainKeywords: ['MAP<>'],
             expectedResult: {
-              lowerCase: false
+              lowerCase: false,
+              suggestKeywords: ['COMMENT']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id INT, ba STRUCT<boo:INT COMMENT \'Some Comment\', bla:BIGINT>, bla MAP<INT,|>, boo BIGINT, bla INT"', function () {
+        it('should suggest keywords for "CREATE EXTERNAL TABLE foo (id int) |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id INT, ba STRUCT<boo:INT COMMENT \'Some Comment\', bla:BIGINT>, bla MAP<INT,',
-            afterCursor: '>, boo BIGINT, bla INT)',
+            beforeCursor: 'CREATE EXTERNAL TABLE foo (id int) ',
+            afterCursor: '',
             dialect: 'hive',
-            containsKeywords: ['BIGINT', 'MAP<>'],
+            containsKeywords: ['COMMENT', 'CLUSTERED BY'],
             expectedResult: {
               lowerCase: false
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (id UNIONTYPE<INT, BIGINT, |"', function () {
+        it('should suggest keywords for "CREATE EXTERNAL TABLE foo (id int) COMMENT \'boo\' |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (id UNIONTYPE<INT, BIGINT, ',
+            beforeCursor: 'CREATE EXTERNAL TABLE foo (id int) COMMENT \'boo\' ',
             afterCursor: '',
             dialect: 'hive',
-            containsKeywords: ['BIGINT', 'MAP<>'],
+            containsKeywords: ['PARTITIONED BY', 'CLUSTERED BY'],
+            doesNotContainKeywords: ['COMMENT'],
             expectedResult: {
               lowerCase: false
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TEMPORARY EXTERNAL TABLE foo (id UNIONTYPE<,,,STRUCT<boo:|>,BIGINT"', function () {
+        it('should suggest keywords for "CREATE EXTERNAL TABLE foo (id int) PARTITIONED BY (boo INT) |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TEMPORARY EXTERNAL TABLE foo (id UNIONTYPE<,,,STRUCT<boo:',
-            afterCursor: '>,BIGINT',
+            beforeCursor: 'CREATE EXTERNAL TABLE foo (id int) PARTITIONED BY (boo INT) ',
+            afterCursor: '',
             dialect: 'hive',
-            containsKeywords: ['BIGINT', 'MAP<>'],
+            containsKeywords: ['CLUSTERED BY', 'SKEWED BY'],
+            doesNotContainKeywords: ['COMMENT', 'PARTITIONED BY'],
             expectedResult: {
               lowerCase: false
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TABLE foo (bla ARRAY<MAP<|>>"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) CLUSTERED BY (a, b, c) INTO 10 BUCKETS |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE foo (bla ARRAY<MAP<',
-            afterCursor: '>>',
+            beforeCursor: 'CREATE TABLE foo (id int) CLUSTERED BY (a, b, c) INTO 10 BUCKETS ',
+            afterCursor: '',
             dialect: 'hive',
-            containsKeywords: ['BIGINT'],
-            doesNotContainKeywords: ['MAP<>'],
+            containsKeywords: ['SKEWED BY'],
+            doesNotContainKeywords: ['CLUSTERED BY', 'PARTITIONED BY'],
             expectedResult: {
               lowerCase: false
             }
           });
         });
-      });
-    });
-
-    describe('CREATE VIEW', function () {
-      it('should handle "CREATE VIEW foo AS SELECT a, | FROM tableOne"', function () {
-        assertAutoComplete({
-          beforeCursor: 'CREATE VIEW foo AS SELECT a, ',
-          afterCursor: ' FROM tableOne',
-          hasLocations:true,
-          expectedResult: {
-            lowerCase: false,
-            suggestAggregateFunctions: true,
-            suggestAnalyticFunctions: true,
-            suggestFunctions: {},
-            suggestColumns: { table: 'tableOne' },
-            suggestKeywords: ['*']
-          }
-        });
-      });
-
-      it('should suggest keywords for "CREATE VIEW |"', function () {
-        assertAutoComplete({
-          beforeCursor: 'CREATE VIEW ',
-          afterCursor: '',
-          expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['IF NOT EXISTS'],
-            suggestDatabases: { appendDot: true }
-          }
-        });
-      });
-
-      it('should suggest keywords for "CREATE VIEW | boo AS select * from baa;"', function () {
-        assertAutoComplete({
-          beforeCursor: 'CREATE VIEW ',
-          afterCursor: ' boo AS SELECT * FROM baa;',
-          hasLocations: true,
-          expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['IF NOT EXISTS']
-          }
-        });
-      });
-
-      it('should suggest keywords for "CREATE VIEW IF |"', function () {
-        assertAutoComplete({
-          beforeCursor: 'CREATE VIEW IF ',
-          afterCursor: '',
-          expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['NOT EXISTS']
-          }
-        });
-      });
-
-      it('should suggest keywords for "CREATE VIEW IF NOT |"', function () {
-        assertAutoComplete({
-          beforeCursor: 'CREATE VIEW IF NOT ',
-          afterCursor: '',
-          expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['EXISTS']
-          }
-        });
-      });
-
-      it('should suggest keywords for "CREATE VIEW boo AS |"', function () {
-        assertAutoComplete({
-          beforeCursor: 'CREATE VIEW boo AS ',
-          afterCursor: '',
-          expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['SELECT']
-          }
-        });
-      });
-
-      it('should suggest keywords for "CREATE VIEW IF NOT EXISTS boo AS |"', function () {
-        assertAutoComplete({
-          beforeCursor: 'CREATE VIEW IF NOT EXISTS boo AS ',
-          afterCursor: '',
-          expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['SELECT']
-          }
-        });
-      });
-
-      describe('Hive specific', function () {
-        it('should suggest columns for "CREATE VIEW IF NOT EXISTS db.foo (baa COMMENT \'foo bar\', ble) COMMENT \'baa\' TBLPROPERTIES ("boo.baa"="buu") AS SELECT a, | FROM tableOne"', function () {
+
+        it('should suggest keywords for "CREATE TABLE foo (id int) LOCATION \'/baa\' |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE VIEW IF NOT EXISTS db.foo (baa COMMENT \'foo bar\', ble) COMMENT \'baa\' TBLPROPERTIES ("boo.baa"="buu") AS SELECT a, ',
-            afterCursor: ' FROM tableOne',
+            beforeCursor: 'CREATE TABLE foo (id int) LOCATION \'/baa\' ',
+            afterCursor: '',
             dialect: 'hive',
-            hasLocations:true,
             expectedResult: {
               lowerCase: false,
-              suggestAggregateFunctions: true,
-              suggestAnalyticFunctions: true,
-              suggestFunctions: {},
-              suggestColumns: { table: 'tableOne' },
-              suggestKeywords: ['*']
+              suggestKeywords: ['TBLPROPERTIES', 'AS']
             }
           });
         });
 
-        it('should handle "CREATE VIEW v1 AS WITH q1 AS ( SELECT key FROM src WHERE key = \'5\') SELECT * FROM q1;|', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) CLUSTERED |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE VIEW v1 AS WITH q1 AS ( SELECT key FROM src WHERE key = \'5\') SELECT * FROM q1;',
+            beforeCursor: 'CREATE TABLE foo (id int) CLUSTERED ',
             afterCursor: '',
             dialect: 'hive',
-            hasLocations:true,
-            containsKeywords: ['SELECT', 'WITH'],
             expectedResult: {
-              lowerCase: false
+              lowerCase: false,
+              suggestKeywords: ['BY']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE VIEW IF NOT EXISTS boo |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) CLUSTERED BY (a, b, c) |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE VIEW IF NOT EXISTS boo ',
+            beforeCursor: 'CREATE TABLE foo (id int) CLUSTERED BY (a, b, c) ',
             afterCursor: '',
             dialect: 'hive',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['COMMENT', 'TBLPROPERTIES', 'AS']
+              suggestKeywords: ['SORTED BY', 'INTO']
             }
           });
         });
-      });
 
-      describe('Impala specific', function () {
-        it('should suggest keywords for "CREATE VIEW IF NOT EXISTS boo |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) CLUSTERED (a, b, c) SORTED |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE VIEW IF NOT EXISTS boo ',
+            beforeCursor: 'CREATE TABLE foo (id int) CLUSTERED BY (a, b, c) SORTED ',
             afterCursor: '',
-            dialect: 'impala',
+            dialect: 'hive',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['AS']
+              suggestKeywords: ['BY']
             }
           });
         });
-      });
-    });
-
-    describe('CREATE ROLE', function () {
-      it('should handle "CREATE ROLE boo; |"', function () {
-        assertAutoComplete({
-          beforeCursor: 'CREATE ROLE boo; ',
-          afterCursor: '',
-          containsKeywords: ['SELECT'],
-          expectedResult: {
-            lowerCase: false
-          }
-        });
-      });
-    });
 
-    describe('CREATE FUNCTION', function () {
-      describe('Hive specific', function () {
-        it('should handle "CREATE TEMPORARY FUNCTION baaa AS \'boo.baa\'; |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) CLUSTERED (a, b, c) SORTED BY (a |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TEMPORARY FUNCTION baaa AS \'boo.baa\'; ',
+            beforeCursor: 'CREATE TABLE foo (id int) CLUSTERED BY (a, b, c) SORTED BY (a ',
             afterCursor: '',
             dialect: 'hive',
-            containsKeywords: ['SELECT'],
             expectedResult: {
-              lowerCase: false
+              lowerCase: false,
+              suggestKeywords: ['ASC', 'DESC']
             }
           });
         });
 
-        it('should handle "CREATE FUNCTION boo.baaa AS \'boo.baa\' USING JAR \'boo.jar\', FILE \'booo\', ARCHIVE \'baa\'; |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) CLUSTERED (a, b, c) SORTED BY (a ASC, b |, c)"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE FUNCTION boo.baaa AS \'boo.baa\' USING JAR \'boo.jar\', FILE \'booo\', ARCHIVE \'baa\'; ',
-            afterCursor: '',
+            beforeCursor: 'CREATE TABLE foo (id int) CLUSTERED BY (a, b, c) SORTED BY (a ASC, b ',
+            afterCursor: ', c)',
             dialect: 'hive',
-            containsKeywords: ['SELECT'],
             expectedResult: {
-              lowerCase: false
+              lowerCase: false,
+              suggestKeywords: ['ASC', 'DESC']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE FUNCTION boo.baa |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) CLUSTERED (a, b, c) SORTED BY (a ASC, b DESC, c) |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE FUNCTION boo.baa ',
+            beforeCursor: 'CREATE TABLE foo (id int) CLUSTERED BY (a, b, c) SORTED BY (a ASC, b DESC, c) ',
             afterCursor: '',
             dialect: 'hive',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['AS']
+              suggestKeywords: ['INTO']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE FUNCTION boo.baa AS \'baa.boo\' |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) CLUSTERED (a, b, c) INTO 10 |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE FUNCTION boo.baa AS \'baa.boo\' ',
+            beforeCursor: 'CREATE TABLE foo (id int) CLUSTERED BY (a, b, c) INTO 10 ',
             afterCursor: '',
             dialect: 'hive',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['USING']
+              suggestKeywords: ['BUCKETS']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE FUNCTION boo.baa AS \'baa.boo\' USING |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) CLUSTERED (a, b, c) SORTED BY (a ASC, b DESC, c) INTO 10 |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE FUNCTION boo.baa AS \'baa.boo\' USING ',
+            beforeCursor: 'CREATE TABLE foo (id int) CLUSTERED BY (a, b, c) SORTED BY (a ASC, b DESC, c) INTO 10 ',
             afterCursor: '',
             dialect: 'hive',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['ARCHIVE', 'FILE', 'JAR']
+              suggestKeywords: ['BUCKETS']
             }
           });
         });
 
-        xit('should suggest hdfs for "CREATE FUNCTION boo.baa AS \'baa.boo\' USING FILE \'|"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) SKEWED |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE FUNCTION boo.baa AS \'baa.boo\' USING FILE \'',
+            beforeCursor: 'CREATE TABLE foo (id int) SKEWED ',
             afterCursor: '',
             dialect: 'hive',
             expectedResult: {
               lowerCase: false,
-              suggestHdfs: { path: '' }
+              suggestKeywords: ['BY']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE FUNCTION boo.baa AS \'baa.boo\' USING FILE \'boo\' |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) SKEWED BY (a, b, c) |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE FUNCTION boo.baa AS \'baa.boo\' USING FILE \'boo\' ',
+            beforeCursor: 'CREATE TABLE foo (id int) SKEWED BY (a, b, c) ',
             afterCursor: '',
             dialect: 'hive',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['ARCHIVE', 'FILE', 'JAR']
+              suggestKeywords: ['ON']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE TEMPORARY FUNCTION boo |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) SKEWED BY (a, b, c) ON ((1,2), (2,3)) |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TEMPORARY FUNCTION boo ',
+            beforeCursor: 'CREATE TABLE foo (id int) SKEWED BY (a, b, c) ON ((1,2), (2,3)) ',
             afterCursor: '',
             dialect: 'hive',
+            containsKeywords: ['STORED AS DIRECTORIES'],
             expectedResult: {
-              lowerCase: false,
-              suggestKeywords: ['AS']
+              lowerCase: false
             }
           });
         });
 
-        it('should not suggest keywords for "CREATE TEMPORARY FUNCTION boo AS \'boo.baa\' |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) STORED |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TEMPORARY FUNCTION boo AS \'boo.baa\' ',
+            beforeCursor: 'CREATE TABLE foo (id int) STORED ',
             afterCursor: '',
             dialect: 'hive',
             expectedResult: {
-              lowerCase: false
+              lowerCase: false,
+              suggestKeywords: ['AS', 'BY']
             }
           });
         });
-      });
 
-      describe('Impala specific', function () {
-        it('should handle "CREATE FUNCTION foo.boo(INT, BOOLEAN) RETURNS INT LOCATION \'/boo\' SYMBOL=\'baaa\'; |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) STORED AS |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE FUNCTION boo(INT, BOOLEAN) RETURNS INT LOCATION \'/boo\' SYMBOL=\'baaa\'; ',
+            beforeCursor: 'CREATE TABLE foo (id int) STORED AS ',
             afterCursor: '',
-            dialect: 'impala',
-            containsKeywords: ['SELECT'],
+            dialect: 'hive',
             expectedResult: {
-              lowerCase: false
+              lowerCase: false,
+              suggestKeywords: ['AVRO', 'INPUTFORMAT', 'ORC', 'PARQUET', 'RCFILE', 'SEQUENCEFILE', 'TEXTFILE']
             }
           });
         });
 
-        it('should handle "CREATE AGGREGATE FUNCTION baa.boo(INT, DOUBLE) RETURNS INT LOCATION \'/boo\' INIT_FN=\'cos\' UPDATE_FN=\'sin\' ' +
-            'MERGE_FN=\'cos\' PREPARE_FN=\'cos\' CLOSE_FN=\'cos\' SERIALIZE_FN=\'cos\' FINALIZE_FN=\'cos\'; |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) ROW |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' INIT_FN=\'cos\' UPDATE_FN=\'sin\' MERGE_FN=\'cos\' PREPARE_FN=\'cos\' CLOSE_FN=\'cos\' SERIALIZE_FN=\'cos\' FINALIZE_FN=\'cos\'; ',
+            beforeCursor: 'CREATE TABLE foo (id int) ROW ',
             afterCursor: '',
-            dialect: 'impala',
-            containsKeywords: ['SELECT'],
+            dialect: 'hive',
             expectedResult: {
-              lowerCase: false
+              lowerCase: false,
+              suggestKeywords: ['FORMAT']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE AGGREGATE |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE AGGREGATE ',
+            beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT ',
             afterCursor: '',
-            dialect: 'impala',
+            dialect: 'hive',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['FUNCTION']
+              suggestKeywords: ['DELIMITED', 'SERDE']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE AGGREGATE FUNCTION |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT DELIMITED |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE AGGREGATE FUNCTION ',
+            beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT DELIMITED ',
             afterCursor: '',
-            dialect: 'impala',
+            dialect: 'hive',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['IF NOT EXISTS'],
-              suggestDatabases: { appendDot: true }
+              suggestKeywords: ['FIELDS TERMINATED BY', 'COLLECTION ITEMS TERMINATED BY', 'MAP KEYS TERMINATED BY', 'LINES TERMINATED BY', 'NULL DEFINED AS', 'STORED AS', 'LOCATION', 'TBLPROPERTIES', 'AS']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE AGGREGATE FUNCTION IF |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT DELIMITED MAP |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE AGGREGATE FUNCTION IF ',
+            beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT DELIMITED MAP ',
             afterCursor: '',
-            dialect: 'impala',
+            dialect: 'hive',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['NOT EXISTS']
+              suggestKeywords: ['KEYS TERMINATED BY']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE AGGREGATE FUNCTION IF NOT |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT DELIMITED MAP KEYS TERMINATED BY \'a\' NULL DEFINED |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE AGGREGATE FUNCTION IF NOT ',
+            beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT DELIMITED MAP KEYS TERMINATED BY \'a\' NULL DEFINED ',
             afterCursor: '',
-            dialect: 'impala',
+            dialect: 'hive',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['EXISTS']
+              suggestKeywords: ['AS']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE AGGREGATE FUNCTION boo(|"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT DELIMITED MAP KEYS TERMINATED BY \'a\' |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE AGGREGATE FUNCTION boo(',
+            beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT DELIMITED MAP KEYS TERMINATED BY \'a\' ',
             afterCursor: '',
-            dialect: 'impala',
-            containsKeywords: ['INT'],
+            dialect: 'hive',
+            containsKeywords: ['STORED AS'],
+            doesNotContainKeywords: ['STORED BY'],
             expectedResult: {
               lowerCase: false
             }
           });
         });
 
-        it('should suggest keywords for "CREATE AGGREGATE FUNCTION boo() |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT DELIMITED MAP KEYS TERMINATED BY \'a\' STORED |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE AGGREGATE FUNCTION boo() ',
+            beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT DELIMITED MAP KEYS TERMINATED BY \'a\' STORED ',
             afterCursor: '',
-            dialect: 'impala',
+            dialect: 'hive',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['RETURNS']
+              suggestKeywords: ['AS']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE AGGREGATE FUNCTION boo() RETURNS |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) ROW FORMAT DELIMITED MAP KEYS TERMINATED BY \'a\' STORED AS |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE AGGREGATE FUNCTION boo() RETURNS ',
+            beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT DELIMITED MAP KEYS TERMINATED BY \'a\' STORED AS ',
             afterCursor: '',
-            dialect: 'impala',
-            containsKeywords: ['INT'],
+            dialect: 'hive',
+            containsKeywords: ['ORC'],
             expectedResult: {
               lowerCase: false
             }
           });
         });
 
-        it('should suggest keywords for "CREATE AGGREGATE FUNCTION boo() RETURNS INT |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) STORED BY \'handler\' |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE AGGREGATE FUNCTION boo() RETURNS INT ',
+            beforeCursor: 'CREATE TABLE foo (id int) STORED BY \'handler\' ',
             afterCursor: '',
-            dialect: 'impala',
+            dialect: 'hive',
+            containsKeywords: ['WITH SERDEPROPERTIES'],
+            doesNotContainKeywords: ['STORED BY'],
             expectedResult: {
-              lowerCase: false,
-              suggestKeywords: ['LOCATION']
+              lowerCase: false
             }
           });
         });
 
-        it('should suggest keywords for "CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id int) STORED BY \'handler\' WITH |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' ',
+            beforeCursor: 'CREATE TABLE foo (id int) STORED BY \'handler\' WITH ',
             afterCursor: '',
-            dialect: 'impala',
+            dialect: 'hive',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['INIT_FN', 'UPDATE_FN']
+              suggestKeywords: ['SERDEPROPERTIES']
             }
           });
         });
 
-        it('should suggest functions for "CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' INIT_FN=\'|"', function () {
+        it('should suggest keywords for "CREATE ... TABLE ... PARTITIONED BY ... ROW FORMAT ... AS |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' INIT_FN=\'',
+            beforeCursor: 'CREATE TEMPORARY EXTERNAL TABLE IF NOT EXISTS db.foo (id INT COMMENT \'an int\', baa ARRAY<BIGINT>) COMMENT \'a table\' ' +
+              'PARTITIONED BY (boo DOUBLE, baa INT) ' +
+              'CLUSTERED BY (boo, baa) SORTED BY (boo ASC, baa) INTO 10 BUCKETS ' +
+              'SKEWED BY (a, b, c) ON ((\'val1\', \'val2\'), (1, 2, 3)) STORED AS DIRECTORIES ' +
+              'ROW FORMAT DELIMITED FIELDS TERMINATED BY \'b\' ESCAPED BY \'o\' COLLECTION ITEMS TERMINATED BY \'d\' ' +
+              'MAP KEYS TERMINATED BY \'a\' LINES TERMINATED BY \'a\' NULL DEFINED AS \'o\' ' +
+              'STORED AS ORC LOCATION \'/asdf/boo/\' TBLPROPERTIES ("comment"="boo") AS ',
             afterCursor: '',
-            dialect: 'impala',
+            dialect: 'hive',
             expectedResult: {
               lowerCase: false,
-              suggestAnalyticFunctions: true,
-              suggestAggregateFunctions: true,
-              suggestFunctions: {}
+              suggestKeywords: ['SELECT']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' INIT_FN=\'cos\' |"', function () {
+        it('should suggest keywords for "CREATE TABLE boo PARTITIONED BY ... STORED BY \'storage.handler\' WITH SERDEPROPERTIES ... AS |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' INIT_FN=\'cos\' ',
+            beforeCursor: 'CREATE TABLE boo PARTITIONED BY (boo DOUBLE, baa INT) STORED BY \'storage.handler\' ' +
+              'WITH SERDEPROPERTIES (\'foo.bar\' = \'booo\', \'bar.foo\' = \'bla\') ' +
+              'LOCATION \'/asdf/boo/\' TBLPROPERTIES ("comment"="boo") AS ',
             afterCursor: '',
-            dialect: 'impala',
+            dialect: 'hive',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['UPDATE_FN']
+              suggestKeywords: ['SELECT']
             }
           });
         });
 
-        it('should suggest functions for "CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' INIT_FN=\'cos\' UPDATE_FN=\'|"', function () {
+        it('should suggest tables for "CREATE TEMPORARY EXTERNAL TABLE IF NOT EXISTS db.boo LIKE | LOCATION \'/some/loc\';"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' INIT_FN=\'cos\' UPDATE_FN=\'',
-            afterCursor: '',
-            dialect: 'impala',
+            beforeCursor: 'CREATE TEMPORARY EXTERNAL TABLE IF NOT EXISTS db.boo LIKE ',
+            afterCursor: ' LOCATION \'/some/loc\';',
+            dialect: 'hive',
             expectedResult: {
               lowerCase: false,
-              suggestAnalyticFunctions: true,
-              suggestAggregateFunctions: true,
-              suggestFunctions: {}
+              suggestTables: {},
+              suggestDatabases: { appendDot: true }
             }
           });
         });
 
-        it('should suggest keywords for "CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' INIT_FN=\'cos\' UPDATE_FN=\'sin\' |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' INIT_FN=\'cos\' UPDATE_FN=\'sin\' ',
+            beforeCursor: 'CREATE TABLE foo (id ',
             afterCursor: '',
-            dialect: 'impala',
+            dialect: 'hive',
+            containsKeywords: ['BIGINT', 'MAP<>'],
             expectedResult: {
-              lowerCase: false,
-              suggestKeywords: ['MERGE_FN']
+              lowerCase: false
             }
           });
         });
 
-        it('should suggest keywords for "CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' INIT_FN=\'cos\' UPDATE_FN=\'sin\' MERGE_FN=\'tan\' ' +
-            'PREPARE_FN=\'boo\' SERIALIZE_FN=\'baa\' |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo(id |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' INIT_FN=\'cos\' UPDATE_FN=\'sin\' MERGE_FN=\'tan\' PREPARE_FN=\'boo\' SERIALIZE_FN=\'baa\' ',
+            beforeCursor: 'CREATE TABLE foo(id ',
             afterCursor: '',
-            dialect: 'impala',
+            dialect: 'hive',
+            containsKeywords: ['BIGINT', 'MAP<>'],
             expectedResult: {
-              lowerCase: false,
-              suggestKeywords: ['FINALIZE_FN']
+              lowerCase: false
             }
           });
         });
 
-        it('should suggest keywords for "CREATE FUNCTION |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (bla ARRAY<INT>, boo |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE FUNCTION ',
+            beforeCursor: 'CREATE TABLE foo (bla ARRAY<INT>, boo ',
             afterCursor: '',
-            dialect: 'impala',
+            dialect: 'hive',
+            containsKeywords: ['BIGINT', 'MAP<>'],
             expectedResult: {
-              lowerCase: false,
-              suggestKeywords: ['IF NOT EXISTS'],
-              suggestDatabases: { appendDot: true }
+              lowerCase: false
             }
           });
         });
 
-        it('should suggest keywords for "CREATE FUNCTION IF |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (bla ARRAY<|"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE FUNCTION IF ',
+            beforeCursor: 'CREATE TABLE foo (bla ARRAY<',
             afterCursor: '',
-            dialect: 'impala',
+            dialect: 'hive',
+            containsKeywords: ['BIGINT', 'MAP<>'],
             expectedResult: {
-              lowerCase: false,
-              suggestKeywords: ['NOT EXISTS']
+              lowerCase: false
             }
           });
         });
 
-        it('should suggest keywords for "CREATE FUNCTION IF NOT |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (bla MAP<|"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE FUNCTION IF NOT ',
+            beforeCursor: 'CREATE TABLE foo (bla MAP<',
             afterCursor: '',
-            dialect: 'impala',
+            dialect: 'hive',
+            containsKeywords: ['BIGINT'],
+            doesNotContainKeywords: ['MAP<>'],
             expectedResult: {
-              lowerCase: false,
-              suggestKeywords: ['EXISTS']
+              lowerCase: false
             }
           });
         });
 
-        it('should suggest keywords for "CREATE FUNCTION boo(|"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (bla MAP<STRING, STRING>, boo |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE FUNCTION boo(',
+            beforeCursor: 'CREATE TABLE foo (bla MAP<STRING, STRING>, boo ',
             afterCursor: '',
-            dialect: 'impala',
-            containsKeywords: ['INT'],
-            doesNotContainKeywords: ['ARRAY<>', '...'],
+            dialect: 'hive',
+            containsKeywords: ['BIGINT'],
             expectedResult: {
               lowerCase: false
             }
           });
         });
 
-        it('should suggest keywords for "CREATE FUNCTION boo(INT, BOOLEAN |"', function () {
+        it('should not suggest keywords for "CREATE TABLE boo (baa STRUCT<foo:INT, |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE FUNCTION boo(INT, BOOLEAN ',
+            beforeCursor: 'CREATE TABLE boo (baa STRUCT<foo:INT, ',
             afterCursor: '',
-            dialect: 'impala',
+            dialect: 'hive',
             expectedResult: {
-              lowerCase: false,
-              suggestKeywords: ['...']
+              lowerCase: false
             }
           });
         });
 
-        it('should not suggest keywords for "CREATE FUNCTION boo(INT |, BOOLEAN"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id INT, bla MAP<|, boo BIGINT, bla INT"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE FUNCTION boo(INT ',
-            afterCursor: ', BOOLEAN',
-            dialect: 'impala',
+            beforeCursor: 'CREATE TABLE foo (id INT, bla MAP<',
+            afterCursor: ', boo BIGINT, bla INT)',
+            dialect: 'hive',
+            containsKeywords: ['BIGINT'],
+            doesNotContainKeywords: ['MAP<>'],
             expectedResult: {
               lowerCase: false
             }
           });
         });
 
-        it('should suggest keywords for "CREATE FUNCTION boo(INT, BOOLEAN, |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id INT, bla MAP<|>, boo BIGINT, bla INT"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE FUNCTION  boo(INT, BOOLEAN, ',
-            afterCursor: '',
-            dialect: 'impala',
-            containsKeywords: ['INT'],
-            doesNotContainKeywords: ['ARRAY<>', '...'],
+            beforeCursor: 'CREATE TABLE foo (id INT, bla MAP<',
+            afterCursor: '>, boo BIGINT, bla INT)',
+            dialect: 'hive',
+            containsKeywords: ['BIGINT'],
+            doesNotContainKeywords: ['MAP<>'],
             expectedResult: {
               lowerCase: false
             }
           });
         });
 
-        it('should suggest keywords for "CREATE FUNCTION boo(INT, BOOLEAN, STRING |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (bla STRUCT<foo:|"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE FUNCTION  boo(INT, BOOLEAN, STRING ',
+            beforeCursor: 'CREATE TABLE foo (bla STRUCT<foo:',
             afterCursor: '',
-            dialect: 'impala',
+            dialect: 'hive',
+            containsKeywords: ['BIGINT', 'MAP<>'],
             expectedResult: {
-              lowerCase: false,
-              suggestKeywords: ['...']
+              lowerCase: false
             }
           });
         });
 
-        it('should suggest keywords for "CREATE FUNCTION boo(INT, BOOLEAN) |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (bla MAP<BIGINT, STRUCT<foo:ARRAY<|, bla DOUBLE"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE FUNCTION boo(INT, BOOLEAN) ',
-            afterCursor: '',
-            dialect: 'impala',
+            beforeCursor: 'CREATE TABLE foo (bla MAP<BIGINT, STRUCT<foo:ARRAY<',
+            afterCursor: ', bla DOUBLE',
+            dialect: 'hive',
+            containsKeywords: ['BIGINT', 'MAP<>'],
             expectedResult: {
-              lowerCase: false,
-              suggestKeywords: ['RETURNS']
+              lowerCase: false
             }
           });
         });
 
-        it('should suggest keywords for "CREATE FUNCTION boo(INT, BOOLEAN) RETURNS |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (bla MAP<BIGINT, STRUCT<boo: INT, foo:STRUCT<blo:DOUBLE |, bla:DOUBLE>"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE FUNCTION boo(INT, BOOLEAN) RETURNS ',
-            afterCursor: '',
-            dialect: 'impala',
-            containsKeywords: ['INT'],
+            beforeCursor: 'CREATE TABLE foo (bla MAP<BIGINT, STRUCT<boo: INT, foo:STRUCT<blo:DOUBLE ',
+            afterCursor: ', bla:DOUBLE>',
+            dialect: 'hive',
             expectedResult: {
-              lowerCase: false
+              lowerCase: false,
+              suggestKeywords: ['COMMENT']
             }
           });
         });
 
-        it('should suggest keywords for "CREATE FUNCTION boo(INT, BOOLEAN) RETURNS INT |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (bla MAP<|, STRUCT<boo: INT, foo:STRUCT<blo:DOUBLE, doo:VARCHAR, bla:DOUBLE>"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE FUNCTION boo(INT, BOOLEAN) RETURNS INT ',
-            afterCursor: '',
-            dialect: 'impala',
+            beforeCursor: 'CREATE TABLE foo (bla MAP<',
+            afterCursor: ', STRUCT<boo: INT, foo:STRUCT<blo:DOUBLE, doo:VARCHAR, bla:DOUBLE>',
+            dialect: 'hive',
+            containsKeywords: ['BIGINT'],
+            doesNotContainKeywords: ['MAP<>'],
             expectedResult: {
-              lowerCase: false,
-              suggestKeywords: ['LOCATION']
+              lowerCase: false
             }
           });
         });
 
-        it('should suggest hdfs for "CREATE FUNCTION boo(INT, BOOLEAN) RETURNS INT LOCATION \'|"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id INT, ba STRUCT<boo:INT COMMENT \'Some Comment\', bla:BIGINT>, bla MAP<INT,|>, boo BIGINT, bla INT"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE FUNCTION boo(INT, BOOLEAN) RETURNS INT LOCATION \'',
-            afterCursor: '',
-            dialect: 'impala',
+            beforeCursor: 'CREATE TABLE foo (id INT, ba STRUCT<boo:INT COMMENT \'Some Comment\', bla:BIGINT>, bla MAP<INT,',
+            afterCursor: '>, boo BIGINT, bla INT)',
+            dialect: 'hive',
+            containsKeywords: ['BIGINT', 'MAP<>'],
             expectedResult: {
-              lowerCase: false,
-              suggestHdfs: { path: '' }
+              lowerCase: false
             }
           });
         });
 
-        it('should suggest keywords for "CREATE FUNCTION boo(INT, BOOLEAN) RETURNS INT LOCATION \'/boo\' |"', function () {
+        it('should suggest keywords for "CREATE TABLE foo (id UNIONTYPE<INT, BIGINT, |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE FUNCTION boo(INT, BOOLEAN) RETURNS INT LOCATION \'/boo\' ',
+            beforeCursor: 'CREATE TABLE foo (id UNIONTYPE<INT, BIGINT, ',
             afterCursor: '',
-            dialect: 'impala',
+            dialect: 'hive',
+            containsKeywords: ['BIGINT', 'MAP<>'],
             expectedResult: {
-              lowerCase: false,
-              suggestKeywords: ['SYMBOL']
+              lowerCase: false
             }
           });
         });
-      });
-    });
-
-    describe('CREATE INDEX', function () {
-      it('should handle "CREATE INDEX bla ON TABLE db.tbl (a, b, c) AS \'COMPACT\' WITH DEFERRED REBUILD IDXPROPERTIES ("boo.baa"="ble", "blaa"=1) IN TABLE dbTwo.tblTwo ROW FORMAT DELIMITED STORED AS PARQUET LOCATION \'/baa/boo\' TBLPROPERTIES ("bla"=1) COMMENT \"booo\"; |"', function () {
-        assertAutoComplete({
-          beforeCursor: 'CREATE INDEX bla ON TABLE db.tbl (a, b, c) AS \'COMPACT\' WITH DEFERRED REBUILD IDXPROPERTIES ' +
-          '("boo.baa"="ble", "blaa"=1) IN TABLE dbTwo.tblTwo ROW FORMAT DELIMITED STORED AS PARQUET LOCATION \'/baa/boo\' ' +
-          'TBLPROPERTIES ("bla"=1) COMMENT \"booo\"; ',
-          afterCursor: '',
-          dialect: 'hive',
-          hasLocations: true,
-          containsKeywords: ['SELECT'],
-          expectedResult: {
-            lowerCase: false
-          }
-        });
-      });
-
-      it('should handle "CREATE INDEX bla ON TABLE db.tbl (a, b, c) AS \'boo.baa.bitmap\'; |"', function () {
-        assertAutoComplete({
-          beforeCursor: 'CREATE INDEX bla ON TABLE db.tbl (a, b, c) AS \'boo.baa.bitmap\'; ',
-          afterCursor: '',
-          dialect: 'hive',
-          hasLocations: true,
-          containsKeywords: ['SELECT'],
-          expectedResult: {
-            lowerCase: false
-          }
-        });
-      });
-
-      it('should suggest keywords for "CREATE INDEX bla  |"', function () {
-        assertAutoComplete({
-          beforeCursor: 'CREATE INDEX bla ',
-          afterCursor: '',
-          dialect: 'hive',
-          expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['ON TABLE']
-          }
-        });
-      });
-
-      it('should suggest keywords for "CREATE INDEX bla ON |"', function () {
-        assertAutoComplete({
-          beforeCursor: 'CREATE INDEX bla ON ',
-          afterCursor: '',
-          dialect: 'hive',
-          expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['TABLE']
-          }
-        });
-      });
-
-      it('should suggest tables for "CREATE INDEX bla ON TABLE |"', function () {
-        assertAutoComplete({
-          beforeCursor: 'CREATE INDEX bla ON TABLE ',
-          afterCursor: '',
-          dialect: 'hive',
-          expectedResult: {
-            lowerCase: false,
-            suggestTables: {},
-            suggestDatabases: { appendDot: true }
-          }
-        });
-      });
-
-      it('should suggest columns for "CREATE INDEX bla ON TABLE foo.bar (|"', function () {
-        assertAutoComplete({
-          beforeCursor: 'CREATE INDEX bla ON TABLE foo.bar (',
-          afterCursor: '',
-          dialect: 'hive',
-          hasLocations: true,
-          expectedResult: {
-            lowerCase: false,
-            suggestColumns: { database: 'foo', table: 'bar' }
-          }
-        });
-      });
-
-      it('should suggest columns for "CREATE INDEX bla ON TABLE foo.bar (a, b, c, |"', function () {
-        assertAutoComplete({
-          beforeCursor: 'CREATE INDEX bla ON TABLE foo.bar (a, b, c, ',
-          afterCursor: '',
-          dialect: 'hive',
-          hasLocations: true,
-          expectedResult: {
-            lowerCase: false,
-            suggestColumns: { database: 'foo', table: 'bar' }
-          }
-        });
-      });
 
-      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) |"', function () {
-        assertAutoComplete({
-          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) ',
-          afterCursor: '',
-          dialect: 'hive',
-          hasLocations: true,
-          expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['AS']
-          }
+        it('should suggest keywords for "CREATE TEMPORARY EXTERNAL TABLE foo (id UNIONTYPE<,,,STRUCT<boo:|>,BIGINT"', function () {
+          assertAutoComplete({
+            beforeCursor: 'CREATE TEMPORARY EXTERNAL TABLE foo (id UNIONTYPE<,,,STRUCT<boo:',
+            afterCursor: '>,BIGINT',
+            dialect: 'hive',
+            containsKeywords: ['BIGINT', 'MAP<>'],
+            expectedResult: {
+              lowerCase: false
+            }
+          });
         });
-      });
 
-      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS |"', function () {
-        assertAutoComplete({
-          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS ',
-          afterCursor: '',
-          dialect: 'hive',
-          hasLocations: true,
-          expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['\'BITMAP\'', '\'COMPACT\'']
-          }
+        it('should suggest keywords for "CREATE TABLE foo (bla ARRAY<MAP<|>>"', function () {
+          assertAutoComplete({
+            beforeCursor: 'CREATE TABLE foo (bla ARRAY<MAP<',
+            afterCursor: '>>',
+            dialect: 'hive',
+            containsKeywords: ['BIGINT'],
+            doesNotContainKeywords: ['MAP<>'],
+            expectedResult: {
+              lowerCase: false
+            }
+          });
         });
       });
+    });
 
-      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BIT|"', function () {
+    describe('CREATE TEMPORARY MACRO', function () {
+      it('should suggest handle "CREATE TEMPORARY MACRO boo(x INT, y INT) x + cos(y);|"', function () {
         assertAutoComplete({
-          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BIT',
+          beforeCursor: 'CREATE TEMPORARY MACRO boo(x INT, y INT) x + cos(y);',
           afterCursor: '',
           dialect: 'hive',
+          noErrors: true,
           hasLocations: true,
+          containsKeywords: ['SELECT'],
           expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['\'BITMAP\'', '\'COMPACT\'']
+            lowerCase: false
           }
         });
       });
 
-      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' |"', function () {
+      it('should suggest keywords for "CREATE |"', function () {
         assertAutoComplete({
-          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' ',
+          beforeCursor: 'CREATE ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
+          containsKeywords: ['TEMPORARY MACRO'],
           expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['WITH DEFERRED REBUILD', 'IDXPROPERTIES', 'IN TABLE', 'ROW FORMAT', 'STORED AS', 'STORED BY', 'LOCATION', 'TBLPROPERTIES', 'COMMENT']
+            lowerCase: false
           }
         });
       });
 
-      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' WITH |"', function () {
+      it('should suggest keywords for "CREATE TEMPORARY |"', function () {
         assertAutoComplete({
-          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' WITH ',
+          beforeCursor: 'CREATE TEMPORARY ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
+          containsKeywords: ['MACRO'],
           expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['DEFERRED REBUILD']
+            lowerCase: false
           }
         });
       });
 
-      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' WITH DEFERRED |"', function () {
+      it('should suggest keywords for "CREATE TEMPORARY MACRO boo(x |"', function () {
         assertAutoComplete({
-          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' WITH DEFERRED ',
+          beforeCursor: 'CREATE TEMPORARY MACRO boo(x ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
+          containsKeywords: ['INT', 'STRING'],
           expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['REBUILD']
+            lowerCase: false
           }
         });
       });
 
-      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' WITH DEFERRED REBUILD |"', function () {
+      it('should suggest keywords for "CREATE TEMPORARY MACRO boo(x INT, y |"', function () {
         assertAutoComplete({
-          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' WITH DEFERRED REBUILD ',
+          beforeCursor: 'CREATE TEMPORARY MACRO boo(x INT, y ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
+          containsKeywords: ['INT', 'STRING'],
           expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['IDXPROPERTIES', 'IN TABLE', 'ROW FORMAT', 'STORED AS', 'STORED BY', 'LOCATION', 'TBLPROPERTIES', 'COMMENT']
+            lowerCase: false
           }
         });
       });
 
-      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' IDXPROPERTIES ("baa"="boo") |"', function () {
+      it('should suggest functions for "CREATE TEMPORARY MACRO boo(x INT, y STRING) |"', function () {
         assertAutoComplete({
-          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' IDXPROPERTIES ("baa"="boo") ',
+          beforeCursor: 'CREATE TEMPORARY MACRO boo(x INT, y STRING) ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
-            suggestKeywords: ['IN TABLE', 'ROW FORMAT', 'STORED AS', 'STORED BY', 'LOCATION', 'TBLPROPERTIES', 'COMMENT']
+            suggestFunctions: {}
           }
         });
       });
 
-      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' IN |"', function () {
+      it('should suggest functions for "CREATE TEMPORARY MACRO boo(x INT, y STRING) cos(x) + y - |"', function () {
         assertAutoComplete({
-          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' IN ',
+          beforeCursor: 'CREATE TEMPORARY MACRO boo(x INT, y STRING) cos(x) + y - ',
           afterCursor: '',
           dialect: 'hive',
           hasLocations: true,
+          containsKeywords: ['CASE'],
           expectedResult: {
             lowerCase: false,
-            suggestKeywords: ['TABLE']
+            suggestFunctions: { types: ['NUMBER'] }
           }
         });
       });
+    });
 
-      it('should suggest tables for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' IN TABLE |"', function () {
+    describe('CREATE VIEW', function () {
+      it('should handle "CREATE VIEW foo AS SELECT a, | FROM tableOne"', function () {
         assertAutoComplete({
-          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' IN TABLE ',
-          afterCursor: '',
-          dialect: 'hive',
-          hasLocations: true,
+          beforeCursor: 'CREATE VIEW foo AS SELECT a, ',
+          afterCursor: ' FROM tableOne',
+          hasLocations:true,
           expectedResult: {
             lowerCase: false,
-            suggestTables: {},
-            suggestDatabases: { appendDot: true }
+            suggestAggregateFunctions: true,
+            suggestAnalyticFunctions: true,
+            suggestFunctions: {},
+            suggestColumns: { table: 'tableOne' },
+            suggestKeywords: ['*']
           }
         });
       });
 
-      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' IN TABLE boo |"', function () {
+      it('should suggest keywords for "CREATE VIEW |"', function () {
         assertAutoComplete({
-          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' IN TABLE boo ',
+          beforeCursor: 'CREATE VIEW ',
           afterCursor: '',
-          dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
-            suggestKeywords: ['ROW FORMAT', 'STORED AS', 'STORED BY', 'LOCATION', 'TBLPROPERTIES', 'COMMENT']
+            suggestKeywords: ['IF NOT EXISTS'],
+            suggestDatabases: { appendDot: true }
           }
         });
       });
 
-      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' ROW |"', function () {
+      it('should suggest keywords for "CREATE VIEW | boo AS select * from baa;"', function () {
         assertAutoComplete({
-          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' ROW ',
-          afterCursor: '',
-          dialect: 'hive',
+          beforeCursor: 'CREATE VIEW ',
+          afterCursor: ' boo AS SELECT * FROM baa;',
           hasLocations: true,
           expectedResult: {
             lowerCase: false,
-            suggestKeywords: ['FORMAT']
+            suggestKeywords: ['IF NOT EXISTS']
           }
         });
       });
 
-      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' ROW FORMAT |"', function () {
+      it('should suggest keywords for "CREATE VIEW IF |"', function () {
         assertAutoComplete({
-          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' ROW FORMAT ',
+          beforeCursor: 'CREATE VIEW IF ',
           afterCursor: '',
-          dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
-            suggestKeywords: ['DELIMITED', 'SERDE']
-          }
-        });
-      });
-
-      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' ROW FORMAT DELIMITED |"', function () {
-        assertAutoComplete({
-          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' ROW FORMAT DELIMITED ',
-          afterCursor: '',
-          dialect: 'hive',
-          containsKeywords: ['MAP KEYS TERMINATED BY', 'NULL DEFINED AS', 'LOCATION', 'TBLPROPERTIES', 'COMMENT'],
-          doesNotContainKeywords: ['AS'],
-          hasLocations: true,
-          expectedResult: {
-            lowerCase: false
+            suggestKeywords: ['NOT EXISTS']
           }
         });
       });
 
-      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' ROW FORMAT DELIMITED NULL |"', function () {
+      it('should suggest keywords for "CREATE VIEW IF NOT |"', function () {
         assertAutoComplete({
-          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' ROW FORMAT DELIMITED NULL ',
+          beforeCursor: 'CREATE VIEW IF NOT ',
           afterCursor: '',
-          dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
-            suggestKeywords: ['DEFINED AS']
+            suggestKeywords: ['EXISTS']
           }
         });
       });
 
-      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'COMPACT\' ROW FORMAT DELIMITED STORED |"', function () {
+      it('should suggest keywords for "CREATE VIEW boo AS |"', function () {
         assertAutoComplete({
-          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'COMPACT\' ROW FORMAT DELIMITED STORED ',
+          beforeCursor: 'CREATE VIEW boo AS ',
           afterCursor: '',
-          dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
-            suggestKeywords: ['AS']
+            suggestKeywords: ['SELECT']
           }
         });
       });
 
-      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'COMPACT\' STORED |"', function () {
+      it('should suggest keywords for "CREATE VIEW IF NOT EXISTS boo AS |"', function () {
         assertAutoComplete({
-          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'COMPACT\' STORED ',
+          beforeCursor: 'CREATE VIEW IF NOT EXISTS boo AS ',
           afterCursor: '',
-          dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
-            suggestKeywords: ['AS', 'BY']
+            suggestKeywords: ['SELECT']
           }
         });
       });
 
-      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'COMPACT\' ROW FORMAT DELIMITED STORED AS |"', function () {
-        assertAutoComplete({
-          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'COMPACT\' ROW FORMAT DELIMITED STORED AS ',
-          afterCursor: '',
-          dialect: 'hive',
-          containsKeywords: ['ORC', 'PARQUET'],
-          hasLocations: true,
-          expectedResult: {
-            lowerCase: false
-          }
+      describe('Hive specific', function () {
+        it('should suggest columns for "CREATE VIEW IF NOT EXISTS db.foo (baa COMMENT \'foo bar\', ble) COMMENT \'baa\' TBLPROPERTIES ("boo.baa"="buu") AS SELECT a, | FROM tableOne"', function () {
+          assertAutoComplete({
+            beforeCursor: 'CREATE VIEW IF NOT EXISTS db.foo (baa COMMENT \'foo bar\', ble) COMMENT \'baa\' TBLPROPERTIES ("boo.baa"="buu") AS SELECT a, ',
+            afterCursor: ' FROM tableOne',
+            dialect: 'hive',
+            hasLocations:true,
+            expectedResult: {
+              lowerCase: false,
+              suggestAggregateFunctions: true,
+              suggestAnalyticFunctions: true,
+              suggestFunctions: {},
+              suggestColumns: { table: 'tableOne' },
+              suggestKeywords: ['*']
+            }
+          });
         });
-      });
 
-      it('should suggest hdfs for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'COMPACT\' LOCATION \'|"', function () {
-        assertAutoComplete({
-          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'COMPACT\' LOCATION \'',
-          afterCursor: '',
-          dialect: 'hive',
-          hasLocations: true,
-          expectedResult: {
-            lowerCase: false,
-            suggestHdfs: { path: '' }
-          }
+        it('should handle "CREATE VIEW v1 AS WITH q1 AS ( SELECT key FROM src WHERE key = \'5\') SELECT * FROM q1;|', function () {
+          assertAutoComplete({
+            beforeCursor: 'CREATE VIEW v1 AS WITH q1 AS ( SELECT key FROM src WHERE key = \'5\') SELECT * FROM q1;',
+            afterCursor: '',
+            dialect: 'hive',
+            hasLocations:true,
+            containsKeywords: ['SELECT', 'WITH'],
+            expectedResult: {
+              lowerCase: false
+            }
+          });
         });
-      });
 
-      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'COMPACT\' LOCATION \'/baa\' |"', function () {
-        assertAutoComplete({
-          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'COMPACT\' LOCATION \'/baa\' ',
-          afterCursor: '',
-          dialect: 'hive',
-          hasLocations: true,
-          expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['TBLPROPERTIES', 'COMMENT']
-          }
+        it('should suggest keywords for "CREATE VIEW IF NOT EXISTS boo |"', function () {
+          assertAutoComplete({
+            beforeCursor: 'CREATE VIEW IF NOT EXISTS boo ',
+            afterCursor: '',
+            dialect: 'hive',
+            expectedResult: {
+              lowerCase: false,
+              suggestKeywords: ['COMMENT', 'TBLPROPERTIES', 'AS']
+            }
+          });
         });
       });
 
-      it('should suggest keywords for "CREATE INDEX bla ON TABLE boo (a, b, c) AS \'COMPACT\' TBLPROPERTIES ("baa"="boo") |"', function () {
-        assertAutoComplete({
-          beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'COMPACT\' TBLPROPERTIES ("baa"="boo") ',
-          afterCursor: '',
-          dialect: 'hive',
-          hasLocations: true,
-          expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['COMMENT']
-          }
+      describe('Impala specific', function () {
+        it('should suggest keywords for "CREATE VIEW IF NOT EXISTS boo |"', function () {
+          assertAutoComplete({
+            beforeCursor: 'CREATE VIEW IF NOT EXISTS boo ',
+            afterCursor: '',
+            dialect: 'impala',
+            expectedResult: {
+              lowerCase: false,
+              suggestKeywords: ['AS']
+            }
+          });
         });
       });
     });
+
   });
 });

+ 300 - 12
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecDrop.js

@@ -54,28 +54,26 @@ define([
     });
 
     describe('hive specific', function () {
-      it('should suggest keywords for "DROP |"', function() {
+      it('should suggest keywords for "DROP |"', function () {
         assertAutoComplete({
           beforeCursor: 'DROP ',
           afterCursor: '',
           dialect: 'hive',
           expectedResult: {
             lowerCase: false,
-            suggestKeywords: ['DATABASE', 'FUNCTION', 'INDEX', 'MACRO', 'ROLE', 'SCHEMA', 'TABLE', 'TEMPORARY FUNCTION', 'TEMPORARY MACRO', 'VIEW']
+            suggestKeywords: ['DATABASE', 'FUNCTION', 'INDEX', 'ROLE', 'SCHEMA', 'TABLE', 'TEMPORARY FUNCTION', 'TEMPORARY MACRO', 'VIEW']
           }
         });
       });
-    });
 
-    describe('hive specific', function () {
-      it('should follow case for "drop |"', function() {
+      it('should follow case for "drop |"', function () {
         assertAutoComplete({
           beforeCursor: 'drop ',
           afterCursor: '',
           dialect: 'hive',
+          containsKeywords: ['DATABASE'],
           expectedResult: {
-            lowerCase: true,
-            suggestKeywords: ['DATABASE', 'FUNCTION', 'INDEX', 'MACRO', 'ROLE', 'SCHEMA', 'TABLE', 'TEMPORARY FUNCTION', 'TEMPORARY MACRO', 'VIEW']
+            lowerCase: true
           }
         });
       });
@@ -95,7 +93,7 @@ define([
       });
     });
 
-    describe('drop database statements', function () {
+    describe('DROP DATABASE', function () {
       it('should suggest databases for "DROP DATABASE |"', function() {
         assertAutoComplete({
           beforeCursor: 'DROP DATABASE ',
@@ -160,14 +158,79 @@ define([
       });
     });
 
-    describe('drop table statements', function () {
+    describe('DROP INDEX', function () {
+      it('should handle "DROP INDEX IF EXISTS baa ON baa.boo;|"', function() {
+        assertAutoComplete({
+          beforeCursor: 'DROP INDEX IF EXISTS baa ON baa.boo;',
+          afterCursor: '',
+          dialect: 'hive',
+          noErrors: true,
+          containsKeywords: ['SELECT'],
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false
+          }
+        });
+      });
+
+      it('should suggest keywords for "DROP INDEX |"', function() {
+        assertAutoComplete({
+          beforeCursor: 'DROP INDEX ',
+          afterCursor: '',
+          dialect: 'hive',
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['IF EXISTS']
+          }
+        });
+      });
+
+      it('should suggest keywords for "DROP INDEX IF |"', function() {
+        assertAutoComplete({
+          beforeCursor: 'DROP INDEX IF ',
+          afterCursor: '',
+          dialect: 'hive',
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['EXISTS']
+          }
+        });
+      });
+
+      it('should suggest keywords for "DROP INDEX baa |"', function() {
+        assertAutoComplete({
+          beforeCursor: 'DROP INDEX baa ',
+          afterCursor: '',
+          dialect: 'hive',
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['ON']
+          }
+        });
+      });
+
+      it('should suggest tabls for "DROP INDEX baa ON |"', function() {
+        assertAutoComplete({
+          beforeCursor: 'DROP INDEX baa ON ',
+          afterCursor: '',
+          dialect: 'hive',
+          expectedResult: {
+            lowerCase: false,
+            suggestTables: {},
+            suggestDatabases: { appendDot: true }
+          }
+        });
+      });
+    });
+
+    describe('DROP TABLE', function () {
       it('should suggest tables for "DROP TABLE |"', function() {
         assertAutoComplete({
           beforeCursor: 'DROP TABLE ',
           afterCursor: '',
           expectedResult: {
             lowerCase: false,
-            suggestTables: {},
+            suggestTables: { onlyTables: true },
             suggestKeywords: ['IF EXISTS'],
             suggestDatabases: {
               appendDot: true
@@ -182,7 +245,7 @@ define([
           afterCursor: '',
           expectedResult: {
             lowerCase: false,
-            suggestTables: { database: 'db' }
+            suggestTables: { onlyTables: true, database: 'db' }
           }
         });
       });
@@ -204,7 +267,7 @@ define([
           afterCursor: '',
           expectedResult: {
             lowerCase: false,
-            suggestTables: {},
+            suggestTables: { onlyTables: true },
             suggestDatabases: {
               appendDot: true
             }
@@ -229,5 +292,230 @@ define([
         });
       });
     });
+
+    describe('DROP TEMPORARY MACRO', function () {
+      it('should handle "DROP TEMPORARY MACRO IF EXISTS boo;|', function () {
+        assertAutoComplete({
+          beforeCursor: 'DROP TEMPORARY MACRO IF EXISTS boo;',
+          afterCursor: '',
+          dialect: 'hive',
+          containsKeywords: ['SELECT'],
+          noErrors: true,
+          expectedResult: {
+            lowerCase: false
+          }
+        });
+      });
+
+      it('should suggest keywords for "DROP |', function () {
+        assertAutoComplete({
+          beforeCursor: 'DROP ',
+          afterCursor: '',
+          dialect: 'hive',
+          containsKeywords: ['TEMPORARY MACRO'],
+          noErrors: true,
+          expectedResult: {
+            lowerCase: false
+          }
+        });
+      });
+
+      it('should suggest keywords for "DROP TEMPORARY |', function () {
+        assertAutoComplete({
+          beforeCursor: 'DROP TEMPORARY ',
+          afterCursor: '',
+          dialect: 'hive',
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['MACRO']
+          }
+        });
+      });
+
+      it('should suggest keywords for "DROP TEMPORARY MACRO |', function () {
+        assertAutoComplete({
+          beforeCursor: 'DROP TEMPORARY MACRO ',
+          afterCursor: '',
+          dialect: 'hive',
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['IF EXISTS']
+          }
+        });
+      });
+
+      it('should suggest keywords for "DROP TEMPORARY MACRO IF |', function () {
+        assertAutoComplete({
+          beforeCursor: 'DROP TEMPORARY MACRO IF ',
+          afterCursor: '',
+          dialect: 'hive',
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['EXISTS']
+          }
+        });
+      });
+    });
+
+    describe('DROP VIEW', function () {
+      it('should handle "DROP VIEW boo;|', function () {
+        assertAutoComplete({
+          beforeCursor: 'DROP VIEW boo;',
+          afterCursor: '',
+          containsKeywords: ['SELECT'],
+          noErrors: true,
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false
+          }
+        });
+      });
+
+      it('should handle "DROP VIEW IF EXISTS baa.boo;|', function () {
+        assertAutoComplete({
+          beforeCursor: 'DROP VIEW IF EXISTS baa.boo;',
+          afterCursor: '',
+          containsKeywords: ['SELECT'],
+          noErrors: true,
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false
+          }
+        });
+      });
+
+      it('should suggest views for "DROP VIEW |', function () {
+        assertAutoComplete({
+          beforeCursor: 'DROP VIEW ',
+          afterCursor: '',
+          noErrors: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestTables: { onlyViews: true },
+            suggestDatabases: { appendDot:true },
+            suggestKeywords: ['IF EXISTS']
+          }
+        });
+      });
+
+      it('should suggest keywords for "DROP VIEW IF |', function () {
+        assertAutoComplete({
+          beforeCursor: 'DROP VIEW IF ',
+          afterCursor: '',
+          noErrors: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['EXISTS']
+          }
+        });
+      });
+
+      it('should suggest views for "DROP VIEW boo.|', function () {
+        assertAutoComplete({
+          beforeCursor: 'DROP VIEW boo.',
+          afterCursor: '',
+          noErrors: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestTables: { database: 'boo', onlyViews: true }
+          }
+        });
+      });
+    });
+
+    describe('TRUNCATE TABLE', function () {
+      it('should handle "TRUNCATE TABLE baa.boo;"', function() {
+        assertAutoComplete({
+          beforeCursor: 'TRUNCATE TABLE baa.boo;',
+          afterCursor: '',
+          dialect: 'generic',
+          containsKeywords: ['SELECT'],
+          noErrors: true,
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false
+          }
+        });
+      });
+
+      it('should suggest keywords for "TRUNCATE |"', function() {
+        assertAutoComplete({
+          beforeCursor: 'truncate ',
+          afterCursor: '',
+          dialect: 'generic',
+          expectedResult: {
+            lowerCase: true,
+            suggestKeywords: ['TABLE']
+          }
+        });
+      });
+
+      it('should suggest tables for "TRUNCATE TABLE |"', function() {
+        assertAutoComplete({
+          beforeCursor: 'TRUNCATE TABLE ',
+          afterCursor: '',
+          dialect: 'generic',
+          expectedResult: {
+            lowerCase: false,
+            suggestTables: {},
+            suggestDatabases: { appendDot: true }
+          }
+        });
+      });
+
+      describe('Hive specific', function () {
+        it('should handle "TRUNCATE TABLE boo PARTITION (baa=1, boo = \'baa\'); |"', function() {
+          assertAutoComplete({
+            beforeCursor: 'TRUNCATE TABLE boo PARTITION (baa=1, boo = \'baa\'); ',
+            afterCursor: '',
+            dialect: 'hive',
+            containsKeywords: ['SELECT'],
+            noErrors: true,
+            hasLocations: true,
+            expectedResult: {
+              lowerCase: false
+            }
+          });
+        });
+
+        it('should suggest keywords for "TRUNCATE |"', function() {
+          assertAutoComplete({
+            beforeCursor: 'TRUNCATE ',
+            afterCursor: '',
+            dialect: 'hive',
+            expectedResult: {
+              lowerCase: false,
+              suggestKeywords: ['TABLE']
+            }
+          });
+        });
+
+        it('should suggest tables for "TRUNCATE TABLE |"', function() {
+          assertAutoComplete({
+            beforeCursor: 'TRUNCATE TABLE ',
+            afterCursor: '',
+            dialect: 'hive',
+            expectedResult: {
+              lowerCase: false,
+              suggestTables: {},
+              suggestDatabases: { appendDot: true }
+            }
+          });
+        });
+
+        it('should suggest keywords for "TRUNCATE TABLE boo |"', function() {
+          assertAutoComplete({
+            beforeCursor: 'TRUNCATE TABLE boo ',
+            afterCursor: '',
+            dialect: 'hive',
+            hasLocations: true,
+            expectedResult: {
+              lowerCase: false,
+              suggestKeywords: ['PARTITION']
+            }
+          });
+        });
+      });
+    })
   });
 });

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