浏览代码

HUE-8598 [autocomplete] Improve autocomplete for CREATE statements

- Fix structural errors with the Hive and Impala CREATE grammar.
- Fix ROW FORMAT and STORED AS
- Fix Kudu partition clauses
- Fix broken jasmine tests
Johan Ahlen 7 年之前
父节点
当前提交
ad820d7

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

@@ -200,8 +200,8 @@
 <hive>'VIEW'                               { return '<hive>VIEW'; }
 <hive>'WAIT'                               { return '<hive>WAIT'; }
 <hive>'WEEK'                               { return '<hive>WEEK'; }
-<hive>'WITH'                               { return '<hive>WITH'; }
 <hive>'WINDOW'                             { return '<hive>WINDOW'; }
+<hive>'WITH'                               { parser.determineCase(yytext); parser.addStatementTypeLocation('WITH', yylloc); return '<hive>WITH'; }
 <hive>'YEAR'                               { return '<hive>YEAR'; }
 
 <hive>'.'                                  { return '<hive>.'; }
@@ -509,7 +509,7 @@
 <impala>'WHENEVER'                         { return '<impala>WHENEVER'; }
 <impala>'WIDTH_BUCKET'                     { return '<impala>WIDTH_BUCKET'; }
 <impala>'WINDOW'                           { return '<impala>WINDOW'; }
-<impala>'WITH'                             { return '<impala>WITH'; }
+<impala>'WITH'                             { parser.determineCase(yytext); parser.addStatementTypeLocation('WITH', yylloc); return '<impala>WITH'; }
 <impala>'WITHIN'                           { return '<impala>WITHIN'; }
 <impala>'WITHOUT'                          { return '<impala>WITHOUT'; }
 

+ 232 - 126
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_create.jison

@@ -104,6 +104,24 @@ DatabaseDefinitionOptionals_EDIT
  | OptionalComment HdfsLocation_EDIT OptionalHiveDbProperties
  ;
 
+OptionalHiveComment
+ :
+ | HiveComment
+ ;
+
+HiveComment
+ : '<hive>COMMENT' QuotedValue
+ ;
+
+OptionalImpalaComment
+ :
+ | ImpalaComment
+ ;
+
+ImpalaComment
+ : '<impala>COMMENT' QuotedValue
+ ;
+
 OptionalComment
  :
  | Comment
@@ -113,6 +131,10 @@ Comment
  : HiveOrImpalaComment QuotedValue
  ;
 
+OptionalComment_INVALID
+ : Comment_INVALID
+ ;
+
 Comment_INVALID
  : HiveOrImpalaComment SINGLE_QUOTE
  | HiveOrImpalaComment DOUBLE_QUOTE
@@ -120,9 +142,6 @@ Comment_INVALID
  | HiveOrImpalaComment DOUBLE_QUOTE VALUE
  ;
 
-OptionalComment_INVALID
- : Comment_INVALID
- ;
 
 OptionalHiveDbProperties
  :
@@ -167,84 +186,112 @@ TableDefinition_EDIT
  ;
 
 TableDefinitionRightPart
- : TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalSortBy OptionalClusteredBy OptionalSkewedBy
-   OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement
+ : TableIdentifierAndOptionalColumnSpecification OptionalHiveComment OptionalPartitionedBy OptionalSortBy OptionalImpalaComment
+   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalImpalaWithSerdeproperties OptionalStoredAsOrBy
+   OptionalHiveWithSerdeproperties OptionalHdfsLocation OptionalCachedInOrUncached OptionalTblproperties OptionalAsSelectStatement
  ;
 
 TableDefinitionRightPart_EDIT
