Browse Source

HUE-4586 [editor] The new autocompleter should completely support SELECT

This takes care of the remaining parts of the SELECT statement:

- TABLESAMPLE
- Virtual columns
- LATERAL VIEW OUTER
- STRAIGHT_JOIN

It should now be complete according to the Hive and Impala docs
Johan Ahlen 9 years ago
parent
commit
8e2c3eb

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

@@ -48,6 +48,8 @@
 <hive>'LATERAL'                            { return '<hive>LATERAL'; }
 <hive>'LATERAL'                            { return '<hive>LATERAL'; }
 <hive>'MACRO'                              { return '<hive>MACRO'; }
 <hive>'MACRO'                              { return '<hive>MACRO'; }
 <hive>'MAP'                                { return '<hive>MAP'; }
 <hive>'MAP'                                { return '<hive>MAP'; }
+<hive>'OF'                                 { return '<hive>OF'; }
+<hive>'OUT'                                { return '<hive>OUT'; }
 <hive>'ROLLUP'                             { return '<hive>ROLLUP'; }
 <hive>'ROLLUP'                             { return '<hive>ROLLUP'; }
 <hive>'TABLE'                              { return '<hive>TABLE'; }
 <hive>'TABLE'                              { return '<hive>TABLE'; }
 <hive>'USER'                               { return '<hive>USER'; }
 <hive>'USER'                               { return '<hive>USER'; }
@@ -60,6 +62,7 @@
 <hive>'ARCHIVE'                            { return '<hive>ARCHIVE'; }
 <hive>'ARCHIVE'                            { return '<hive>ARCHIVE'; }
 <hive>'ASC'                                { return '<hive>ASC'; }
 <hive>'ASC'                                { return '<hive>ASC'; }
 <hive>'AVRO'                               { return '<hive>AVRO'; }
 <hive>'AVRO'                               { return '<hive>AVRO'; }
+<hive>'BUCKET'                             { return '<hive>BUCKET'; }
 <hive>'BUCKETS'                            { return '<hive>BUCKETS'; }
 <hive>'BUCKETS'                            { return '<hive>BUCKETS'; }
 <hive>'CACHE'                              { return '<hive>CACHE'; }
 <hive>'CACHE'                              { return '<hive>CACHE'; }
 <hive>'CASCADE'                            { return '<hive>CASCADE'; }
 <hive>'CASCADE'                            { return '<hive>CASCADE'; }
@@ -143,6 +146,7 @@
 <hive>'STRING'                             { return '<hive>STRING'; }
 <hive>'STRING'                             { return '<hive>STRING'; }
 <hive>'STRUCT'                             { return '<hive>STRUCT'; }
 <hive>'STRUCT'                             { return '<hive>STRUCT'; }
 <hive>'TABLES'                             { return '<hive>TABLES'; }
 <hive>'TABLES'                             { return '<hive>TABLES'; }
+<hive>'TABLESAMPLE'                        { return '<hive>TABLESAMPLE'; }
 <hive>'TBLPROPERTIES'                      { return '<hive>TBLPROPERTIES'; }
 <hive>'TBLPROPERTIES'                      { return '<hive>TBLPROPERTIES'; }
 <hive>'TEMPORARY'                          { return '<hive>TEMPORARY'; }
 <hive>'TEMPORARY'                          { return '<hive>TEMPORARY'; }
 <hive>'TERMINATED'                         { return '<hive>TERMINATED'; }
 <hive>'TERMINATED'                         { return '<hive>TERMINATED'; }
@@ -213,6 +217,7 @@
 <impala>'SERIALIZE_FN'                     { return '<impala>SERIALIZE_FN'; }
 <impala>'SERIALIZE_FN'                     { return '<impala>SERIALIZE_FN'; }
 <impala>'STATS'                            { return '<impala>STATS'; }
 <impala>'STATS'                            { return '<impala>STATS'; }
 <impala>'STORED'                           { return '<impala>STORED'; }
 <impala>'STORED'                           { return '<impala>STORED'; }
+<impala>'STRAIGHT_JOIN'                    { return '<impala>STRAIGHT_JOIN'; }
 <impala>'SYMBOL'                           { return '<impala>SYMBOL'; }
 <impala>'SYMBOL'                           { return '<impala>SYMBOL'; }
 <impala>'TABLE'                            { return '<impala>TABLE'; }
 <impala>'TABLE'                            { return '<impala>TABLE'; }
 <impala>'TABLES'                           { return '<impala>TABLES'; }
 <impala>'TABLES'                           { return '<impala>TABLES'; }

+ 123 - 40
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_main.jison

@@ -34,6 +34,7 @@ NonReservedKeyword
  | '<hive>ANALYZE'
  | '<hive>ANALYZE'
  | '<hive>ARCHIVE'
  | '<hive>ARCHIVE'
  | '<hive>AVRO'
  | '<hive>AVRO'
+ | '<hive>BUCKET'
  | '<hive>BUCKETS'
  | '<hive>BUCKETS'
  | '<hive>CACHE'
  | '<hive>CACHE'
  | '<hive>CASCADE'
  | '<hive>CASCADE'
@@ -200,8 +201,8 @@ SqlStatement_EDIT
 // This is a work-around for error handling when a statement starts with some token that the parser can understand but
 // 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.)
 // it's not a valid statement (see ErrorStatement). It contains everything except valid starting tokens ('SELECT', 'USE' etc.)
 NonStartingToken
 NonStartingToken
- : '<hive>ALL' | '<hive>ARRAY' | '<hive>AS' | '<hive>AVRO' | '<hive>BINARY' | '<hive>BUCKETS' | '<hive>CACHE' | '<hive>CLUSTER' | '<hive>CLUSTERED' | '<hive>COLLECTION' | '<hive>COMPUTE' | '<hive>CONF' | '<hive>CROSS' | '<hive>CUBE' | '<hive>CURRENT' | '<hive>DATE' | '<hive>DEFERRED' | '<hive>DELIMITED' | '<hive>DISTRIBUTE' | '<hive>DISTRIBUTED' | '<hive>ESCAPED' | '<hive>EXTENDED' | '<hive>EXTERNAL' | '<hive>FIELDS' | '<hive>FILE' | '<hive>FOR' | '<hive>FORMAT' | '<hive>FUNCTION' | '<hive>GRANT' | '<hive>GROUPING' | '<hive>IDXPROPERTIES' | '<hive>LATERAL' | '<hive>MACRO' | '<hive>PARTITION' | '<hive>REBUILD' | '<hive>REPAIR' | '<hive>ROLLUP' | '<hive>SETS' | '<hive>STATISTICS' | '<hive>TABLE' | '<hive>USER' | '<hive>ASC' | '<hive>COLUMNS' | '<hive>COMMENT' | '<hive>COMPACTIONS' | '<hive>DATA' | '<hive>DATABASES' | '<hive>DEFINED' | '<hive>DESC' |  '<hive>FORMATTED' | '<hive>FUNCTIONS' | '<hive>INDEX' | '<hive>INDEXES' | '<hive>INPATH' | '<hive>INPUTFORMAT' | '<hive>ITEMS' | '<hive>JAR' | '<hive>KEYS' | '<hive>LINES' | '<hive>LIMIT' | '<hive>LOCATION' | '<hive>LOCKS' | '<hive>MAP' | '<hive>METADATA' | '<hive>NOSCAN' | '<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>STORED_AS_DIRECTORIES' | '<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>]'
+ : '<hive>ALL' | '<hive>ARRAY' | '<hive>AS' | '<hive>AVRO' | '<hive>BINARY' | '<hive>BUCKET' | '<hive>BUCKETS' | '<hive>CACHE' | '<hive>CLUSTER' | '<hive>CLUSTERED' | '<hive>COLLECTION' | '<hive>COMPUTE' | '<hive>CONF' | '<hive>CROSS' | '<hive>CUBE' | '<hive>CURRENT' | '<hive>DATE' | '<hive>DEFERRED' | '<hive>DELIMITED' | '<hive>DISTRIBUTE' | '<hive>DISTRIBUTED' | '<hive>ESCAPED' | '<hive>EXTENDED' | '<hive>EXTERNAL' | '<hive>FIELDS' | '<hive>FILE' | '<hive>FOR' | '<hive>FORMAT' | '<hive>FUNCTION' | '<hive>GRANT' | '<hive>GROUPING' | '<hive>IDXPROPERTIES' | '<hive>LATERAL' | '<hive>MACRO' | '<hive>PARTITION' | '<hive>REBUILD' | '<hive>REPAIR' | '<hive>ROLLUP' | '<hive>SETS' | '<hive>STATISTICS' | '<hive>TABLE' | '<hive>USER' | '<hive>ASC' | '<hive>COLUMNS' | '<hive>COMMENT' | '<hive>COMPACTIONS' | '<hive>DATA' | '<hive>DATABASES' | '<hive>DEFINED' | '<hive>DESC' |  '<hive>FORMATTED' | '<hive>FUNCTIONS' | '<hive>INDEX' | '<hive>INDEXES' | '<hive>INPATH' | '<hive>INPUTFORMAT' | '<hive>ITEMS' | '<hive>JAR' | '<hive>KEYS' | '<hive>LINES' | '<hive>LIMIT' | '<hive>LOCATION' | '<hive>LOCKS' | '<hive>MAP' | '<hive>METADATA' | '<hive>NOSCAN' | '<hive>OF' | '<hive>ORC' | '<hive>OUT' | '<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>STORED_AS_DIRECTORIES' | '<hive>STRING' | '<hive>STRUCT' | '<hive>TABLES' | '<hive>TABLESAMPLE' | '<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>STRAIGHT_JOIN' | '<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' | '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'
  | 'ALL' | 'AS' | 'ASC' | 'BETWEEN' | 'BIGINT' | 'BOOLEAN' | 'BY' | 'CASE' | 'CHAR' | 'CURRENT' | 'DATABASE' | 'DECIMAL' | 'DISTINCT' | 'DOUBLE' | 'DESC' | 'ELSE' | 'END' | 'EXISTS' | 'FALSE' | 'FLOAT' | 'FOLLOWING' | 'FROM' | 'FULL' | 'GROUP' | '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'
  | 'AVG' | 'CAST' | 'COUNT' | 'MAX' | 'MIN' | 'STDDEV_POP' | 'STDDEV_SAMP' | 'SUM' | 'VARIANCE' | 'VAR_POP' | 'VAR_SAMP'
  | '<hive>COLLECT_SET' | '<hive>COLLECT_LIST' | '<hive>CORR' | '<hive>COVAR_POP' | '<hive>COVAR_SAMP' | '<hive>HISTOGRAM_NUMERIC' | '<hive>NTILE' | '<hive>PERCENTILE' | '<hive>PERCENTILE_APPROX'
  | '<hive>COLLECT_SET' | '<hive>COLLECT_LIST' | '<hive>CORR' | '<hive>COVAR_POP' | '<hive>COVAR_SAMP' | '<hive>HISTOGRAM_NUMERIC' | '<hive>NTILE' | '<hive>PERCENTILE' | '<hive>PERCENTILE_APPROX'
