瀏覽代碼

HUE-8598 [autocomplete] Split the rules WithSerdeproperties and OptionalWithSerdeproperties into one for Impala and one for Hive (#749)

Xiao Kang 7 年之前
父節點
當前提交
02be9ec

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

@@ -200,6 +200,7 @@
 <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>'YEAR'                               { return '<hive>YEAR'; }
 
@@ -508,6 +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>'WITHIN'                           { return '<impala>WITHIN'; }
 <impala>'WITHOUT'                          { return '<impala>WITHOUT'; }
 

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

@@ -607,15 +607,15 @@ AndWait_EDIT
 
 OptionalWithOverwriteTblProperties
  :
- | 'WITH' '<hive>OVERWRITE' '<hive>TBLPROPERTIES' ParenthesizedPropertyAssignmentList
+ | '<hive>WITH' '<hive>OVERWRITE' '<hive>TBLPROPERTIES' ParenthesizedPropertyAssignmentList
  ;
 
 WithOverwriteTblProperties_EDIT
- : 'WITH' 'CURSOR'
+ : AnyWith 'CURSOR'
    {
      parser.suggestKeywords(['OVERWRITE TBLPROPERTIES']);
    }
- | 'WITH' '<hive>OVERWRITE' 'CURSOR'
+ | '<hive>WITH' '<hive>OVERWRITE' 'CURSOR'
    {
      parser.suggestKeywords(['TBLPROPERTIES']);
    }
@@ -641,7 +641,7 @@ AnyColumns
  ;
 
 HiveExchange
- : '<hive>EXCHANGE' ExchangePartitionSpec 'WITH' '<hive>TABLE' RegularOrBackTickedSchemaQualifiedName
+ : '<hive>EXCHANGE' ExchangePartitionSpec '<hive>WITH' '<hive>TABLE' RegularOrBackTickedSchemaQualifiedName
  ;
 
 HiveExchange_EDIT
@@ -653,18 +653,18 @@ HiveExchange_EDIT
    {
      parser.suggestKeywords(['WITH TABLE']);
    }
- | '<hive>EXCHANGE' ExchangePartitionSpec 'WITH' 'CURSOR'
+ | '<hive>EXCHANGE' ExchangePartitionSpec '<hive>WITH' 'CURSOR'
    {
      parser.suggestKeywords(['TABLE']);
    }
- | '<hive>EXCHANGE' ExchangePartitionSpec 'WITH' '<hive>TABLE' 'CURSOR'
+ | '<hive>EXCHANGE' ExchangePartitionSpec '<hive>WITH' '<hive>TABLE' 'CURSOR'
    {
      parser.suggestTables();
      parser.suggestDatabases({ appendDot: true });
    }
- | '<hive>EXCHANGE' ExchangePartitionSpec 'WITH' '<hive>TABLE' RegularOrBackTickedSchemaQualifiedName_EDIT
+ | '<hive>EXCHANGE' ExchangePartitionSpec '<hive>WITH' '<hive>TABLE' RegularOrBackTickedSchemaQualifiedName_EDIT
  | '<hive>EXCHANGE' ExchangePartitionSpec_EDIT
- | '<hive>EXCHANGE' ExchangePartitionSpec_EDIT 'WITH' '<hive>TABLE' RegularOrBackTickedSchemaQualifiedName
+ | '<hive>EXCHANGE' ExchangePartitionSpec_EDIT '<hive>WITH' '<hive>TABLE' RegularOrBackTickedSchemaQualifiedName
  ;
 
 ExchangePartitionSpec

+ 50 - 27
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_create.jison

@@ -168,34 +168,32 @@ TableDefinition_EDIT
 
 TableDefinitionRightPart
  : TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalSortBy OptionalClusteredBy OptionalSkewedBy
-   OptionalStoredAsOrBy OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement
+   OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement
  ;
 
 TableDefinitionRightPart_EDIT
  : TableIdentifierAndOptionalColumnSpecification_EDIT OptionalComment OptionalPartitionedBy OptionalSortBy OptionalClusteredBy OptionalSkewedBy
-   OptionalStoredAsOrBy OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement
+   OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement
  | TableIdentifierAndOptionalColumnSpecification OptionalComment PartitionedBy_EDIT OptionalSortBy OptionalClusteredBy OptionalSkewedBy
-   OptionalStoredAsOrBy OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement
+   OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement
  | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy SortBy_EDIT OptionalClusteredBy OptionalSkewedBy
-   OptionalStoredAsOrBy OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement
+   OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement
  | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalSortBy ClusteredBy_EDIT OptionalSkewedBy
-   OptionalStoredAsOrBy OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement
+   OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement
  | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalSortBy OptionalClusteredBy SkewedBy_EDIT
-   OptionalStoredAsOrBy OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement
+   OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement
  | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalSortBy OptionalClusteredBy OptionalSkewedBy
-   StoredAsOrBy_EDIT OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement
+   StoredAsOrBy_EDIT OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement
  | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalSortBy OptionalClusteredBy OptionalSkewedBy
-   OptionalStoredAsOrBy WithSerdeproperties_EDIT OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement
+   OptionalStoredAsOrBy HdfsLocation_EDIT OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement
  | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalSortBy OptionalClusteredBy OptionalSkewedBy
-   OptionalStoredAsOrBy OptionalWithSerdeproperties HdfsLocation_EDIT OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement
+   OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties CachedIn_EDIT OptionalAsSelectStatement
  | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalSortBy OptionalClusteredBy OptionalSkewedBy
-   OptionalStoredAsOrBy OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties CachedIn_EDIT OptionalAsSelectStatement
+   OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties CachedIn WithReplication_EDIT OptionalAsSelectStatement
  | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalSortBy OptionalClusteredBy OptionalSkewedBy
-   OptionalStoredAsOrBy OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties CachedIn WithReplication_EDIT OptionalAsSelectStatement
+   OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement_EDIT
  | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalSortBy OptionalClusteredBy OptionalSkewedBy
-   OptionalStoredAsOrBy OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement_EDIT
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalSortBy OptionalClusteredBy OptionalSkewedBy
-   OptionalStoredAsOrBy OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached 'CURSOR'
+   OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached 'CURSOR'
    {
      var keywords = [];
      if (!$1 && !$2 && !$3 && !$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10 && !$11) {
@@ -1000,10 +998,14 @@ StoredAsOrBy
    {
      $$ = parser.mergeSuggestKeywords($3, $4)
    }
- | '<hive>STORED' 'BY' QuotedValue
+ | '<hive>STORED' 'BY' QuotedValue OptionalWithSerdeproperties
   {
     $$ = { storedBy: true }
   }
+ | '<hive>STORED' 'BY' QuotedValue WithSerdeproperties_EDIT
+  {
+    $$ = { storedBy: true }
+  } 
  ;
 
 StoredAsOrBy_EDIT
@@ -1081,7 +1083,8 @@ HiveOrImpalaRowFormat_EDIT
 
 HiveRowFormat
  : HiveDelimitedRowFormat
- | '<hive>SERDE' QuotedValue
+ | '<hive>SERDE' QuotedValue OptionalWithSerdeproperties
+ | '<hive>SERDE' QuotedValue WithSerdeproperties_EDIT
  ;
 
 HiveRowFormat_EDIT
@@ -1232,22 +1235,42 @@ OptionalNullDefinedAs_EDIT
    }
  ;
 
-OptionalWithSerdeproperties
- :
- | WithSerdeproperties
+ OptionalWithSerdeproperties
+ : 
+ | ImpalaWithSerdeproperties
+ | HiveWithSerdeproperties
  ;
 
-WithSerdeproperties
- : 'WITH' '<hive>SERDEPROPERTIES' ParenthesizedPropertyAssignmentList
- | 'WITH' '<impala>SERDEPROPERTIES' ParenthesizedPropertyAssignmentList
+ImpalaWithSerdeproperties
+ :'<impala>WITH' '<impala>SERDEPROPERTIES' ParenthesizedPropertyAssignmentList
  ;
 
+HiveWithSerdeproperties
+ :'<hive>WITH' '<hive>SERDEPROPERTIES' ParenthesizedPropertyAssignmentList
+ ;
+  
 WithSerdeproperties_EDIT
- : 'WITH' 'CURSOR'
+ : HiveWithSerdeproperties_EDIT
+ | ImpalaWithSerdeproperties_EDIT
+ ;
+
+ HiveWithSerdeproperties_EDIT
+ : '<hive>WITH' 'CURSOR'
+   {
+     parser.suggestKeywords(['SERDEPROPERTIES']);
+   }
+ | '<hive>WITH' 'CURSOR' ParenthesizedPropertyAssignmentList
+   {
+     parser.suggestKeywords(['SERDEPROPERTIES']);
+   }
+ ;
+
+  ImpalaWithSerdeproperties_EDIT
+ : '<impala>WITH' 'CURSOR'
    {
      parser.suggestKeywords(['SERDEPROPERTIES']);
    }
- | 'WITH' 'CURSOR' ParenthesizedPropertyAssignmentList
+ | '<impala>WITH' 'CURSOR' ParenthesizedPropertyAssignmentList
    {
      parser.suggestKeywords(['SERDEPROPERTIES']);
    }
@@ -1818,15 +1841,15 @@ IndexType_EDIT
 
 OptionalWithDeferredRebuild
  :
- | 'WITH' '<hive>DEFERRED' '<hive>REBUILD'
+ | '<hive>WITH' '<hive>DEFERRED' '<hive>REBUILD'
  ;
 
 OptionalWithDeferredRebuild_EDIT
- : 'WITH' 'CURSOR'
+ : '<hive>WITH' 'CURSOR'
    {
      parser.suggestKeywords(['DEFERRED REBUILD']);
    }
- | 'WITH' '<hive>DEFERRED' 'CURSOR'
+ | '<hive>WITH' '<hive>DEFERRED' 'CURSOR'
    {
      parser.suggestKeywords(['REBUILD']);
    }

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

@@ -313,20 +313,20 @@ UserOrRoleList
 
 OptionalWithGrantOption
  :
- | 'WITH' '<hive>GRANT' 'OPTION'
- | 'WITH' '<impala>GRANT' 'OPTION'
+ | '<hive>WITH' '<hive>GRANT' 'OPTION'
+ | '<impala>WITH' '<impala>GRANT' 'OPTION'
  ;
 
 WithGrantOption_EDIT
- : 'WITH' 'CURSOR'
+ : AnyWith 'CURSOR'
    {
      parser.suggestKeywords(['GRANT OPTION']);
    }
- | 'WITH' '<hive>GRANT' 'CURSOR'
+ | '<hive>WITH' '<hive>GRANT' 'CURSOR'
    {
      parser.suggestKeywords(['OPTION']);
    }
- | 'WITH' '<impala>GRANT' 'CURSOR'
+ | '<hive>WITH' '<impala>GRANT' 'CURSOR'
    {
      parser.suggestKeywords(['OPTION']);
    }
@@ -334,15 +334,15 @@ WithGrantOption_EDIT
 
 OptionalWithAdminOption
  :
- | 'WITH' '<hive>ADMIN' 'OPTION'
+ | '<hive>WITH' '<hive>ADMIN' 'OPTION'
  ;
 
 WithAdminOption_EDIT
- : 'WITH' 'CURSOR'
+ : '<hive>WITH' 'CURSOR'
    {
      parser.suggestKeywords(['ADMIN OPTION']);
    }
- | 'WITH' '<hive>ADMIN' 'CURSOR'
+ | '<hive>WITH' '<hive>ADMIN' 'CURSOR'
    {
      parser.suggestKeywords(['OPTION']);
    }

+ 15 - 9
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_main.jison

@@ -823,7 +823,7 @@ NonStartingToken
  | 'VARIANCE'
  | 'WHEN'
  | 'WHERE'
- | 'WITH'
+ | AnyWith
  ;
 
 DataDefinition
@@ -890,6 +890,12 @@ AnyTable
  | '<impala>TABLE'
  ;
 
+AnyWith
+ : 'WITH'
+ | '<hive>WITH'
+ | '<impala>WITH'
+ ;
+
 DatabaseOrSchema
  : 'DATABASE'
  | 'SCHEMA'
@@ -1455,15 +1461,15 @@ OptionalWithReplication
  ;
 
 WithReplication
- : 'WITH' '<impala>REPLICATION' '=' SignedInteger
+ : '<impala>WITH' '<impala>REPLICATION' '=' SignedInteger
  ;
 
 WithReplication_EDIT
- : 'WITH' 'CURSOR'
+ : '<impala>WITH' 'CURSOR'
    {
      parser.suggestKeywords(['REPLICATION =']);
    }
- | 'WITH' '<impala>REPLICATION' 'CURSOR'
+ | '<impala>WITH' '<impala>REPLICATION' 'CURSOR'
    {
      parser.suggestKeywords(['=']);
    }
@@ -2033,11 +2039,11 @@ OptionalStraightJoin
  ;
 
 CommonTableExpression
- : 'WITH' WithQueries  -> $2
+ : AnyWith WithQueries  -> $2
  ;
 
 CommonTableExpression_EDIT
- : 'WITH' WithQueries_EDIT
+ : AnyWith WithQueries_EDIT
  ;
 
 WithQueries
@@ -2506,13 +2512,13 @@ GroupByClause_EDIT
 OptionalHiveGroupingSetsCubeOrRollup
  :
  | HiveGroupingSets
- | 'WITH' '<hive>CUBE'
- | 'WITH' '<hive>ROLLUP'
+ | '<hive>WITH' '<hive>CUBE'
+ | '<hive>WITH' '<hive>ROLLUP'
  ;
 
 OptionalHiveGroupingSetsCubeOrRollup_EDIT
  : HiveGroupingSets_EDIT
- | 'WITH' 'CURSOR'
+ | '<hive>WITH' 'CURSOR'
    {
      if (parser.isHive()) {
        parser.suggestKeywords(['CUBE', 'ROLLUP']);

+ 8 - 7
desktop/core/src/desktop/static/desktop/js/autocomplete/spec/sqlSpecCreate.js

@@ -1115,7 +1115,7 @@
             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\' STORED AS PARQUET WITH SERDEPROPERTIES ( \'key\' = \'value\', \'key2\' = \'value 2\' ) ' +
+            '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\';',
             afterCursor: '',
@@ -1534,8 +1534,8 @@
           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\' STORED AS PARQUET ' +
-            'WITH SERDEPROPERTIES ( \'key\' = \'value\', \'key2\' = \'value 2\' ) ' +
+            '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 ',
             afterCursor: '',
@@ -1551,8 +1551,9 @@
           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\' STORED AS PARQUET ' +
-            'WITH SERDEPROPERTIES ( \'key\' = \'value\', \'key2\' = \'value 2\' ) LOCATION \'/baa/baa\' TBLPROPERTIES (\'key\' = \'value\', \'key2\' = \'value 2\') ' +
+            '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 ',
             afterCursor: '',
             dialect: 'impala',
@@ -1595,8 +1596,8 @@
           assertAutoComplete({
             beforeCursor: 'CREATE TABLE dbOne.tableName ' +
             'COMMENT \'Table comment...\' ' +
-            'ROW FORMAT DELIMITED FIELDS TERMINATED BY \'a\' ESCAPED BY \'c\' LINES TERMINATED BY \'q\' STORED AS PARQUET ' +
-            'WITH SERDEPROPERTIES ( \'key\' = \'value\', \'key2\' = \'value 2\' ) ' +
+            '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 ',
             afterCursor: '',

文件差異過大導致無法顯示
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/sqlAutocompleteParser.js


文件差異過大導致無法顯示
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/sqlSyntaxParser.js


部分文件因文件數量過多而無法顯示