- : TableIdentifierAndOptionalColumnSpecification_EDIT OptionalComment OptionalPartitionedBy OptionalSortBy OptionalClusteredBy OptionalSkewedBy
-   OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment PartitionedBy_EDIT OptionalSortBy OptionalClusteredBy OptionalSkewedBy
-   OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy SortBy_EDIT OptionalClusteredBy OptionalSkewedBy
-   OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalSortBy ClusteredBy_EDIT OptionalSkewedBy
-   OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalSortBy OptionalClusteredBy SkewedBy_EDIT
-   OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalSortBy OptionalClusteredBy OptionalSkewedBy
-   StoredAsOrBy_EDIT OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalSortBy OptionalClusteredBy OptionalSkewedBy
-   OptionalStoredAsOrBy HdfsLocation_EDIT OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalSortBy OptionalClusteredBy OptionalSkewedBy
-   OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties CachedIn_EDIT OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalSortBy OptionalClusteredBy OptionalSkewedBy
-   OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties CachedIn WithReplication_EDIT OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalSortBy OptionalClusteredBy OptionalSkewedBy
-   OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement_EDIT
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalSortBy OptionalClusteredBy OptionalSkewedBy
-   OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached 'CURSOR'
+ : TableIdentifierAndOptionalColumnSpecification_EDIT OptionalHiveComment OptionalPartitionedBy OptionalSortBy OptionalImpalaComment
+   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalImpalaWithSerdeproperties OptionalStoredAsOrBy
+   OptionalHiveWithSerdeproperties OptionalHdfsLocation OptionalCachedInOrUncached OptionalTblproperties OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification OptionalHiveComment PartitionedBy_EDIT OptionalSortBy OptionalImpalaComment
+   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalImpalaWithSerdeproperties OptionalStoredAsOrBy
+   OptionalHiveWithSerdeproperties OptionalHdfsLocation OptionalCachedInOrUncached OptionalTblproperties OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification OptionalHiveComment OptionalPartitionedBy SortBy_EDIT OptionalImpalaComment
+   OptionalClusteredBy  OptionalSkewedBy OptionalRowFormat OptionalImpalaWithSerdeproperties OptionalStoredAsOrBy
+   OptionalHiveWithSerdeproperties OptionalHdfsLocation OptionalCachedInOrUncached OptionalTblproperties OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification OptionalHiveComment OptionalPartitionedBy OptionalSortBy OptionalImpalaComment
+   ClusteredBy_EDIT OptionalSkewedBy OptionalRowFormat OptionalImpalaWithSerdeproperties OptionalStoredAsOrBy
+   OptionalHiveWithSerdeproperties OptionalHdfsLocation OptionalCachedInOrUncached OptionalTblproperties OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification OptionalHiveComment OptionalPartitionedBy OptionalSortBy OptionalImpalaComment
+   OptionalClusteredBy SkewedBy_EDIT OptionalRowFormat OptionalImpalaWithSerdeproperties OptionalStoredAsOrBy
+   OptionalHiveWithSerdeproperties OptionalHdfsLocation OptionalCachedInOrUncached OptionalTblproperties OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification OptionalHiveComment OptionalPartitionedBy OptionalSortBy OptionalImpalaComment
+   OptionalClusteredBy OptionalSkewedBy RowFormat_EDIT OptionalImpalaWithSerdeproperties OptionalStoredAsOrBy
+   OptionalHiveWithSerdeproperties OptionalHdfsLocation OptionalCachedInOrUncached OptionalTblproperties OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification OptionalHiveComment OptionalPartitionedBy OptionalSortBy OptionalImpalaComment
+   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat ImpalaWithSerdeproperties_EDIT OptionalStoredAsOrBy
+   OptionalHiveWithSerdeproperties OptionalHdfsLocation OptionalCachedInOrUncached OptionalTblproperties OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification OptionalHiveComment OptionalPartitionedBy OptionalSortBy OptionalImpalaComment
+   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalImpalaWithSerdeproperties StoredAsOrBy_EDIT
+   OptionalHiveWithSerdeproperties OptionalHdfsLocation OptionalCachedInOrUncached OptionalTblproperties OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification OptionalHiveComment OptionalPartitionedBy OptionalSortBy OptionalImpalaComment
+   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalImpalaWithSerdeproperties OptionalStoredAsOrBy
+   HiveWithSerdeproperties_EDIT OptionalHdfsLocation OptionalCachedInOrUncached OptionalTblproperties OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification OptionalHiveComment OptionalPartitionedBy OptionalSortBy OptionalImpalaComment
+   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalImpalaWithSerdeproperties OptionalStoredAsOrBy
+   OptionalHiveWithSerdeproperties HdfsLocation_EDIT OptionalCachedInOrUncached OptionalTblproperties OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification OptionalHiveComment OptionalPartitionedBy OptionalSortBy OptionalImpalaComment
+   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalImpalaWithSerdeproperties OptionalStoredAsOrBy
+   OptionalHiveWithSerdeproperties OptionalHdfsLocation CachedIn_EDIT OptionalTblproperties OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification OptionalHiveComment OptionalPartitionedBy OptionalSortBy OptionalImpalaComment
+   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalImpalaWithSerdeproperties OptionalStoredAsOrBy
+   OptionalHiveWithSerdeproperties OptionalHdfsLocation CachedIn WithReplication_EDIT OptionalTblproperties OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification OptionalHiveComment OptionalPartitionedBy OptionalSortBy OptionalImpalaComment
+   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalImpalaWithSerdeproperties OptionalStoredAsOrBy
+   OptionalHiveWithSerdeproperties OptionalHdfsLocation OptionalCachedInOrUncached OptionalTblproperties OptionalAsSelectStatement_EDIT
+ | TableIdentifierAndOptionalColumnSpecification OptionalHiveComment OptionalPartitionedBy OptionalSortBy OptionalImpalaComment
+   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalImpalaWithSerdeproperties OptionalStoredAsOrBy
+   OptionalHiveWithSerdeproperties OptionalHdfsLocation OptionalCachedInOrUncached OptionalTblproperties 'CURSOR'
    {
      var keywords = [];
-     if (!$1 && !$2 && !$3 && !$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10 && !$11) {
+     if (!$1 && !$2 && !$3 && !$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10 && !$11 && !$12 && !$13 && !$14) {
        keywords.push({ value: 'LIKE', weight: 1 });
        if (parser.isImpala()) {
          keywords.push({ value: 'LIKE PARQUET', weight: 1 });
        }
      } else {
-       if (!$2 && !$3 && !$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10 && !$11) {
-         keywords.push({ value: 'COMMENT', weight: 11 });
+       if (parser.isHive() && !$2 && !$3 && !$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10 && !$11 && !$12 && !$13 && !$14) {
+         keywords.push({ value: 'COMMENT', weight: 13 });
        }
-       if (!$3 && !$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10 && !$11) {
-         keywords.push({ value: 'PARTITIONED BY', weight: 10 });
+       if (!$3 && !$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10 && !$11 && !$12 && !$13 && !$14) {
+         keywords.push({ value: 'PARTITIONED BY', weight: 12 });
          if (parser.isImpala()) {
-           keywords.push({ value: 'PARTITION BY', weight: 10 });
+           keywords.push({ value: 'PARTITION BY', weight: 12 });
          }
        }
-       if (parser.isImpala() && !$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10 && !$11) {
-         keywords.push({ value: 'SORT BY', weight: 9 });
+       if (!$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10 && !$11 && !$12 && !$13 && !$14) {
+         keywords.push({ value: 'SORT BY', weight: 11 });
+       }
+       if (parser.isImpala() && !$5 && !$6 && !$7 && !$8 && !$9 && !$10 && !$11 && !$12 && !$13 && !$14) {
+         keywords.push({ value: 'COMMENT', weight: 10 });
+       }
+       if (parser.isHive() && !$6 && !$7 && !$8 && !$9 && !$10 && !$11 && !$12 && !$13 && !$14) {
+         keywords.push({ value: 'CLUSTERED BY', weight: 9 });
        }
-       if (parser.isHive() && !$5 && !$6 && !$7 && !$8 && !$9 && !$10 && !$11) {
-         keywords.push({ value: 'CLUSTERED BY', weight: 8 });
+       if (parser.isHive() && !$7 && !$8 && !$9 && !$10 && !$11 && !$12 && !$13 && !$14) {
+         keywords.push({ value: 'SKEWED BY', weight: 8 });
+       } else if (parser.isHive() && $7 && $7.suggestKeywords && !$8 && !$9 && !$10 && !$11 && !$12 && !$13 && !$14) {
+         keywords = keywords.concat(parser.createWeightedKeywords($7.suggestKeywords, 8)); // Get the last optional from SKEWED BY
        }
-       if (parser.isHive() && !$6 && !$7 && !$8 && !$9 && !$10 && !$11) {
-         keywords.push({ value: 'SKEWED BY', weight: 7 });
-       } else if (parser.isHive() && $6 && $6.suggestKeywords && !$7 && !$8 && !$9 && !$10 && !$10) {
-         keywords = keywords.concat(parser.createWeightedKeywords($6.suggestKeywords, 7)); // Get the last optional from SKEWED BY
+       if (!$8 && !$9 && !$10 && !$11 && !$12 && !$13 && !$14) {
+         keywords.push({ value: 'ROW FORMAT', weight: 7 });
+       } else if ($8 && $8.suggestKeywords && !$9 && !$10 && !$11 && !$12 && !$13 && !$14) {
+         keywords = keywords.concat(parser.createWeightedKeywords($8.suggestKeywords, 7));
        }
-       if (!$7 && !$8 && !$9 && !$10 && !$11) {
-         keywords.push({ value: 'ROW FORMAT', weight: 6 });
-         keywords.push({ value: 'STORED AS', weight: 6 });
+       if (parser.isImpala() && !$9 && !$10 && !$11 && !$12 && !$13 && !$14) {
+         keywords.push({ value: 'WITH SERDEPROPERTIES', weight: 6 });
+       }
+       if (!$10 && !$11 && !$12 && !$13 && !$14) {
+         keywords.push({ value: 'STORED AS', weight: 5 });
          if (parser.isHive()) {
-           keywords.push({ value: 'STORED BY', weight: 6 });
+           keywords.push({ value: 'STORED BY', weight: 5 });
          }
-       } else if ($7 && $7.suggestKeywords && !$8 && !$9 && !$10 && !$11) {
-         keywords = keywords.concat(parser.createWeightedKeywords($7.suggestKeywords, 6));
        }
-       if ((($7 && $7.storedBy) || parser.isImpala()) && !$8 && !$9 && !$10 && !$11) {
-         keywords.push({ value: 'WITH SERDEPROPERTIES', weight: 5 });
+       if (parser.isHive() && $10 && $10.storedBy && !$11 && !$12 && !$13 && !$14) {
+         keywords.push({ value: 'WITH SERDEPROPERTIES', weight: 6 });
        }
-       if (!$9 && !$10 && !$11) {
+       if (!$12 && !$13 && !$14) {
          keywords.push({ value: 'LOCATION', weight: 4 });
        }
-       if (!$10 && !$11) {
-         keywords.push({ value: 'TBLPROPERTIES', weight: 3 });
-       }
-       if (parser.isImpala() && !$11) {
-         keywords.push({ value: 'CACHED IN', weight: 2 }, { value: 'UNCACHED', weight: 2 });
+       if (parser.isImpala() && !$13 && !$14) {
+         keywords.push({ value: 'CACHED IN', weight: 3 }, { value: 'UNCACHED', weight: 3 });
+       } else if (parser.isImpala() && $13 && $13.suggestKeywords && !$14) {
+         keywords = keywords.concat(parser.createWeightedKeywords($13.suggestKeywords, 3));
        }
-       if (parser.isImpala() && $11 && $11.suggestKeywords) {
-         keywords = keywords.concat(parser.createWeightedKeywords($11.suggestKeywords, 2));
+       if (!$14) {
+         keywords.push({ value: 'TBLPROPERTIES', weight: 2 });
        }
        keywords.push({ value: 'AS', weight: 1 });
      }
@@ -715,8 +762,9 @@ OptionalPartitionedBy
 
 PartitionedBy
  : HiveOrImpalaPartitioned 'BY' ParenthesizedColumnSpecificationList
- | 'PARTITION' 'BY' AnyRange ParenthesizedColumnList ParenthesizedPartitionValuesList
- | 'PARTITION' 'BY' '<impala>HASH' ParenthesizedColumnList '<impala>PARTITIONS' UnsignedNumericLiteral
+ | 'PARTITION' 'BY' HashClauses
+ | 'PARTITION' 'BY' HashClauses ',' RangeClause
+ | 'PARTITION' 'BY' RangeClause
  ;
 
 PartitionedBy_EDIT
@@ -738,14 +786,51 @@ PartitionedBy_EDIT
    {
      parser.suggestKeywords(['HASH', 'RANGE']);
    }
- | 'PARTITION' 'BY' AnyRange ParenthesizedColumnList_EDIT
- | 'PARTITION' 'BY' AnyRange ParenthesizedColumnList ParenthesizedPartitionValuesList_EDIT
- | 'PARTITION' 'BY' '<impala>HASH' ParenthesizedColumnList_EDIT
- | 'PARTITION' 'BY' '<impala>HASH' ParenthesizedColumnList 'CURSOR'
+ | 'PARTITION' 'BY' HashClauses_EDIT
+ | 'PARTITION' 'BY' RangeClause_EDIT
+ | 'PARTITION' 'BY' HashClauses ',' 'CURSOR'
+   {
+     parser.suggestKeywords(['HASH', 'RANGE']);
+   }
+ | 'PARTITION' 'BY' HashClauses ',' RangeClause_EDIT
+ | 'PARTITION' 'BY' HashClauses_EDIT ',' RangeClause
+ ;
+
+HashClauses
+ : HashClause
+ | HashClauses ',' HashClause
+ ;
+
+HashClauses_EDIT
+ : HashClause_EDIT
+ | HashClauses ',' HashClause_EDIT
+ | HashClauses ',' HashClause_EDIT ',' HashClauses
+ ;
+
+HashClause
+ : '<impala>HASH' OptionalParenthesizedColumnList '<impala>PARTITIONS' UnsignedNumericLiteral
+ ;
+
+HashClause_EDIT
+ : '<impala>HASH' OptionalParenthesizedColumnList 'CURSOR'
    {
      parser.suggestKeywords(['PARTITIONS']);
    }
- | 'PARTITION' 'BY' '<impala>HASH' ParenthesizedColumnList_EDIT '<impala>PARTITIONS' UnsignedNumericLiteral
+ | '<impala>HASH' ParenthesizedColumnList_EDIT
+ | '<impala>HASH' OptionalParenthesizedColumnList '<impala>PARTITIONS' 'CURSOR'
+ | '<impala>HASH' ParenthesizedColumnList_EDIT '<impala>PARTITIONS' UnsignedNumericLiteral
+ ;
+
+RangeClause
+ : AnyRange ParenthesizedColumnList ParenthesizedPartitionValuesList
+ ;
+
+RangeClause_EDIT
+ : AnyRange 'CURSOR'
+ | AnyRange ParenthesizedColumnList_EDIT
+ | AnyRange ParenthesizedColumnList 'CURSOR'
+ | AnyRange ParenthesizedColumnList ParenthesizedPartitionValuesList_EDIT
+ | AnyRange ParenthesizedColumnList_EDIT ParenthesizedPartitionValuesList
  ;
 
 OptionalSortBy
@@ -987,6 +1072,34 @@ SkewedValueList
  | SkewedValueList ',' ParenthesizedSimpleValueList
  ;
 
+OptionalRowFormat
+ :
+ | RowFormat
+ ;
+
+RowFormat
+ : 'ROW' HiveOrImpalaFormat HiveOrImpalaRowFormat
+   {
+     $$ = $3
+   }
+ ;
+
+RowFormat_EDIT
+ : 'ROW' 'CURSOR'
+   {
+     parser.suggestKeywords(['FORMAT']);
+   }
+ | 'ROW' HiveOrImpalaFormat 'CURSOR'
+   {
+     if (parser.isHive()) {
+       parser.suggestKeywords(['DELIMITED', 'SERDE']);
+     } else {
+       parser.suggestKeywords(['DELIMITED']);
+     }
+   }
+ | 'ROW' HiveOrImpalaFormat HiveOrImpalaRowFormat_EDIT
+ ;
+
 OptionalStoredAsOrBy
  :
  | StoredAsOrBy
@@ -994,15 +1107,7 @@ OptionalStoredAsOrBy
 
 StoredAsOrBy
  : StoredAs
- | 'ROW' HiveOrImpalaFormat HiveOrImpalaRowFormat OptionalStoredAs
-   {
-     $$ = parser.mergeSuggestKeywords($3, $4)
-   }
- | '<hive>STORED' 'BY' QuotedValue OptionalWithSerdeproperties
-  {
-    $$ = { storedBy: true }
-  }
- | '<hive>STORED' 'BY' QuotedValue WithSerdeproperties_EDIT
+ | '<hive>STORED' 'BY' QuotedValue
   {
     $$ = { storedBy: true }
   } 
@@ -1018,24 +1123,6 @@ StoredAsOrBy_EDIT
      }
    }
  | StoredAs_EDIT
- | 'ROW' 'CURSOR'
-   {
-     parser.suggestKeywords(['FORMAT']);
-   }
- | 'ROW' HiveOrImpalaFormat 'CURSOR'
-   {
-     if (parser.isHive()) {
-       parser.suggestKeywords(['DELIMITED', 'SERDE']);
-     } else {
-       parser.suggestKeywords(['DELIMITED']);
-     }
-   }
- | 'ROW' HiveOrImpalaFormat HiveOrImpalaRowFormat_EDIT
- | 'ROW' HiveOrImpalaFormat HiveOrImpalaRowFormat HiveOrImpalaStored 'CURSOR'
-   {
-     parser.suggestKeywords(['AS']);
-   }
- | 'ROW' HiveOrImpalaFormat HiveOrImpalaRowFormat StoredAs_EDIT
  ;
 
 OptionalStoredAs
@@ -1083,8 +1170,7 @@ HiveOrImpalaRowFormat_EDIT
 
 HiveRowFormat
  : HiveDelimitedRowFormat
- | '<hive>SERDE' QuotedValue OptionalWithSerdeproperties
- | '<hive>SERDE' QuotedValue WithSerdeproperties_EDIT
+ | '<hive>SERDE' QuotedValue
  ;
 
 HiveRowFormat_EDIT
@@ -1235,9 +1321,19 @@ OptionalNullDefinedAs_EDIT
    }
  ;
 
- OptionalWithSerdeproperties
- : 
+OptionalWithSerdeproperties
+ :
+ | ImpalaWithSerdeproperties
+ | HiveWithSerdeproperties
+ ;
+
+OptionalImpalaWithSerdeproperties
+ :
  | ImpalaWithSerdeproperties
+ ;
+
+OptionalHiveWithSerdeproperties
+ :
  | HiveWithSerdeproperties
  ;
 
@@ -1254,7 +1350,7 @@ WithSerdeproperties_EDIT
  | ImpalaWithSerdeproperties_EDIT
  ;
 
- HiveWithSerdeproperties_EDIT
+HiveWithSerdeproperties_EDIT
  : '<hive>WITH' 'CURSOR'
    {
      parser.suggestKeywords(['SERDEPROPERTIES']);
@@ -1265,7 +1361,7 @@ WithSerdeproperties_EDIT
    }
  ;
 
-  ImpalaWithSerdeproperties_EDIT
+ImpalaWithSerdeproperties_EDIT
  : '<impala>WITH' 'CURSOR'
    {
      parser.suggestKeywords(['SERDEPROPERTIES']);
@@ -1743,19 +1839,8 @@ AnyRole
 
 IndexDefinition
  : AnyCreate '<hive>INDEX' RegularOrBacktickedIdentifier 'ON' '<hive>TABLE' ExistingTable ParenthesizedIndexColumnList
-   '<hive>AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalStoredAsOrBy OptionalHdfsLocation
-   OptionalTblproperties OptionalComment
- ;
-
-ExistingTable
- : SchemaQualifiedTableIdentifier
-   {
-     parser.addTablePrimary($1);
-   }
- ;
-
-ExistingTable_EDIT
- : SchemaQualifiedTableIdentifier_EDIT
+   '<hive>AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalRowFormat
+   OptionalStoredAsOrBy  OptionalHdfsLocation OptionalTblproperties OptionalComment
  ;
 
 IndexDefinition_EDIT
@@ -1784,50 +1869,71 @@ IndexDefinition_EDIT
      parser.suggestKeywords(['\'BITMAP\'', '\'COMPACT\'']);
    }
  | AnyCreate '<hive>INDEX' RegularOrBacktickedIdentifier 'ON' '<hive>TABLE' ExistingTable ParenthesizedIndexColumnList
-   '<hive>AS' IndexType_EDIT OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalStoredAsOrBy OptionalHdfsLocation
+   '<hive>AS' IndexType_EDIT OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
    OptionalTblproperties OptionalComment
  | AnyCreate '<hive>INDEX' RegularOrBacktickedIdentifier 'ON' '<hive>TABLE' ExistingTable_EDIT ParenthesizedIndexColumnList
-   '<hive>AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalStoredAsOrBy OptionalHdfsLocation
+   '<hive>AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
    OptionalTblproperties OptionalComment
  | AnyCreate '<hive>INDEX' RegularOrBacktickedIdentifier 'ON' '<hive>TABLE' ExistingTable ParenthesizedIndexColumnList_EDIT
-   '<hive>AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalStoredAsOrBy OptionalHdfsLocation
+   '<hive>AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
    OptionalTblproperties OptionalComment
  | AnyCreate '<hive>INDEX' RegularOrBacktickedIdentifier 'ON' '<hive>TABLE' ExistingTable ParenthesizedIndexColumnList
-   '<hive>AS' IndexType OptionalWithDeferredRebuild_EDIT OptionalIdxProperties OptionalInTable OptionalStoredAsOrBy OptionalHdfsLocation
+   '<hive>AS' IndexType OptionalWithDeferredRebuild_EDIT OptionalIdxProperties OptionalInTable OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
    OptionalTblproperties OptionalComment
  | AnyCreate '<hive>INDEX' RegularOrBacktickedIdentifier 'ON' '<hive>TABLE' ExistingTable ParenthesizedIndexColumnList
-   '<hive>AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable_EDIT OptionalStoredAsOrBy OptionalHdfsLocation
+   '<hive>AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable_EDIT OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
    OptionalTblproperties OptionalComment
  | AnyCreate '<hive>INDEX' RegularOrBacktickedIdentifier 'ON' '<hive>TABLE' ExistingTable ParenthesizedIndexColumnList
-   '<hive>AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable StoredAsOrBy_EDIT OptionalHdfsLocation
+   '<hive>AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable RowFormat_EDIT OptionalStoredAsOrBy OptionalHdfsLocation
    OptionalTblproperties OptionalComment
  | AnyCreate '<hive>INDEX' RegularOrBacktickedIdentifier 'ON' '<hive>TABLE' ExistingTable ParenthesizedIndexColumnList
-   '<hive>AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalStoredAsOrBy HdfsLocation_EDIT
+   '<hive>AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalRowFormat StoredAsOrBy_EDIT OptionalHdfsLocation
+   OptionalTblproperties OptionalComment
+   {
+     if ($13 && parser.yy.result.suggestKeywords && parser.yy.result.suggestKeywords.length === 2) {
+       parser.suggestKeywords(['AS']);
+     }
+   }
+ | AnyCreate '<hive>INDEX' RegularOrBacktickedIdentifier 'ON' '<hive>TABLE' ExistingTable ParenthesizedIndexColumnList
+   '<hive>AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalRowFormat OptionalStoredAsOrBy HdfsLocation_EDIT
    OptionalTblproperties OptionalComment
  | AnyCreate '<hive>INDEX' RegularOrBacktickedIdentifier 'ON' '<hive>TABLE' ExistingTable ParenthesizedIndexColumnList
-   '<hive>AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalStoredAsOrBy OptionalHdfsLocation
+   '<hive>AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
    OptionalTblproperties OptionalComment 'CURSOR'
    {
-     if (!$10 && !$11 && !$12 && !$13 && !$14 && !$15 && !$16) {
+     if (!$10 && !$11 && !$12 && !$13 && !$14 && !$15 && !$16 && !$17) {
        parser.suggestKeywords([{ value: 'WITH DEFERRED REBUILD', weight: 7 }, { value: 'IDXPROPERTIES', weight: 6 }, { value: 'IN TABLE', weight: 5 }, { value: 'ROW FORMAT', weight: 4 }, { value: 'STORED AS', weight: 4 }, { value: 'STORED BY', weight: 4 }, { value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]);
-     } else if (!$11 && !$12 && !$13 && !$14 && !$15 && !$16) {
+     } else if (!$11 && !$12 && !$13 && !$14 && !$15 && !$16 && !$17) {
        parser.suggestKeywords([{ value: 'IDXPROPERTIES', weight: 6 }, { value: 'IN TABLE', weight: 5 }, { value: 'ROW FORMAT', weight: 4 }, { value: 'STORED AS', weight: 4 }, { value: 'STORED BY', weight: 4 }, { value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]);
-     } else if (!$12 && !$13 && !$14 && !$15 && !$16) {
+     } else if (!$12 && !$13 && !$14 && !$15 && !$16 && !$17) {
        parser.suggestKeywords([{ value: 'IN TABLE', weight: 5 }, { value: 'ROW FORMAT', weight: 4 }, { value: 'STORED AS', weight: 4 }, { value: 'STORED BY', weight: 4 }, { value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]);
-     } else if (!$13 && !$14 && !$15 && !$16) {
+     } else if (!$13 && !$14 && !$15 && !$16 && !$17) {
        parser.suggestKeywords([{ value: 'ROW FORMAT', weight: 4 }, { value: 'STORED AS', weight: 4 }, { value: 'STORED BY', weight: 4 }, { value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]);
      } else if ($13 && $13.suggestKeywords && !$14 && !$15 && !$16) {
-       parser.suggestKeywords(parser.createWeightedKeywords($13.suggestKeywords, 4).concat([{ value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]));
-     } else if (!$14 && !$15 && !$16) {
+       parser.suggestKeywords(parser.createWeightedKeywords($13.suggestKeywords, 5).concat([{ value: 'STORED AS', weight: 4 }, { value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]));
+     } else if (!$14 && !$15 && !$16 && !$17) {
+       parser.suggestKeywords([{ value: 'STORED AS', weight: 4 }, { value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]);
+     } else if (!$15 && !$16 && !$17) {
        parser.suggestKeywords([{ value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]);
-     } else if (!$15 && !$16) {
+     } else if (!$16 && !$17) {
        parser.suggestKeywords([{ value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]);
-     } else if (!$16) {
+     } else if (!$17) {
        parser.suggestKeywords([{ value: 'COMMENT', weight: 1 }]);
      }
    }
  ;
 
+ExistingTable
+ : SchemaQualifiedTableIdentifier
+   {
+     parser.addTablePrimary($1);
+   }
+ ;
+
+ExistingTable_EDIT
+ : SchemaQualifiedTableIdentifier_EDIT
+ ;
+
 IndexType
  : QuotedValue
  ;

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

@@ -326,7 +326,7 @@ WithGrantOption_EDIT
    {
      parser.suggestKeywords(['OPTION']);
    }
- | '<hive>WITH' '<impala>GRANT' 'CURSOR'
+ | '<impala>WITH' '<impala>GRANT' 'CURSOR'
    {
      parser.suggestKeywords(['OPTION']);
    }

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

@@ -823,7 +823,6 @@ NonStartingToken
  | 'VARIANCE'
  | 'WHEN'
  | 'WHERE'
- | AnyWith
  ;
 
 DataDefinition
@@ -2520,9 +2519,7 @@ OptionalHiveGroupingSetsCubeOrRollup_EDIT
  : HiveGroupingSets_EDIT
  | '<hive>WITH' 'CURSOR'
    {
-     if (parser.isHive()) {
-       parser.suggestKeywords(['CUBE', 'ROLLUP']);
-     }
+     parser.suggestKeywords(['CUBE', 'ROLLUP']);
    }
  ;
 

+ 140 - 31
desktop/core/src/desktop/static/desktop/js/autocomplete/spec/sqlSpecCreate.js

@@ -1110,14 +1110,114 @@
           });
         });
 
-        it('should handle "CREATE ... TABLE ... LIKE PARQUET ... PARTITIONED BY ... ROW FORMAT ... CACHED ...;|"', function () {
+        it('should handle "CREATE ... TABLE ... PARTITIONED BY ... ROW FORMAT ... UNCACHED ...;|"', function () {
+          assertAutoComplete({
+            beforeCursor: 'CREATE EXTERNAL TABLE IF NOT EXISTS foo.bar ' +
+              '(foo int COMMENT \'col_comment\', bar int COMMENT \'col_comment\') ' +
+              'PARTITIONED BY (foo int COMMENT \'col_comment\', bar int COMMENT \'col_comment\') ' +
+              'SORT BY (foo, bar) ' +
+              'COMMENT \'table_comment\' ' +
+              'ROW FORMAT DELIMITED FIELDS TERMINATED BY \'c\' ESCAPED BY \'c\' ' +
+              'LINES TERMINATED BY \'c\' ' +
+              'WITH SERDEPROPERTIES (\'key1\'=\'value1\', \'key2\'=\'value2\') ' +
+              'STORED AS PARQUET ' +
+              'LOCATION \'/hdfs_path\' ' +
+              'UNCACHED ' +
+              'TBLPROPERTIES (\'key1\'=\'value1\', \'key2\'=\'value2\');',
+            afterCursor: '',
+            dialect: 'impala',
+            noErrors: true,
+            containsKeywords: ['SELECT'],
+            expectedResult: {
+              lowerCase: false
+            }
+          });
+        });
+
+        it('should handle "CREATE ... TABLE ... PARTITIONED BY ... ROW FORMAT ... CACHED ...;|"', function () {
+          assertAutoComplete({
+            beforeCursor: 'CREATE EXTERNAL TABLE IF NOT EXISTS foo.bar ' +
+              '(foo int COMMENT \'col_comment\', bar int COMMENT \'col_comment\') ' +
+              'PARTITIONED BY (foo int COMMENT \'col_comment\', bar int COMMENT \'col_comment\') ' +
+              'SORT BY (foo, bar) ' +
+              'COMMENT \'table_comment\' ' +
+              'ROW FORMAT DELIMITED FIELDS TERMINATED BY \'c\' ESCAPED BY \'c\' ' +
+              'LINES TERMINATED BY \'c\' ' +
+              'WITH SERDEPROPERTIES (\'key1\'=\'value1\', \'key2\'=\'value2\') ' +
+              'STORED AS PARQUET ' +
+              'LOCATION \'/hdfs_path\' ' +
+              'CACHED IN \'pool_name\' WITH REPLICATION = 1 ' +
+              'TBLPROPERTIES (\'key1\'=\'value1\', \'key2\'=\'value2\');',
+            afterCursor: '',
+            dialect: 'impala',
+            noErrors: true,
+            containsKeywords: ['SELECT'],
+            expectedResult: {
+              lowerCase: false
+            }
+          });
+        });
+
+        it('should handle "CREATE ... TABLE ... PARTITIONED BY ... ROW FORMAT ... AS SELECT ...;|"', function () {
+          assertAutoComplete({
+            beforeCursor: 'CREATE EXTERNAL TABLE IF NOT EXISTS foo.bar ' +
+              'PARTITIONED BY (foo int COMMENT \'col_comment\', bar int COMMENT \'col_comment\') ' +
+              'SORT BY (foo, bar) ' +
+              'COMMENT \'table_comment\' ' +
+              'ROW FORMAT DELIMITED FIELDS TERMINATED BY \'c\' ESCAPED BY \'c\' ' +
+              'LINES TERMINATED BY \'c\' ' +
+              'WITH SERDEPROPERTIES (\'key1\'=\'value1\', \'key2\'=\'value2\') ' +
+              'STORED AS PARQUET ' +
+              'LOCATION \'/hdfs_path\' ' +
+              'CACHED IN \'pool_name\' WITH REPLICATION = 1 ' +
+              'TBLPROPERTIES (\'key1\'=\'value1\', \'key2\'=\'value2\') ' +
+              'AS SELECT * FROM boo;',
+            afterCursor: '',
+            dialect: 'impala',
+            noErrors: true,
+            containsKeywords: ['SELECT'],
+            expectedResult: {
+              lowerCase: false
+            }
+          });
+        });
+
+        it('should handle "CREATE ... TABLE ... LIKE PARQUET ... PARTITIONED BY ... ROW FORMAT ...;|"', 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) ' +
-            'SORT BY (baa, boo, ble) ROW FORMAT DELIMITED FIELDS TERMINATED BY \'a\' ESCAPED BY \'c\' ' +
-            'LINES TERMINATED BY \'q\' WITH SERDEPROPERTIES ( \'key\' = \'value\', \'key2\' = \'value 2\' ) STORED AS PARQUET ' +
-            'LOCATION \'/baa/baa\' TBLPROPERTIES (\'key\' = \'value\', \'key2\' = \'value 2\') ' +
-            'CACHED IN \'boo\';',
+            beforeCursor: 'CREATE EXTERNAL TABLE IF NOT EXISTS foo.bar ' +
+              'LIKE PARQUET \'/hdfs_path_of_parquet_file\' ' +
+              'PARTITIONED BY (foo int COMMENT \'col_comment\', bar int COMMENT \'col_comment\') ' +
+              'SORT BY (foo, bar) ' +
+              'COMMENT \'table_comment\' ' +
+              'ROW FORMAT DELIMITED FIELDS TERMINATED BY \'c\' ESCAPED BY \'c\' ' +
+              'LINES TERMINATED BY \'c\' ' +
+              'WITH SERDEPROPERTIES (\'key1\'=\'value1\', \'key2\'=\'value2\') ' +
+              'STORED AS PARQUET ' +
+              'LOCATION \'/hdfs_path\' ' +
+              'CACHED IN \'pool_name\' WITH REPLICATION = 1 ' +
+              'TBLPROPERTIES (\'key1\'=\'value1\', \'key2\'=\'value2\');',
+            afterCursor: '',
+            dialect: 'impala',
+            noErrors: true,
+            containsKeywords: ['SELECT'],
+            expectedResult: {
+              lowerCase: false
+            }
+          });
+        });
+
+        it('should handle "CREATE ... TABLE ... PARTITIONED BY ... STORED AS KUDU ...;|"', function () {
+          assertAutoComplete({
+            beforeCursor: 'CREATE TABLE IF NOT EXISTS bar\n' +
+              '(foo int NOT NULL COMMENT \'col_comment\', bar int BLOCK_SIZE 1 COMMENT \'col_comment\', PRIMARY KEY (foo))\n' +
+              'PARTITION BY HASH (id) PARTITIONS 3,\n' +
+              '  RANGE (year) (PARTITION 1980 <= VALUES < 1990,\n' +
+              '    PARTITION 1990 <= VALUES < 2000,\n' +
+              '    PARTITION VALUE = 2001,\n' +
+              '    PARTITION 2001 < VALUES)\n' +
+              'COMMENT \'table_comment\'\n' +
+              'STORED AS KUDU\n' +
+              'TBLPROPERTIES (\'key1\'=\'value1\', \'key2\'=\'value2\');',
             afterCursor: '',
             dialect: 'impala',
             noErrors: true,
@@ -1282,7 +1382,7 @@
             dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['TBLPROPERTIES', 'CACHED IN', 'UNCACHED', 'AS']
+              suggestKeywords: ['CACHED IN', 'UNCACHED', 'TBLPROPERTIES', 'AS']
             }
           });
         });
@@ -1400,7 +1500,7 @@
             beforeCursor: 'CREATE TABLE foo (id int) ROW FORMAT DELIMITED ',
             afterCursor: '',
             dialect: 'impala',
-            containsKeywords: ['AS', 'FIELDS TERMINATED BY', 'LINES TERMINATED BY' ],
+            containsKeywords: ['FIELDS TERMINATED BY', 'LINES TERMINATED BY', 'WITH SERDEPROPERTIES', 'STORED AS', 'LOCATION', 'CACHED IN', 'UNCACHED', 'TBLPROPERTIES', 'AS'],
             doestNotContainKeywords: ['ROW FORMAT'],
             expectedResult: {
               lowerCase: false
@@ -1501,7 +1601,7 @@
             dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['WITH REPLICATION =', 'AS']
+              suggestKeywords: ['WITH REPLICATION =', 'TBLPROPERTIES', 'AS']
             }
           });
         });
@@ -1532,12 +1632,15 @@
 
         it('should suggest keywords for "CREATE ... TABLE ... PARTITIONED BY ... ROW FORMAT ... CACHED |"', 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) ' +
-            'ROW FORMAT DELIMITED FIELDS TERMINATED BY \'a\' ESCAPED BY \'c\' LINES TERMINATED BY \'q\' ' +
-            'WITH SERDEPROPERTIES ( \'key\' = \'value\', \'key2\' = \'value 2\' ) STORED AS PARQUET' +
-            'LOCATION \'/baa/baa\' TBLPROPERTIES (\'key\' = \'value\', \'key2\' = \'value 2\') ' +
-            'CACHED ',
+            beforeCursor: 'CREATE EXTERNAL TABLE IF NOT EXISTS dbOne.tableName\n' +
+              '  (id INT, col2 STRING COMMENT \'booo\', col3 BIGINT)\n' +
+              'PARTITIONED BY (boo DOUBLE COMMENT \'booo boo\', baa INT)\n' +
+              'COMMENT \'Table comment...\' \n' +
+              'ROW FORMAT DELIMITED FIELDS TERMINATED BY \'a\' ESCAPED BY \'c\' LINES TERMINATED BY \'q\'\n' +
+              'WITH SERDEPROPERTIES ( \'key\' = \'value\', \'key2\' = \'value 2\' ) \n' +
+              'STORED AS PARQUET\n' +
+              'LOCATION \'/baa/baa\'\n' +
+              'CACHED ',
             afterCursor: '',
             dialect: 'impala',
             expectedResult: {
@@ -1549,12 +1652,16 @@
 
         it('should suggest keywords for "CREATE ... TABLE ... LIKE PARQUET ... PARTITIONED BY ... ROW FORMAT ... CACHED |"', 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) ' +
-            'SORT BY (baa, boo, ble) ROW FORMAT DELIMITED FIELDS TERMINATED BY \'a\' ESCAPED BY \'c\' LINES TERMINATED BY \'q\' ' +
-            'WITH SERDEPROPERTIES ( \'key\' = \'value\', \'key2\' = \'value 2\' ) '+
-            'STORED AS PARQUET LOCATION \'/baa/baa\' TBLPROPERTIES (\'key\' = \'value\', \'key2\' = \'value 2\') ' +
-            'CACHED ',
+            beforeCursor: 'CREATE EXTERNAL TABLE IF NOT EXISTS dbOne.tableName \n' +
+              'LIKE PARQUET \'/boo/baa\'\n' +
+              'PARTITIONED BY (boo DOUBLE COMMENT \'booo boo\', baa INT)\n' +
+              'SORT BY (baa, boo, ble)\n' +
+              'COMMENT \'Table comment...\' \n' +
+              'ROW FORMAT DELIMITED FIELDS TERMINATED BY \'a\' ESCAPED BY \'c\' LINES TERMINATED BY \'q\'\n' +
+              'WITH SERDEPROPERTIES (\'key\' = \'value\', \'key2\' = \'value 2\')\n' +
+              'STORED AS PARQUET \n' +
+              'LOCATION \'/baa/baa\'\n' +
+              'CACHED ',
             afterCursor: '',
             dialect: 'impala',
             expectedResult: {
@@ -1594,12 +1701,15 @@
 
         it('should suggest keywords for "CREATE ... TABLE ... ROW FORMAT ... CACHED IN ... AS |"', function () {
           assertAutoComplete({
-            beforeCursor: 'CREATE TABLE dbOne.tableName ' +
-            'COMMENT \'Table comment...\' ' +
-            'ROW FORMAT DELIMITED FIELDS TERMINATED BY \'a\' ESCAPED BY \'c\' LINES TERMINATED BY \'q\' ' +
-            'WITH SERDEPROPERTIES ( \'key\' = \'value\', \'key2\' = \'value 2\' ) STORED AS PARQUET ' +
-            'LOCATION \'/baa/baa\' TBLPROPERTIES (\'key\' = \'value\', \'key2\' = \'value 2\') ' +
-            'CACHED IN \'boo\' AS ',
+            beforeCursor: 'CREATE TABLE dbOne.tableName\n' +
+              'COMMENT \'Table comment...\'\n' +
+              'ROW FORMAT DELIMITED FIELDS TERMINATED BY \'a\' ESCAPED BY \'c\' LINES TERMINATED BY \'q\'\n' +
+              'WITH SERDEPROPERTIES (\'key\' = \'value\', \'key2\' = \'value 2\')\n' +
+              'STORED AS PARQUET\n' +
+              'LOCATION \'/baa/baa\'\n' +
+              'CACHED IN \'boo\'\n' +
+              'TBLPROPERTIES (\'key\' = \'value\', \'key2\' = \'value 2\')\n' +
+              'AS ',
             afterCursor: '',
             dialect: 'impala',
             expectedResult: {
@@ -2471,7 +2581,7 @@
             dialect: 'hive',
             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: ['FIELDS TERMINATED BY', 'COLLECTION ITEMS TERMINATED BY', 'MAP KEYS TERMINATED BY', 'LINES TERMINATED BY', 'NULL DEFINED AS', 'STORED AS', 'STORED BY', 'LOCATION', 'TBLPROPERTIES', 'AS']
             }
           });
         });
@@ -2506,7 +2616,6 @@
             afterCursor: '',
             dialect: 'hive',
             containsKeywords: ['STORED AS'],
-            doesNotContainKeywords: ['STORED BY'],
             expectedResult: {
               lowerCase: false
             }
@@ -2520,7 +2629,7 @@
             dialect: 'hive',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['AS']
+              suggestKeywords: ['AS', 'BY']
             }
           });
         });

文件差异内容过多而无法显示
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/sqlAutocompleteParser.js


文件差异内容过多而无法显示
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/sqlSyntaxParser.js


部分文件因为文件数量过多而无法显示