@@ -1148,15 +1149,19 @@ SelectStatement_EDIT
  : 'SELECT' OptionalAllOrDistinct SelectList_EDIT
  : 'SELECT' OptionalAllOrDistinct SelectList_EDIT
    {
    {
      if ($3.cursorAtStart) {
      if ($3.cursorAtStart) {
+       var keywords = [];
        if ($2) {
        if ($2) {
-         suggestKeywords([{ value: '*', weight: 1000 }]);
+         keywords = [{ value: '*', weight: 1000 }];
        } else {
        } else {
-         suggestKeywords([{ value: '*', weight: 1000 }, 'ALL', 'DISTINCT']);
+         keywords = [{ value: '*', weight: 1000 }, 'ALL', 'DISTINCT'];
+       }
+       if (isImpala()) {
+         keywords.push('STRAIGHT_JOIN');
        }
        }
+       suggestKeywords(keywords);
      } else {
      } else {
        checkForSelectListKeywords($3);
        checkForSelectListKeywords($3);
      }
      }
-
      if ($3.suggestAggregateFunctions && (!$2 || $2 === 'ALL')) {
      if ($3.suggestAggregateFunctions && (!$2 || $2 === 'ALL')) {
        suggestAggregateFunctions();
        suggestAggregateFunctions();
        suggestAnalyticFunctions();
        suggestAnalyticFunctions();
@@ -1164,17 +1169,22 @@ SelectStatement_EDIT
    }
    }
  | 'SELECT' OptionalAllOrDistinct 'CURSOR'
  | 'SELECT' OptionalAllOrDistinct 'CURSOR'
    {
    {
+     var keywords = [];
      if ($2) {
      if ($2) {
-       suggestKeywords([{ value: '*', weight: 1000 }]);
+       keywords = [{ value: '*', weight: 1000 }];
        if ($2 === 'ALL') {
        if ($2 === 'ALL') {
          suggestAggregateFunctions();
          suggestAggregateFunctions();
          suggestAnalyticFunctions();
          suggestAnalyticFunctions();
        }
        }
      } else {
      } else {
-       suggestKeywords([{ value: '*', weight: 1000 }, 'ALL', 'DISTINCT']);
+       keywords = [{ value: '*', weight: 1000 }, 'ALL', 'DISTINCT'];
        suggestAggregateFunctions();
        suggestAggregateFunctions();
        suggestAnalyticFunctions();
        suggestAnalyticFunctions();
      }
      }
+     if (isImpala()) {
+       keywords.push('STRAIGHT_JOIN');
+     }
+     suggestKeywords(keywords);
      suggestFunctions();
      suggestFunctions();
      suggestColumns();
      suggestColumns();
      suggestTables({ prependQuestionMark: true, prependFrom: true });
      suggestTables({ prependQuestionMark: true, prependFrom: true });
@@ -1185,11 +1195,16 @@ SelectStatement_EDIT
  | 'SELECT' OptionalAllOrDistinct SelectList_EDIT TableExpression
  | 'SELECT' OptionalAllOrDistinct SelectList_EDIT TableExpression
    {
    {
      if ($3.cursorAtStart) {
      if ($3.cursorAtStart) {
+       var keywords = [];
        if ($2) {
        if ($2) {
-         suggestKeywords([{ value: '*', weight: 1000 }]);
+         keywords = [{ value: '*', weight: 1000 }];
        } else {
        } else {
-         suggestKeywords([{ value: '*', weight: 1000 }, 'ALL', 'DISTINCT']);
+         keywords = [{ value: '*', weight: 1000 }, 'ALL', 'DISTINCT'];
+       }
+       if (isImpala()) {
+         keywords.push('STRAIGHT_JOIN');
        }
        }
+       suggestKeywords(keywords);
      } else {
      } else {
        checkForKeywords($3);
        checkForKeywords($3);
      }
      }
@@ -1201,17 +1216,22 @@ SelectStatement_EDIT
    }
    }
  | 'SELECT' OptionalAllOrDistinct 'CURSOR' TableExpression
  | 'SELECT' OptionalAllOrDistinct 'CURSOR' TableExpression
    {
    {
+     var keywords = [];
      if ($2) {
      if ($2) {
-       suggestKeywords([{ value: '*', weight: 1000 }]);
+       keywords = [{ value: '*', weight: 1000 }];
        if ($2 === 'ALL') {
        if ($2 === 'ALL') {
          suggestAggregateFunctions();
          suggestAggregateFunctions();
          suggestAnalyticFunctions();
          suggestAnalyticFunctions();
        }
        }
      } else {
      } else {
-       suggestKeywords([{ value: '*', weight: 1000 }, 'ALL', 'DISTINCT']);
+       keywords = [{ value: '*', weight: 1000 }, 'ALL', 'DISTINCT'];
        suggestAggregateFunctions();
        suggestAggregateFunctions();
        suggestAnalyticFunctions();
        suggestAnalyticFunctions();
      }
      }
+     if (isImpala()) {
+       keywords.push('STRAIGHT_JOIN');
+     }
+     suggestKeywords(keywords);
      suggestFunctions();
      suggestFunctions();
      suggestColumns();
      suggestColumns();
      suggestTables({ prependQuestionMark: true, prependFrom: true });
      suggestTables({ prependQuestionMark: true, prependFrom: true });
@@ -1311,7 +1331,7 @@ TableExpression_EDIT
            keywords.push({ value: 'USING', weight: 3 });
            keywords.push({ value: 'USING', weight: 3 });
          }
          }
        } else if ($1 && $1.suggestKeywords) {
        } else if ($1 && $1.suggestKeywords) {
-         keywords = createWeightedKeywords($1.suggestKeywords, 1);
+         keywords = createWeightedKeywords($1.suggestKeywords, 3);
        } else if ($1 && $1.types) {
        } else if ($1 && $1.types) {
          var veKeywords = getValueExpressionKeywords($1);
          var veKeywords = getValueExpressionKeywords($1);
          keywords = veKeywords.suggestKeywords;
          keywords = veKeywords.suggestKeywords;
@@ -1395,7 +1415,7 @@ OptionalSelectConditions_EDIT
 
 
      keywords = keywords.concat([{ value: 'FULL JOIN', weight: 1 }, { value: 'FULL OUTER JOIN', weight: 1 }, { value: 'JOIN', weight: 1 }, { value: 'LEFT JOIN', weight: 1 }, { value: 'LEFT OUTER JOIN', weight: 1 }, { value: 'RIGHT JOIN', weight: 1 }, { value: 'RIGHT OUTER JOIN', weight: 1 }]);
      keywords = keywords.concat([{ value: 'FULL JOIN', weight: 1 }, { value: 'FULL OUTER JOIN', weight: 1 }, { value: 'JOIN', weight: 1 }, { value: 'LEFT JOIN', weight: 1 }, { value: 'LEFT OUTER JOIN', weight: 1 }, { value: 'RIGHT JOIN', weight: 1 }, { value: 'RIGHT OUTER JOIN', weight: 1 }]);
      if (isHive()) {
      if (isHive()) {
-       keywords = keywords.concat([{ value: 'LATERAL VIEW', weight: 1 }, { value: 'CROSS JOIN', weight: 1 }, { value: 'LEFT SEMI JOIN', weight: 1 }]);
+       keywords = keywords.concat([{ value: 'CROSS JOIN', weight: 1 }, { value: 'LEFT SEMI JOIN', weight: 1 }]);
      } else if (isImpala()) {
      } else if (isImpala()) {
        keywords = keywords.concat([{ value: 'INNER JOIN', weight: 1 },  { value: 'LEFT ANTI JOIN', weight: 1 }, { value: 'LEFT SEMI JOIN', weight: 1 }, { value: 'RIGHT ANTI JOIN', weight: 1 }, { value: 'RIGHT SEMI JOIN', weight: 1 }]);
        keywords = keywords.concat([{ value: 'INNER JOIN', weight: 1 },  { value: 'LEFT ANTI JOIN', weight: 1 }, { value: 'LEFT SEMI JOIN', weight: 1 }, { value: 'RIGHT ANTI JOIN', weight: 1 }, { value: 'RIGHT SEMI JOIN', weight: 1 }]);
      } else {
      } else {
@@ -2109,9 +2129,11 @@ TableReferenceList
 
 
 TableReferenceList_EDIT
 TableReferenceList_EDIT
  : TableReference_EDIT
  : TableReference_EDIT
- | TableReferenceList_EDIT ',' TableReference
+ | TableReference_EDIT ',' TableReference
+// | TableReferenceList 'CURSOR' ',' TableReferenceList   // TODO: Causes conflict for some reason
  | TableReferenceList ',' TableReference_EDIT
  | TableReferenceList ',' TableReference_EDIT
- | TableReferenceList ',' 'CURSOR'
+ | TableReferenceList ',' TableReference_EDIT ',' TableReferenceList
+ | TableReferenceList ',' AnyCursor
    {
    {
        suggestTables();
        suggestTables();
        suggestDatabases({ appendDot: true });
        suggestDatabases({ appendDot: true });
@@ -2311,19 +2333,21 @@ JoinCondition_EDIT
  ;
  ;
 
 
 TablePrimary
 TablePrimary
- : TableOrQueryName OptionalCorrelationName OptionalLateralViews
+ : TableOrQueryName OptionalTableSample OptionalCorrelationName OptionalLateralViews
    {
    {
      if ($1.identifierChain) {
      if ($1.identifierChain) {
-       if ($2) {
-         $1.alias = $2
+       if ($3) {
+         $1.alias = $3
        }
        }
-       if ($3 && $3.length > 0) {
-         $1.lateralViews = $3;
+       if ($4 && $4.length > 0) {
+         $1.lateralViews = $4;
        }
        }
        addTablePrimary($1);
        addTablePrimary($1);
      }
      }
+     // Right-to-left for cursor after TablePrimary
+     $$.suggestKeywords = getKeywordsForOptionalsLR([$4, $3, $2], [{ value: 'LATERAL VIEW', weight: 1 }, { value: 'AS', weight: 2 }, { value: 'TABLESAMPLE', weight: 3 }], [isHive(), true, isHive()]);
    }
    }
- | DerivedTable OptionalCorrelationName
+ | DerivedTable OptionalCorrelationName OptionalLateralViews
    {
    {
       if ($2) {
       if ($2) {
        $1.alias = $2;
        $1.alias = $2;
@@ -2333,22 +2357,32 @@ TablePrimary
  ;
  ;
 
 
 TablePrimary_EDIT
 TablePrimary_EDIT
- : TableOrQueryName_EDIT OptionalCorrelationName OptionalLateralViews
- | TableOrQueryName OptionalCorrelationName OptionalLateralViews_EDIT
+ : TableOrQueryName_EDIT OptionalTableSample OptionalCorrelationName OptionalLateralViews
+ | TableOrQueryName OptionalTableSample_EDIT OptionalCorrelationName OptionalLateralViews
    {
    {
-     if ($2) {
-       $1.alias = $2;
+     if ($3) {
+       $1.alias = $3;
      }
      }
      addTablePrimary($1);
      addTablePrimary($1);
    }
    }
- | DerivedTable_EDIT OptionalCorrelationName
+ | TableOrQueryName OptionalTableSample OptionalCorrelationName OptionalLateralViews_EDIT
+   {
+     if ($3) {
+       $1.alias = $3;
+     }
+     addTablePrimary($1);
+   }
+ | DerivedTable_EDIT OptionalCorrelationName OptionalLateralViews
    {
    {
      if ($2) {
      if ($2) {
-       // TODO: Potentially add columns for SELECT bla.| FROM (SELECT * FROM foo) AS bla;
        addTablePrimary({ subQueryAlias: $2 });
        addTablePrimary({ subQueryAlias: $2 });
      }
      }
    }
    }
- | DerivedTable OptionalCorrelationName_EDIT // TODO: OptionalLateralViews?
+ | DerivedTable OptionalCorrelationName_EDIT OptionalLateralViews
+ | DerivedTable OptionalCorrelationName OptionalLateralViews_EDIT
+   if ($2) {
+     addTablePrimary({ subQueryAlias: $2 });
+   }
  ;
  ;
 
 
 TableOrQueryName
 TableOrQueryName
@@ -2367,6 +2401,46 @@ DerivedTable_EDIT
  : TableSubQuery_EDIT
  : TableSubQuery_EDIT
  ;
  ;
 
 
+OptionalTableSample
+ :
+ | '<hive>TABLESAMPLE' '(' '<hive>BUCKET' 'UNSIGNED_INTEGER' '<hive>OUT' '<hive>OF' 'UNSIGNED_INTEGER' OptionalOnColumn ')'
+ ;
+
+OptionalTableSample_EDIT
+ : '<hive>TABLESAMPLE' '(' AnyCursor RightParenthesisOrError
+   {
+     suggestKeywords(['BUCKET']);
+   }
+ | '<hive>TABLESAMPLE' '(' '<hive>BUCKET' 'UNSIGNED_INTEGER' 'CURSOR' RightParenthesisOrError
+   {
+     suggestKeywords(['OUT OF']);
+   }
+ | '<hive>TABLESAMPLE' '(' '<hive>BUCKET' 'UNSIGNED_INTEGER' '<hive>OUT' 'CURSOR' RightParenthesisOrError
+   {
+     suggestKeywords(['OF']);
+   }
+ | '<hive>TABLESAMPLE' '(' '<hive>BUCKET' 'UNSIGNED_INTEGER' '<hive>OUT' '<hive>OF' 'UNSIGNED_INTEGER' OptionalOnColumn 'CURSOR' RightParenthesisOrError
+   {
+     if (!$8) {
+       suggestKeywords(['ON']);
+     }
+   }
+ | '<hive>TABLESAMPLE' '(' '<hive>BUCKET' 'UNSIGNED_INTEGER' '<hive>OUT' '<hive>OF' 'UNSIGNED_INTEGER' OptionalOnColumn_EDIT RightParenthesisOrError
+ ;
+
+OptionalOnColumn
+ :
+ | 'ON' ValueExpression
+ ;
+
+OptionalOnColumn_EDIT
+ : 'ON' 'CURSOR'
+   {
+     valueExpressionSuggest();
+   }
+ | 'ON' ValueExpression_EDIT
+ ;
+
 PushQueryState
 PushQueryState
  :
  :
    {
    {
@@ -3123,34 +3197,38 @@ SumFunction_EDIT
  ;
  ;
 
 
 LateralView
 LateralView
- : '<hive>LATERAL' '<hive>VIEW' UserDefinedFunction RegularIdentifier LateralViewColumnAliases  -> [{ udtf: $3, tableAlias: $4, columnAliases: $5 }]
- | '<hive>LATERAL' '<hive>VIEW' UserDefinedFunction LateralViewColumnAliases                    -> [{ udtf: $3, columnAliases: $4 }]
+ : '<hive>LATERAL' '<hive>VIEW' OptionalOuter UserDefinedFunction RegularIdentifier LateralViewColumnAliases  -> [{ udtf: $4, tableAlias: $5, columnAliases: $6 }]
+ | '<hive>LATERAL' '<hive>VIEW' OptionalOuter UserDefinedFunction LateralViewColumnAliases                    -> [{ udtf: $4, columnAliases: $5 }]
  | LateralView_INVALID
  | LateralView_INVALID
  ;
  ;
 
 
 LateralView_INVALID
 LateralView_INVALID
- : '<hive>LATERAL' '<hive>VIEW' UserDefinedFunction RegularIdentifier error                     -> []
- | '<hive>LATERAL' '<hive>VIEW' UserDefinedFunction error                                       -> []
- | '<hive>LATERAL' '<hive>VIEW' error                                                           -> []
- | '<hive>LATERAL' error                                                                        -> []
+ : '<hive>LATERAL' '<hive>VIEW' OptionalOuter UserDefinedFunction RegularIdentifier error  -> []
+ | '<hive>LATERAL' '<hive>VIEW' OptionalOuter UserDefinedFunction error                    -> []
+ | '<hive>LATERAL' '<hive>VIEW' OptionalOuter error                                        -> []
+ | '<hive>LATERAL' error                                                                   -> []
  ;
  ;
 
 
 LateralView_EDIT
 LateralView_EDIT
- : '<hive>LATERAL' '<hive>VIEW' UserDefinedFunction_EDIT
- | '<hive>LATERAL' '<hive>VIEW' UserDefinedFunction_EDIT LateralViewColumnAliases
- | '<hive>LATERAL' '<hive>VIEW' UserDefinedFunction RegularIdentifier 'CURSOR'
+ : '<hive>LATERAL' '<hive>VIEW' OptionalOuter UserDefinedFunction_EDIT
+ | '<hive>LATERAL' '<hive>VIEW' OptionalOuter UserDefinedFunction_EDIT LateralViewColumnAliases
+ | '<hive>LATERAL' '<hive>VIEW' OptionalOuter UserDefinedFunction RegularIdentifier 'CURSOR'
    {
    {
      suggestKeywords(['AS']);
      suggestKeywords(['AS']);
      $$ = [];
      $$ = [];
    }
    }
- | '<hive>LATERAL' '<hive>VIEW' UserDefinedFunction 'CURSOR'
+ | '<hive>LATERAL' '<hive>VIEW' OptionalOuter UserDefinedFunction 'CURSOR'
    {
    {
      suggestKeywords(['AS']);
      suggestKeywords(['AS']);
      $$ = [];
      $$ = [];
    }
    }
- | '<hive>LATERAL' '<hive>VIEW' 'CURSOR'
+ | '<hive>LATERAL' '<hive>VIEW' OptionalOuter 'CURSOR'
    {
    {
-     suggestKeywords(['explode', 'posexplode']);
+     if (!$3) {
+       suggestKeywords([{ value: 'OUTER', weight: 2 }, { value: 'explode', weight: 1 }, { value: 'posexplode', weight: 1 }]);
+     } else {
+       suggestKeywords(['explode', 'posexplode']);
+     }
      $$ = [];
      $$ = [];
    }
    }
  | '<hive>LATERAL' 'CURSOR'
  | '<hive>LATERAL' 'CURSOR'
@@ -3160,6 +3238,11 @@ LateralView_EDIT
    }
    }
  ;
  ;
 
 
+OptionalOuter
+ :
+ | 'OUTER'
+ ;
+
 LateralViewColumnAliases
 LateralViewColumnAliases
  : '<hive>AS' RegularIdentifier                                -> [ $2 ]
  : '<hive>AS' RegularIdentifier                                -> [ $2 ]
  | '<hive>AS' '(' RegularIdentifier ',' RegularIdentifier ')'  -> [ $3, $5 ]
  | '<hive>AS' '(' RegularIdentifier ',' RegularIdentifier ')'  -> [ $3, $5 ]

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


+ 6 - 1
desktop/core/src/desktop/static/desktop/js/sqlAutocompleter2.js

@@ -39,7 +39,8 @@
 
 
   // Keyword weights come from the parser
   // Keyword weights come from the parser
   var DEFAULT_WEIGHTS = {
   var DEFAULT_WEIGHTS = {
-    COLUMN: 600,
+    COLUMN: 700,
+    VIRTUAL_COLUMN: 600,
     SAMPLE: 500,
     SAMPLE: 500,
     IDENTIFIER: 400,
     IDENTIFIER: 400,
     CTE: 300,
     CTE: 300,
@@ -163,6 +164,10 @@
         deferrals.push(self.addColumns(parseResult, editor, database, parseResult.suggestColumns.types || ['T'], completions));
         deferrals.push(self.addColumns(parseResult, editor, database, parseResult.suggestColumns.types || ['T'], completions));
         suggestColumnsDeferral.resolve();
         suggestColumnsDeferral.resolve();
       }
       }
+      if (typeof parseResult.suggestColumns.identifierChain === 'undefined' && self.snippet.type() === 'hive') {
+        completions.push({value: 'BLOCK__OFFSET__INSIDE__FILE', meta: 'virtual', weight: DEFAULT_WEIGHTS.VIRTUAL_COLUMN});
+        completions.push({value: 'INPUT__FILE__NAME', meta: 'virtual', weight: DEFAULT_WEIGHTS.VIRTUAL_COLUMN});
+      }
       deferrals.push(suggestColumnsDeferral);
       deferrals.push(suggestColumnsDeferral);
     }
     }
 
 

+ 154 - 41
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecSelect.js

@@ -119,7 +119,7 @@ define([
         hasLocations: true,
         hasLocations: true,
         expectedResult: {
         expectedResult: {
           lowerCase: false,
           lowerCase: false,
-          suggestKeywords: ['WHERE', 'GROUP BY', 'HAVING', 'ORDER BY', 'LIMIT', 'UNION', 'FULL JOIN', 'FULL OUTER JOIN', 'INNER JOIN', 'JOIN', 'LEFT JOIN', 'LEFT OUTER JOIN', 'RIGHT JOIN', 'RIGHT OUTER JOIN']
+          suggestKeywords: ['AS', 'WHERE', 'GROUP BY', 'HAVING', 'ORDER BY', 'LIMIT', 'UNION', 'FULL JOIN', 'FULL OUTER JOIN', 'INNER JOIN', 'JOIN', 'LEFT JOIN', 'LEFT OUTER JOIN', 'RIGHT JOIN', 'RIGHT OUTER JOIN']
         }
         }
       });
       });
     });
     });
@@ -595,7 +595,7 @@ define([
         });
         });
       });
       });
 
 
-    it('should handle "SELECT CASE cos(boo.a) > baa.boo \\n' +
+      it('should handle "SELECT CASE cos(boo.a) > baa.boo \\n' +
         '\\tWHEN baa.b THEN true \\n' +
         '\\tWHEN baa.b THEN true \\n' +
         '\\tWHEN boo.c THEN false \\n' +
         '\\tWHEN boo.c THEN false \\n' +
         '\\tWHEN baa.blue THEN boo.d \\n' +
         '\\tWHEN baa.blue THEN boo.d \\n' +
@@ -632,9 +632,9 @@ define([
         assertAutoComplete({
         assertAutoComplete({
           beforeCursor: 'SELECT ',
           beforeCursor: 'SELECT ',
           afterCursor: '',
           afterCursor: '',
+          containsKeywords: ['*', 'ALL', 'DISTINCT'],
           expectedResult: {
           expectedResult: {
             lowerCase: false,
             lowerCase: false,
-            suggestKeywords: ['*', 'ALL', 'DISTINCT'],
             suggestTables: {
             suggestTables: {
               prependQuestionMark: true,
               prependQuestionMark: true,
               prependFrom: true
               prependFrom: true
@@ -655,9 +655,9 @@ define([
         assertAutoComplete({
         assertAutoComplete({
           beforeCursor: 'select ',
           beforeCursor: 'select ',
           afterCursor: '',
           afterCursor: '',
+          containsKeywords: ['*', 'ALL', 'DISTINCT'],
           expectedResult: {
           expectedResult: {
             lowerCase: true,
             lowerCase: true,
-            suggestKeywords: ['*', 'ALL', 'DISTINCT'],
             suggestAggregateFunctions: true,
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
             suggestAnalyticFunctions: true,
             suggestFunctions: {},
             suggestFunctions: {},
@@ -678,9 +678,10 @@ define([
         assertAutoComplete({
         assertAutoComplete({
           beforeCursor: 'SELECT ALL ',
           beforeCursor: 'SELECT ALL ',
           afterCursor: '',
           afterCursor: '',
+          containsKeywords: ['*'],
+          doesNotContainKeywords: ['ALL', 'DISTINCT'],
           expectedResult: {
           expectedResult: {
             lowerCase: false,
             lowerCase: false,
-            suggestKeywords: ['*'],
             suggestAggregateFunctions: true,
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
             suggestAnalyticFunctions: true,
             suggestFunctions: {},
             suggestFunctions: {},
@@ -701,9 +702,10 @@ define([
         assertAutoComplete({
         assertAutoComplete({
           beforeCursor: 'SELECT DISTINCT ',
           beforeCursor: 'SELECT DISTINCT ',
           afterCursor: '',
           afterCursor: '',
+          containsKeywords: ['*'],
+          doesNotContainKeywords: ['ALL', 'DISTINCT'],
           expectedResult: {
           expectedResult: {
             lowerCase: false,
             lowerCase: false,
-            suggestKeywords: ['*'],
             suggestFunctions: {},
             suggestFunctions: {},
             suggestTables: {
             suggestTables: {
               prependQuestionMark: true,
               prependQuestionMark: true,
@@ -722,9 +724,10 @@ define([
         assertAutoComplete({
         assertAutoComplete({
           beforeCursor: 'SELECT DISTINCT ',
           beforeCursor: 'SELECT DISTINCT ',
           afterCursor: ' a, b, c FROM tbl',
           afterCursor: ' a, b, c FROM tbl',
+          containsKeywords: ['*'],
+          doesNotContainKeywords: ['ALL', 'DISTINCT'],
           expectedResult: {
           expectedResult: {
             lowerCase: false,
             lowerCase: false,
-            suggestKeywords: ['*'],
             suggestFunctions: {},
             suggestFunctions: {},
             suggestColumns: { table: 'tbl' },
             suggestColumns: { table: 'tbl' },
             locations: [
             locations: [
@@ -744,9 +747,9 @@ define([
           beforeCursor: 'SELECT ',
           beforeCursor: 'SELECT ',
           afterCursor: ' FROM tableA;',
           afterCursor: ' FROM tableA;',
           hasLocations: true,
           hasLocations: true,
+          containsKeywords: ['*', 'ALL', 'DISTINCT'],
           expectedResult: {
           expectedResult: {
             lowerCase: false,
             lowerCase: false,
-            suggestKeywords: ['*', 'ALL', 'DISTINCT'],
             suggestAggregateFunctions: true,
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
             suggestAnalyticFunctions: true,
             suggestFunctions: {},
             suggestFunctions: {},
@@ -760,9 +763,9 @@ define([
           beforeCursor: 'SELECT ',
           beforeCursor: 'SELECT ',
           afterCursor: ' FROM testWHERE',
           afterCursor: ' FROM testWHERE',
           hasLocations: true,
           hasLocations: true,
+          containsKeywords: ['*', 'ALL', 'DISTINCT'],
           expectedResult: {
           expectedResult: {
             lowerCase: false,
             lowerCase: false,
-            suggestKeywords: ['*', 'ALL', 'DISTINCT'],
             suggestAggregateFunctions: true,
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
             suggestAnalyticFunctions: true,
             suggestFunctions: {},
             suggestFunctions: {},
@@ -776,9 +779,9 @@ define([
           beforeCursor: 'SELECT ',
           beforeCursor: 'SELECT ',
           afterCursor: ' FROM testON',
           afterCursor: ' FROM testON',
           hasLocations: true,
           hasLocations: true,
+          containsKeywords: ['*', 'ALL', 'DISTINCT'],
           expectedResult: {
           expectedResult: {
             lowerCase: false,
             lowerCase: false,
-            suggestKeywords: ['*', 'ALL', 'DISTINCT'],
             suggestAggregateFunctions: true,
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
             suggestAnalyticFunctions: true,
             suggestFunctions: {},
             suggestFunctions: {},
@@ -792,9 +795,9 @@ define([
           beforeCursor: 'SELECT ',
           beforeCursor: 'SELECT ',
           afterCursor: ' FROM transactions',
           afterCursor: ' FROM transactions',
           hasLocations: true,
           hasLocations: true,
+          containsKeywords: ['*', 'ALL', 'DISTINCT'],
           expectedResult: {
           expectedResult: {
             lowerCase: false,
             lowerCase: false,
-            suggestKeywords: ['*', 'ALL', 'DISTINCT'],
             suggestAggregateFunctions: true,
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
             suggestAnalyticFunctions: true,
             suggestFunctions: {},
             suggestFunctions: {},
@@ -808,9 +811,9 @@ define([
           beforeCursor: 'SELECT ',
           beforeCursor: 'SELECT ',
           afterCursor: ' FROM testTableA tta, testTableB',
           afterCursor: ' FROM testTableA tta, testTableB',
           hasLocations: true,
           hasLocations: true,
+          containsKeywords: ['*', 'ALL', 'DISTINCT'],
           expectedResult: {
           expectedResult: {
             lowerCase: false,
             lowerCase: false,
-            suggestKeywords: ['*', 'ALL', 'DISTINCT'],
             suggestAggregateFunctions: true,
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
             suggestAnalyticFunctions: true,
             suggestFunctions: {},
             suggestFunctions: {},
@@ -824,9 +827,9 @@ define([
           beforeCursor: 'select ',
           beforeCursor: 'select ',
           afterCursor: ' from database_two.testTable',
           afterCursor: ' from database_two.testTable',
           hasLocations: true,
           hasLocations: true,
+          containsKeywords: ['*', 'ALL', 'DISTINCT'],
           expectedResult: {
           expectedResult: {
             lowerCase: true,
             lowerCase: true,
-            suggestKeywords: ['*', 'ALL', 'DISTINCT'],
             suggestAggregateFunctions: true,
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
             suggestAnalyticFunctions: true,
             suggestFunctions: {},
             suggestFunctions: {},
@@ -839,9 +842,9 @@ define([
         assertAutoComplete({
         assertAutoComplete({
           beforeCursor: 'select ',
           beforeCursor: 'select ',
           afterCursor: ' from `database one`.`test table`',
           afterCursor: ' from `database one`.`test table`',
+          containsKeywords: ['*', 'ALL', 'DISTINCT'],
           expectedResult: {
           expectedResult: {
             lowerCase: true,
             lowerCase: true,
-            suggestKeywords: ['*', 'ALL', 'DISTINCT'],
             suggestAggregateFunctions: true,
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
             suggestAnalyticFunctions: true,
             suggestFunctions: {},
             suggestFunctions: {},
@@ -984,9 +987,9 @@ define([
           beforeCursor: 'SELECT ',
           beforeCursor: 'SELECT ',
           afterCursor: ' a, cast(b as int), c, d FROM testTable WHERE a = \'US\' AND b >= 998 ORDER BY c DESC LIMIT 15',
           afterCursor: ' a, cast(b as int), c, d FROM testTable WHERE a = \'US\' AND b >= 998 ORDER BY c DESC LIMIT 15',
           hasLocations: true,
           hasLocations: true,
+          containsKeywords: ['*', 'ALL', 'DISTINCT'],
           expectedResult: {
           expectedResult: {
             lowerCase: false,
             lowerCase: false,
-            suggestKeywords: ['*', 'ALL', 'DISTINCT'],
             suggestAggregateFunctions: true,
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
             suggestAnalyticFunctions: true,
             suggestFunctions: {},
             suggestFunctions: {},
@@ -1027,9 +1030,9 @@ define([
           beforeCursor: 'SELECT ',
           beforeCursor: 'SELECT ',
           afterCursor: ' FROM ${some_variable};',
           afterCursor: ' FROM ${some_variable};',
           hasLocations: true,
           hasLocations: true,
+          containsKeywords: ['*', 'ALL', 'DISTINCT'],
           expectedResult: {
           expectedResult: {
             lowerCase: false,
             lowerCase: false,
-            suggestKeywords: ['*', 'ALL', 'DISTINCT'],
             suggestAggregateFunctions: true,
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
             suggestAnalyticFunctions: true,
             suggestFunctions: {},
             suggestFunctions: {},
@@ -2646,7 +2649,7 @@ define([
           hasLocations: true,
           hasLocations: true,
           expectedResult: {
           expectedResult: {
             lowerCase: false,
             lowerCase: false,
-            suggestKeywords: ['WHERE', 'GROUP BY', 'HAVING', 'WINDOW', 'ORDER BY', 'CLUSTER BY', 'DISTRIBUTE BY', 'SORT BY', 'LIMIT', 'UNION', 'CROSS JOIN', 'FULL JOIN', 'FULL OUTER JOIN', 'JOIN', 'LATERAL VIEW', 'LEFT JOIN', 'LEFT OUTER JOIN', 'LEFT SEMI JOIN', 'RIGHT JOIN', 'RIGHT OUTER JOIN']
+            suggestKeywords: ['TABLESAMPLE', 'AS', 'LATERAL VIEW', 'WHERE', 'GROUP BY', 'HAVING', 'WINDOW', 'ORDER BY', 'CLUSTER BY', 'DISTRIBUTE BY', 'SORT BY', 'LIMIT', 'UNION', 'CROSS JOIN', 'FULL JOIN', 'FULL OUTER JOIN', 'JOIN', 'LEFT JOIN', 'LEFT OUTER JOIN', 'LEFT SEMI JOIN', 'RIGHT JOIN', 'RIGHT OUTER JOIN']
           }
           }
         });
         });
       });
       });
@@ -2659,7 +2662,7 @@ define([
           hasLocations: true,
           hasLocations: true,
           expectedResult: {
           expectedResult: {
             lowerCase: false,
             lowerCase: false,
-            suggestKeywords: ['WHERE', 'GROUP BY', 'HAVING', 'WINDOW', 'ORDER BY', 'CLUSTER BY', 'DISTRIBUTE BY', 'SORT BY', 'LIMIT', 'UNION', 'CROSS JOIN', 'FULL JOIN', 'FULL OUTER JOIN', 'JOIN', 'LATERAL VIEW', 'LEFT JOIN', 'LEFT OUTER JOIN', 'LEFT SEMI JOIN', 'RIGHT JOIN', 'RIGHT OUTER JOIN']
+            suggestKeywords: ['LATERAL VIEW', 'WHERE', 'GROUP BY', 'HAVING', 'WINDOW', 'ORDER BY', 'CLUSTER BY', 'DISTRIBUTE BY', 'SORT BY', 'LIMIT', 'UNION', 'CROSS JOIN', 'FULL JOIN', 'FULL OUTER JOIN', 'JOIN', 'LEFT JOIN', 'LEFT OUTER JOIN', 'LEFT SEMI JOIN', 'RIGHT JOIN', 'RIGHT OUTER JOIN']
           }
           }
         });
         });
       });
       });
@@ -2750,14 +2753,14 @@ define([
           hasLocations: true,
           hasLocations: true,
           expectedResult: {
           expectedResult: {
             lowerCase: false,
             lowerCase: false,
-            suggestKeywords: ['explode', 'posexplode']
+            suggestKeywords: ['OUTER', 'explode', 'posexplode']
           }
           }
         });
         });
       });
       });
 
 
-      it('should suggest keywords for "SELECT bar FROM foo LATERAL VIEW explode(bar) |"', function () {
+      it('should suggest keywords for "SELECT bar FROM foo LATERAL VIEW OUTER explode(bar) |"', function () {
         assertAutoComplete({
         assertAutoComplete({
-          beforeCursor: 'SELECT bar FROM foo LATERAL VIEW explode(bar) ',
+          beforeCursor: 'SELECT bar FROM foo LATERAL VIEW OUTER explode(bar) ',
           afterCursor: '',
           afterCursor: '',
           dialect: 'hive',
           dialect: 'hive',
           hasLocations: true,
           hasLocations: true,
@@ -3231,7 +3234,7 @@ define([
           dialect: 'impala',
           dialect: 'impala',
           expectedResult: {
           expectedResult: {
             lowerCase: false,
             lowerCase: false,
-            suggestKeywords: ['WHERE', 'GROUP BY', 'HAVING', 'ORDER BY', 'LIMIT', 'OFFSET', 'UNION', 'FULL JOIN', 'FULL OUTER JOIN', 'INNER JOIN', 'JOIN', 'LEFT ANTI JOIN', 'LEFT JOIN', 'LEFT OUTER JOIN', 'LEFT SEMI JOIN', 'RIGHT ANTI JOIN', 'RIGHT JOIN', 'RIGHT OUTER JOIN', 'RIGHT SEMI JOIN'],
+            suggestKeywords: ['AS', 'WHERE', 'GROUP BY', 'HAVING', 'ORDER BY', 'LIMIT', 'OFFSET', 'UNION', 'FULL JOIN', 'FULL OUTER JOIN', 'INNER JOIN', 'JOIN', 'LEFT ANTI JOIN', 'LEFT JOIN', 'LEFT OUTER JOIN', 'LEFT SEMI JOIN', 'RIGHT ANTI JOIN', 'RIGHT JOIN', 'RIGHT OUTER JOIN', 'RIGHT SEMI JOIN'],
             locations: [
             locations: [
               {type: 'table', location: { first_line: 1, last_line: 1, first_column: 15, last_column: 25}, table: 'testTableA'},
               {type: 'table', location: { first_line: 1, last_line: 1, first_column: 15, last_column: 25}, table: 'testTableA'},
               {type: 'table', location: { first_line: 1, last_line: 1, first_column: 31, last_column: 41}, table: 'testTableB'}
               {type: 'table', location: { first_line: 1, last_line: 1, first_column: 31, last_column: 41}, table: 'testTableB'}
@@ -3398,7 +3401,7 @@ define([
           hasLocations: true,
           hasLocations: true,
           expectedResult: {
           expectedResult: {
             lowerCase: false,
             lowerCase: false,
-            suggestKeywords: ['*', 'ALL', 'DISTINCT'],
+            suggestKeywords: ['*', 'ALL', 'DISTINCT', 'STRAIGHT_JOIN'],
             suggestAggregateFunctions: true,
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
             suggestAnalyticFunctions: true,
             suggestFunctions: {},
             suggestFunctions: {},
@@ -4953,13 +4956,13 @@ define([
           beforeCursor: 'SELECT ',
           beforeCursor: 'SELECT ',
           afterCursor: ' a, b, c FROM testTable',
           afterCursor: ' a, b, c FROM testTable',
           hasLocations: true,
           hasLocations: true,
+          containsKeywords: ['*', 'ALL', 'DISTINCT'],
           expectedResult: {
           expectedResult: {
             lowerCase: false,
             lowerCase: false,
             suggestFunctions: {},
             suggestFunctions: {},
             suggestAggregateFunctions: true,
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
             suggestAnalyticFunctions: true,
-            suggestColumns: { table: 'testTable' },
-            suggestKeywords: ['*', 'ALL', 'DISTINCT']
+            suggestColumns: { table: 'testTable' }
           }
           }
         });
         });
       });
       });
@@ -5736,6 +5739,116 @@ define([
       });
       });
     });
     });
 
 
+    describe('TABLESAMPLE', function () {
+      it('should handle "SELECT * FROM boo TABLESAMPLE (BUCKET 1 OUT OF 32 ON baa) baa JOIN bla;|', function () {
+        assertAutoComplete({
+          beforeCursor: 'SELECT * FROM boo TABLESAMPLE (BUCKET 1 OUT OF 32 ON baa) baa JOIN bla;',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          noErrors: true,
+          containsKeywords: ['SELECT'],
+          expectedResult: {
+            lowerCase: false
+          }
+        });
+      });
+
+      it('should suggest keywords for "SELECT * FROM boo |', function () {
+        assertAutoComplete({
+          beforeCursor: 'SELECT * FROM boo ',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          noErrors: true,
+          containsKeywords: ['TABLESAMPLE', 'AS'],
+          expectedResult: {
+            lowerCase: false
+          }
+        });
+      });
+
+      xit('should suggest keywords for "SELECT * FROM boo |, baa', function () {
+        assertAutoComplete({
+          beforeCursor: 'SELECT * FROM boo ',
+          afterCursor: ', baa',
+          dialect: 'hive',
+          hasLocations: true,
+          containsKeywords: ['TABLESAMPLE', 'AS'],
+          expectedResult: {
+            lowerCase: false
+          }
+        });
+      });
+
+      it('should suggest keywords for "SELECT * FROM boo TABLESAMPLE (|', function () {
+        assertAutoComplete({
+          beforeCursor: 'SELECT * FROM boo TABLESAMPLE (',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['BUCKET']
+          }
+        });
+      });
+
+      it('should suggest keywords for "SELECT * FROM boo TABLESAMPLE (BUCKET 1 |', function () {
+        assertAutoComplete({
+          beforeCursor: 'SELECT * FROM boo TABLESAMPLE (BUCKET 1 ',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['OUT OF']
+          }
+        });
+      });
+
+      it('should suggest keywords for "SELECT * FROM boo TABLESAMPLE (BUCKET 1 OUT |', function () {
+        assertAutoComplete({
+          beforeCursor: 'SELECT * FROM boo TABLESAMPLE (BUCKET 1 OUT ',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['OF']
+          }
+        });
+      });
+
+      it('should suggest keywords for "SELECT * FROM boo TABLESAMPLE (BUCKET 1 OUT OF 16 |', function () {
+        assertAutoComplete({
+          beforeCursor: 'SELECT * FROM boo TABLESAMPLE (BUCKET 1 OUT OF 16 ',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['ON']
+          }
+        });
+      });
+
+      it('should suggest columns for "SELECT * FROM boo TABLESAMPLE (BUCKET 1 OUT OF 16 ON |', function () {
+        assertAutoComplete({
+          beforeCursor: 'SELECT * FROM boo TABLESAMPLE (BUCKET 1 OUT OF 16 ON ',
+          afterCursor: '',
+          dialect: 'hive',
+          hasLocations: true,
+          containsKeywords: ['CASE'],
+          expectedResult: {
+            lowerCase: false,
+            suggestFunctions: {},
+            suggestColumns: { table: 'boo' }
+          }
+        });
+      });
+    });
+
     describe('UNION clause', function () {
     describe('UNION clause', function () {
       // TODO: Fix locations
       // TODO: Fix locations
       xit('should handle "SELECT * FROM (SELECT x FROM few_ints UNION ALL SELECT x FROM few_ints) AS t1 ORDER BY x;|', function () {
       xit('should handle "SELECT * FROM (SELECT x FROM few_ints UNION ALL SELECT x FROM few_ints) AS t1 ORDER BY x;|', function () {
@@ -5809,9 +5922,9 @@ define([
           afterCursor: '',
           afterCursor: '',
           hasLocations: true,
           hasLocations: true,
           noErrors: true,
           noErrors: true,
+          containsKeywords: ['*', 'ALL', 'DISTINCT'],
           expectedResult: {
           expectedResult: {
             lowerCase: false,
             lowerCase: false,
-            suggestKeywords: ['*', 'ALL', 'DISTINCT'],
             suggestAggregateFunctions: true,
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
             suggestAnalyticFunctions: true,
             suggestFunctions: {},
             suggestFunctions: {},
@@ -5909,9 +6022,9 @@ define([
           afterCursor: '',
           afterCursor: '',
           hasLocations: true,
           hasLocations: true,
           noErrors: true,
           noErrors: true,
+          containsKeywords: ['*', 'ALL', 'DISTINCT'],
           expectedResult: {
           expectedResult: {
             lowerCase: false,
             lowerCase: false,
-            suggestKeywords: ['*', 'ALL', 'DISTINCT'],
             suggestAggregateFunctions: true,
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
             suggestAnalyticFunctions: true,
             suggestFunctions: {},
             suggestFunctions: {},
@@ -6403,7 +6516,7 @@ define([
             hasLocations: true,
             hasLocations: true,
             expectedResult: {
             expectedResult: {
               lowerCase: false,
               lowerCase: false,
-              suggestKeywords: ['CROSS', 'FULL', 'FULL OUTER', 'LEFT', 'LEFT OUTER', 'LEFT SEMI', 'RIGHT', 'RIGHT OUTER']
+              suggestKeywords: ['LATERAL VIEW', 'CROSS', 'FULL', 'FULL OUTER', 'LEFT', 'LEFT OUTER', 'LEFT SEMI', 'RIGHT', 'RIGHT OUTER']
             }
             }
           });
           });
         });
         });
@@ -6750,9 +6863,9 @@ define([
         assertAutoComplete({
         assertAutoComplete({
           beforeCursor: 'SELECT * FROM foo WHERE bar IN (SELECT ',
           beforeCursor: 'SELECT * FROM foo WHERE bar IN (SELECT ',
           afterCursor: '',
           afterCursor: '',
+          containsKeywords: ['*', 'ALL', 'DISTINCT'],
           expectedResult: {
           expectedResult: {
             lowerCase: false,
             lowerCase: false,
-            suggestKeywords: ['*', 'ALL', 'DISTINCT'],
             suggestAggregateFunctions: true,
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
             suggestAnalyticFunctions: true,
             suggestFunctions: {},
             suggestFunctions: {},
@@ -6778,9 +6891,9 @@ define([
         assertAutoComplete({
         assertAutoComplete({
           beforeCursor: 'SELECT * FROM bar WHERE foo NOT IN (SELECT ',
           beforeCursor: 'SELECT * FROM bar WHERE foo NOT IN (SELECT ',
           afterCursor: ')',
           afterCursor: ')',
+          containsKeywords: ['*', 'ALL', 'DISTINCT'],
           expectedResult: {
           expectedResult: {
             lowerCase: false,
             lowerCase: false,
-            suggestKeywords: ['*', 'ALL', 'DISTINCT'],
             suggestAggregateFunctions: true,
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
             suggestAnalyticFunctions: true,
             suggestFunctions: {},
             suggestFunctions: {},
@@ -6829,9 +6942,9 @@ define([
         assertAutoComplete({
         assertAutoComplete({
           beforeCursor: 'SELECT * FROM (SELECT ',
           beforeCursor: 'SELECT * FROM (SELECT ',
           afterCursor: '',
           afterCursor: '',
+          containsKeywords: ['*', 'ALL', 'DISTINCT'],
           expectedResult: {
           expectedResult: {
             lowerCase: false,
             lowerCase: false,
-            suggestKeywords: ['*', 'ALL', 'DISTINCT'],
             suggestAggregateFunctions: true,
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
             suggestAnalyticFunctions: true,
             suggestFunctions: {},
             suggestFunctions: {},
@@ -6871,9 +6984,9 @@ define([
         assertAutoComplete({
         assertAutoComplete({
           beforeCursor: 'SELECT ',
           beforeCursor: 'SELECT ',
           afterCursor: ' FROM testTable tt, (SELECT bla FROM abc WHERE foo > 1) bar',
           afterCursor: ' FROM testTable tt, (SELECT bla FROM abc WHERE foo > 1) bar',
+          containsKeywords: ['*', 'ALL', 'DISTINCT'],
           expectedResult: {
           expectedResult: {
             lowerCase: false,
             lowerCase: false,
-            suggestKeywords: ['*', 'ALL', 'DISTINCT'],
             suggestAggregateFunctions: true,
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
             suggestAnalyticFunctions: true,
             suggestFunctions: {},
             suggestFunctions: {},
@@ -6899,9 +7012,9 @@ define([
           beforeCursor: 'select ',
           beforeCursor: 'select ',
           afterCursor: ' from (select id i, name as n, bla from foo) bar',
           afterCursor: ' from (select id i, name as n, bla from foo) bar',
           hasLocations: true,
           hasLocations: true,
+          containsKeywords: ['*', 'ALL', 'DISTINCT'],
           expectedResult: {
           expectedResult: {
             lowerCase: true,
             lowerCase: true,
-            suggestKeywords: ['*', 'ALL', 'DISTINCT'],
             suggestAggregateFunctions: true,
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
             suggestAnalyticFunctions: true,
             suggestFunctions: {},
             suggestFunctions: {},
@@ -6924,9 +7037,9 @@ define([
           beforeCursor: 'select ',
           beforeCursor: 'select ',
           afterCursor: ' from (select id i, name as n, bla from foo) bar',
           afterCursor: ' from (select id i, name as n, bla from foo) bar',
           hasLocations: true,
           hasLocations: true,
+          containsKeywords: ['*', 'ALL', 'DISTINCT'],
           expectedResult: {
           expectedResult: {
             lowerCase: true,
             lowerCase: true,
-            suggestKeywords: ['*', 'ALL', 'DISTINCT'],
             suggestAggregateFunctions: true,
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
             suggestAnalyticFunctions: true,
             suggestFunctions: {},
             suggestFunctions: {},
@@ -7011,9 +7124,9 @@ define([
         assertAutoComplete({
         assertAutoComplete({
           beforeCursor: 'SELECT * FROM (SELECT ',
           beforeCursor: 'SELECT * FROM (SELECT ',
           afterCursor: ')',
           afterCursor: ')',
+          containsKeywords: ['*', 'ALL', 'DISTINCT'],
           expectedResult: {
           expectedResult: {
             lowerCase: false,
             lowerCase: false,
-            suggestKeywords: ['*', 'ALL', 'DISTINCT'],
             suggestAggregateFunctions: true,
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
             suggestAnalyticFunctions: true,
             suggestFunctions: {},
             suggestFunctions: {},
@@ -7035,9 +7148,9 @@ define([
           beforeCursor: 'SELECT ',
           beforeCursor: 'SELECT ',
           afterCursor: ' FROM (SELECT * FROM tableOne) AS subQueryOne, someDb.tableTwo tAlias, tableThree, (SELECT * FROM t3 JOIN table4 t4 ON t3.id = t4.id) subQueryTwo;',
           afterCursor: ' FROM (SELECT * FROM tableOne) AS subQueryOne, someDb.tableTwo tAlias, tableThree, (SELECT * FROM t3 JOIN table4 t4 ON t3.id = t4.id) subQueryTwo;',
           hasLocations: true,
           hasLocations: true,
+          containsKeywords: ['*', 'ALL', 'DISTINCT'],
           expectedResult: {
           expectedResult: {
             lowerCase: false,
             lowerCase: false,
-            suggestKeywords: ['*', 'ALL', 'DISTINCT'],
             suggestAggregateFunctions: true,
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
             suggestAnalyticFunctions: true,
             suggestFunctions: {},
             suggestFunctions: {},
@@ -7058,9 +7171,9 @@ define([
           beforeCursor: 'SELECT * FROM (SELECT ',
           beforeCursor: 'SELECT * FROM (SELECT ',
           afterCursor: ' FROM tableOne) subQueryOne, someDb.tableTwo talias, (SELECT * FROM t3 JOIN t4 ON t3.id = t4.id) AS subQueryTwo;',
           afterCursor: ' FROM tableOne) subQueryOne, someDb.tableTwo talias, (SELECT * FROM t3 JOIN t4 ON t3.id = t4.id) AS subQueryTwo;',
           hasLocations: true,
           hasLocations: true,
+          containsKeywords: ['*', 'ALL', 'DISTINCT'],
           expectedResult: {
           expectedResult: {
             lowerCase: false,
             lowerCase: false,
-            suggestKeywords: ['*', 'ALL', 'DISTINCT'],
             suggestAggregateFunctions: true,
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
             suggestAnalyticFunctions: true,
             suggestFunctions: {},
             suggestFunctions: {},
@@ -7076,9 +7189,9 @@ define([
           beforeCursor: 'SELECT ',
           beforeCursor: 'SELECT ',
           afterCursor: ' FROM (SELECT * FROM (SELECT * FROM tableOne) subQueryOne) subQueryTwo',
           afterCursor: ' FROM (SELECT * FROM (SELECT * FROM tableOne) subQueryOne) subQueryTwo',
           hasLocations: true,
           hasLocations: true,
+          containsKeywords: ['*', 'ALL', 'DISTINCT'],
           expectedResult: {
           expectedResult: {
             lowerCase:false,
             lowerCase:false,
-            suggestKeywords: ['*', 'ALL', 'DISTINCT'],
             suggestAggregateFunctions: true,
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
             suggestAnalyticFunctions: true,
             suggestFunctions: {},
             suggestFunctions: {},
@@ -7101,9 +7214,9 @@ define([
           beforeCursor: 'SELECT ',
           beforeCursor: 'SELECT ',
           afterCursor: ' FROM (SELECT * FROM (SELECT * FROM (SELECT * FROM tableOne) subQueryOne) subQueryTwo) subQueryThree',
           afterCursor: ' FROM (SELECT * FROM (SELECT * FROM (SELECT * FROM tableOne) subQueryOne) subQueryTwo) subQueryThree',
           hasLocations: true,
           hasLocations: true,
+          containsKeywords: ['*', 'ALL', 'DISTINCT'],
           expectedResult: {
           expectedResult: {
             lowerCase:false,
             lowerCase:false,
-            suggestKeywords: ['*', 'ALL', 'DISTINCT'],
             suggestAggregateFunctions: true,
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
             suggestAnalyticFunctions: true,
             suggestFunctions: {},
             suggestFunctions: {},
@@ -7130,9 +7243,9 @@ define([
           beforeCursor: 'SELECT * FROM (SELECT ',
           beforeCursor: 'SELECT * FROM (SELECT ',
           afterCursor: ' FROM (SELECT * FROM (SELECT * FROM tableOne) subQueryOne) subQueryTwo) subQueryThree',
           afterCursor: ' FROM (SELECT * FROM (SELECT * FROM tableOne) subQueryOne) subQueryTwo) subQueryThree',
           hasLocations: true,
           hasLocations: true,
+          containsKeywords: ['*', 'ALL', 'DISTINCT'],
           expectedResult: {
           expectedResult: {
             lowerCase:false,
             lowerCase:false,
-            suggestKeywords: ['*', 'ALL', 'DISTINCT'],
             suggestAggregateFunctions: true,
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
             suggestAnalyticFunctions: true,
             suggestFunctions: {},
             suggestFunctions: {},
@@ -7155,9 +7268,9 @@ define([
           beforeCursor: 'SELECT * FROM (SELECT * FROM (SELECT ',
           beforeCursor: 'SELECT * FROM (SELECT * FROM (SELECT ',
           afterCursor: ' FROM (SELECT * FROM tableOne) subQueryOne) subQueryTwo) subQueryThree',
           afterCursor: ' FROM (SELECT * FROM tableOne) subQueryOne) subQueryTwo) subQueryThree',
           hasLocations: true,
           hasLocations: true,
+          containsKeywords: ['*', 'ALL', 'DISTINCT'],
           expectedResult: {
           expectedResult: {
             lowerCase:false,
             lowerCase:false,
-            suggestKeywords: ['*', 'ALL', 'DISTINCT'],
             suggestAggregateFunctions: true,
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
             suggestAnalyticFunctions: true,
             suggestFunctions: {},
             suggestFunctions: {},

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

@@ -69,10 +69,10 @@ define([
       assertAutoComplete({
       assertAutoComplete({
         beforeCursor: 'USE database_two; \nselect ',
         beforeCursor: 'USE database_two; \nselect ',
         afterCursor: '',
         afterCursor: '',
+        containsKeywords: ['*', 'ALL', 'DISTINCT'],
         expectedResult: {
         expectedResult: {
           useDatabase: 'database_two',
           useDatabase: 'database_two',
           lowerCase: true,
           lowerCase: true,
-          suggestKeywords: ['*', 'ALL', 'DISTINCT'],
           suggestAggregateFunctions: true,
           suggestAggregateFunctions: true,
           suggestAnalyticFunctions: true,
           suggestAnalyticFunctions: true,
           suggestFunctions: {},
           suggestFunctions: {},
@@ -93,10 +93,10 @@ define([
       assertAutoComplete({
       assertAutoComplete({
         beforeCursor: 'USE other_db; USE closest_db; \n\tSELECT ',
         beforeCursor: 'USE other_db; USE closest_db; \n\tSELECT ',
         afterCursor: '',
         afterCursor: '',
+        containsKeywords: ['*', 'ALL', 'DISTINCT'],
         expectedResult: {
         expectedResult: {
           useDatabase: 'closest_db',
           useDatabase: 'closest_db',
           lowerCase: false,
           lowerCase: false,
-          suggestKeywords: ['*', 'ALL', 'DISTINCT'],
           suggestAggregateFunctions: true,
           suggestAggregateFunctions: true,
           suggestAnalyticFunctions: true,
           suggestAnalyticFunctions: true,
           suggestFunctions: {},
           suggestFunctions: {},
@@ -117,10 +117,10 @@ define([
       assertAutoComplete({
       assertAutoComplete({
         beforeCursor: 'USE other_db; USE closest_db; \n\tSELECT ',
         beforeCursor: 'USE other_db; USE closest_db; \n\tSELECT ',
         afterCursor: '; USE some_other_db;',
         afterCursor: '; USE some_other_db;',
+        containsKeywords: ['*', 'ALL', 'DISTINCT'],
         expectedResult: {
         expectedResult: {
           useDatabase: 'closest_db',
           useDatabase: 'closest_db',
           lowerCase: false,
           lowerCase: false,
-          suggestKeywords: ['*', 'ALL', 'DISTINCT'],
           suggestAggregateFunctions: true,
           suggestAggregateFunctions: true,
           suggestAnalyticFunctions: true,
           suggestAnalyticFunctions: true,
           suggestFunctions: {},
           suggestFunctions: {},

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