Browse Source

HUE-8856 [autocomplete] Extract jison for remaining generic statements

Johan Ahlen 6 years ago
parent
commit
f8721ba3ae

+ 6 - 20
desktop/core/src/desktop/js/parse/jison/generic/sql_alter.jison

@@ -23,42 +23,28 @@ DataDefinition_EDIT
  ;
 
 AlterStatement
- : AlterDatabase
- | AlterTable
+ : AlterTable
  | AlterView
  ;
 
 AlterStatement_EDIT
- : AlterDatabase_EDIT
- | AlterTable_EDIT
+ : AlterTable_EDIT
  | AlterView_EDIT
  | 'ALTER' 'CURSOR'
    {
-     parser.suggestKeywords(['DATABASE', 'SCHEMA', 'TABLE', 'VIEW']);
+     parser.suggestKeywords(['TABLE', 'VIEW']);
    }
  ;
 
-AlterDatabase
- ;
-
-AlterDatabase_EDIT
- ;
-
 AlterTable
- : AlterTableLeftSide OptionalPartitionOperations
- | AlterTableLeftSide PartitionSpec OptionalPartitionOperations
+ : AlterTableLeftSide PartitionSpec
  ;
 
 AlterTable_EDIT
  : AlterTableLeftSide_EDIT
- | AlterTableLeftSide_EDIT OptionalPartitionOperations
- | AlterTableLeftSide_EDIT PartitionSpec OptionalPartitionOperations
- | AlterTableLeftSide OptionalPartitionOperations_EDIT
+ | AlterTableLeftSide_EDIT PartitionSpec
  | AlterTableLeftSide 'CURSOR'
  | AlterTableLeftSide PartitionSpec 'CURSOR'
- | AlterTableLeftSide PartitionSpec 'SET' 'CURSOR'
- | AlterTableLeftSide 'SET' 'CURSOR'
- | AlterTableLeftSide PartitionSpec OptionalPartitionOperations_EDIT
  ;
 
 AlterTableLeftSide
@@ -83,7 +69,7 @@ AlterTableLeftSide_EDIT
  ;
 
 AlterView
- | AlterViewLeftSide 'AS' QuerySpecification
+ : AlterViewLeftSide 'AS' QuerySpecification
  ;
 
 AlterView_EDIT

+ 18 - 32
desktop/core/src/desktop/js/parse/jison/generic/sql_create.jison

@@ -33,13 +33,9 @@ CreateStatement_EDIT
  : DatabaseDefinition_EDIT
  | TableDefinition_EDIT
  | ViewDefinition_EDIT
- | 'CREATE' OptionalExternal 'CURSOR'
+ | 'CREATE' 'CURSOR'
    {
-     if ($2) {
-       parser.suggestKeywords(['TABLE']);
-     } else {
-       parser.suggestKeywords(['DATABASE', 'ROLE', 'SCHEMA', 'TABLE', 'VIEW']);
-     }
+     parser.suggestKeywords(['DATABASE', 'SCHEMA', 'TABLE', 'VIEW']);
    }
  ;
 
@@ -77,23 +73,16 @@ DatabaseDefinition_EDIT
  ;
 
 DatabaseDefinitionOptionals
- : OptionalComment OptionalHdfsLocation
+ : OptionalComment
    {
-     var keywords = [];
-     if (!$2) {
-       keywords.push('LOCATION');
-     }
-     if (!$1 && !$2) {
-       keywords.push('COMMENT');
-     }
-     if (keywords.length > 0) {
-       parser.suggestKeywords(keywords);
+     if (!$1) {
+       parser.suggestKeywords(['COMMENT');
      }
    }
  ;
 
 DatabaseDefinitionOptionals_EDIT
- : OptionalComment_INVALID OptionalHdfsLocation
+ : OptionalComment_INVALID
  ;
 
 OptionalComment
@@ -117,40 +106,37 @@ Comment_INVALID
  ;
 
 TableDefinition
- : 'CREATE' OptionalExternal 'TABLE' OptionalIfNotExists TableDefinitionRightPart
+ : 'CREATE' 'TABLE' OptionalIfNotExists TableDefinitionRightPart
  ;
 
 TableDefinition_EDIT
- : 'CREATE' OptionalExternal 'TABLE' OptionalIfNotExists TableDefinitionRightPart_EDIT
- | 'CREATE' OptionalExternal 'TABLE' OptionalIfNotExists 'CURSOR'
+ : 'CREATE' 'TABLE' OptionalIfNotExists TableDefinitionRightPart_EDIT
+ | 'CREATE' 'TABLE' OptionalIfNotExists 'CURSOR'
    {
-     if (!$4) {
+     if (!$3) {
        parser.suggestKeywords(['IF NOT EXISTS']);
      }
    }
- | 'CREATE' OptionalExternal 'TABLE' OptionalIfNotExists_EDIT
+ | 'CREATE' 'TABLE' OptionalIfNotExists_EDIT
  ;
 
 TableDefinitionRightPart
- : TableIdentifierAndOptionalColumnSpecification OptionalPartitionedBy OptionalHdfsLocation OptionalAsSelectStatement
+ : TableIdentifierAndOptionalColumnSpecification OptionalPartitionedBy OptionalAsSelectStatement
  ;
 
 TableDefinitionRightPart_EDIT
- : TableIdentifierAndOptionalColumnSpecification_EDIT OptionalPartitionedBy OptionalHdfsLocation OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification PartitionedBy_EDIT OptionalHdfsLocation OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalPartitionedBy OptionalHdfsLocation OptionalAsSelectStatement_EDIT
- | TableIdentifierAndOptionalColumnSpecification OptionalPartitionedBy OptionalHdfsLocation 'CURSOR'
+ : TableIdentifierAndOptionalColumnSpecification_EDIT OptionalPartitionedBy OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification PartitionedBy_EDIT OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification OptionalPartitionedBy OptionalAsSelectStatement_EDIT
+ | TableIdentifierAndOptionalColumnSpecification OptionalPartitionedBy 'CURSOR'
    {
      var keywords = [];
-     if (!$1 && !$2 && !$3) {
+     if (!$1 && !$2) {
        keywords.push({ value: 'LIKE', weight: 1 });
      } else {
-       if (!$2 && !$3) {
+       if (!$2) {
          keywords.push({ value: 'PARTITIONED BY', weight: 12 });
        }
-       if (!$3) {
-         keywords.push({ value: 'LOCATION', weight: 4 });
-       }
        keywords.push({ value: 'AS', weight: 1 });
      }
 

+ 25 - 31
desktop/core/src/desktop/js/parse/jison/generic/sql_error.jison

@@ -27,16 +27,16 @@ SqlStatement_EDIT
  ;
 
 SelectStatement
- : 'SELECT' OptionalAllOrDistinct OptionalStraightJoin SelectList_ERROR TableExpression
- | 'SELECT' OptionalAllOrDistinct OptionalStraightJoin SelectList TableExpression_ERROR
+ : 'SELECT' OptionalAllOrDistinct SelectList_ERROR TableExpression
+ | 'SELECT' OptionalAllOrDistinct SelectList TableExpression_ERROR
  ;
 
 SelectStatement_EDIT
- : 'SELECT' OptionalAllOrDistinct OptionalStraightJoin SelectList_ERROR_EDIT TableExpression
+ : 'SELECT' OptionalAllOrDistinct SelectList_ERROR_EDIT TableExpression
    {
-     parser.selectListNoTableSuggest($4, $2);
+     parser.selectListNoTableSuggest($3, $2);
    }
- | 'SELECT' OptionalAllOrDistinct OptionalStraightJoin SelectList_ERROR TableExpression_EDIT
+ | 'SELECT' OptionalAllOrDistinct SelectList_ERROR TableExpression_EDIT
  ;
 
 SelectList_ERROR
@@ -90,47 +90,41 @@ JoinType_EDIT
  ;
 
 OptionalSelectConditions_EDIT
- : WhereClause error 'CURSOR' OptionalGroupByClause OptionalHavingClause OptionalWindowClause OptionalOrderByClause OptionalClusterOrDistributeBy OptionalLimitClause OptionalOffsetClause
+ : WhereClause error 'CURSOR' OptionalGroupByClause OptionalHavingClause OptionalOrderByClause OptionalLimitClause
    {
      $$ = {
-       suggestKeywords: parser.getKeywordsForOptionalsLR([$4, $5, $6, $7, $8, $9, $10], [{ value: 'GROUP BY', weight: 8 }, { value: 'HAVING', weight: 7 }, { value: 'WINDOW', weight: 6 }, { value: 'ORDER BY', weight: 5 }, [{ value: 'CLUSTER BY', weight: 4 }, { value: 'DISTRIBUTE BY', weight: 4 }, { value: 'SORT BY', weight: 4 }], { value: 'LIMIT', weight: 3 }, { value: 'OFFSET', weight: 2 }], [true, true, parser.isHive(), true, parser.isHive(), true, parser.isImpala()]),
-       cursorAtEnd: !$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10
+       suggestKeywords: parser.getKeywordsForOptionalsLR([$4, $5, $6, $7], [{ value: 'GROUP BY', weight: 8 }, { value: 'HAVING', weight: 7 }, { value: 'ORDER BY', weight: 5 }, { value: 'LIMIT', weight: 3 }], [true, true, true, true]),
+       cursorAtEnd: !$4 && !$5 && !$6 && !$7
      };
    }
- | OptionalWhereClause OptionalGroupByClause HavingClause error 'CURSOR' OptionalWindowClause OptionalOrderByClause OptionalClusterOrDistributeBy OptionalLimitClause OptionalOffsetClause
+ | OptionalWhereClause OptionalGroupByClause HavingClause error 'CURSOR' OptionalOrderByClause OptionalLimitClause
    {
      $$ = {
-       suggestKeywords: parser.getKeywordsForOptionalsLR([$6, $7, $8, $9, $10], [{ value: 'WINDOW', weight: 6 }, { value: 'ORDER BY', weight: 5 }, [{ value: 'CLUSTER BY', weight: 4 }, { value: 'DISTRIBUTE BY', weight: 4 }, { value: 'SORT BY', weight: 4 }], { value: 'LIMIT', weight: 3 }, { value: 'OFFSET', weight: 2 }], [parser.isHive(), true, parser.isHive(), true, parser.isImpala()]),
-       cursorAtEnd: !$6 && !$7 && !$8 && !$9 && !$10
+       suggestKeywords: parser.getKeywordsForOptionalsLR([$6, $7], [{ value: 'ORDER BY', weight: 5 }, { value: 'LIMIT', weight: 3 }], [true, true]),
+       cursorAtEnd: !$6 && !$7
      }
    }
- | OptionalWhereClause OptionalGroupByClause OptionalHavingClause OptionalWindowClause OrderByClause error 'CURSOR' OptionalClusterOrDistributeBy OptionalLimitClause OptionalOffsetClause
+ | OptionalWhereClause OptionalGroupByClause OptionalHavingClause OrderByClause error 'CURSOR' OptionalLimitClause
    {
      $$ = {
-       suggestKeywords: parser.getKeywordsForOptionalsLR([$8, $9, $10], [[{ value: 'CLUSTER BY', weight: 4 }, { value: 'DISTRIBUTE BY', weight: 4 }, { value: 'SORT BY', weight: 4 }], { value: 'LIMIT', weight: 3 }, { value: 'OFFSET', weight: 2 }], [parser.isHive(), true, parser.isImpala()]),
-       cursorAtEnd: !$8 && !$9 && !$10
-     }
-   }
- | OptionalWhereClause OptionalGroupByClause OptionalHavingClause OptionalWindowClause OptionalOrderByClause OptionalClusterOrDistributeBy LimitClause error 'CURSOR' OptionalOffsetClause
-   {
-     $$ = {
-       suggestKeywords: parser.getKeywordsForOptionalsLR([$10], [{ value: 'OFFSET', weight: 2 }], [parser.isImpala()]),
-       cursorAtEnd: !$10
+       suggestKeywords: parser.getKeywordsForOptionalsLR([$7], [{ value: 'LIMIT', weight: 3 }], [true]),
+       cursorAtEnd: !$7
      }
    }
+ | OptionalWhereClause OptionalGroupByClause OptionalHavingClause OptionalOrderByClause LimitClause error 'CURSOR'
  ;
 
 OptionalSelectConditions_EDIT
- : WhereClause error GroupByClause_EDIT OptionalHavingClause OptionalWindowClause OptionalOrderByClause OptionalClusterOrDistributeBy OptionalLimitClause OptionalOffsetClause
- | WhereClause error OptionalGroupByClause HavingClause_EDIT OptionalWindowClause OptionalOrderByClause OptionalClusterOrDistributeBy OptionalLimitClause OptionalOffsetClause
- | WhereClause error OptionalGroupByClause OptionalHavingClause OptionalWindowClause OrderByClause_EDIT OptionalClusterOrDistributeBy OptionalLimitClause OptionalOffsetClause
- | WhereClause error OptionalGroupByClause OptionalHavingClause OptionalWindowClause OptionalOrderByClause OptionalClusterOrDistributeBy LimitClause_EDIT OptionalOffsetClause
- | OptionalWhereClause GroupByClause error HavingClause_EDIT OptionalWindowClause OptionalOrderByClause OptionalClusterOrDistributeBy OptionalLimitClause OptionalOffsetClause
- | OptionalWhereClause GroupByClause error OptionalHavingClause OptionalWindowClause OrderByClause_EDIT OptionalClusterOrDistributeBy OptionalLimitClause OptionalOffsetClause
- | OptionalWhereClause GroupByClause error OptionalHavingClause OptionalWindowClause OptionalOrderByClause OptionalClusterOrDistributeBy LimitClause_EDIT OptionalOffsetClause
- | OptionalWhereClause OptionalGroupByClause HavingClause error OptionalWindowClause OrderByClause_EDIT OptionalClusterOrDistributeBy OptionalLimitClause OptionalOffsetClause
- | OptionalWhereClause OptionalGroupByClause HavingClause error OptionalWindowClause OptionalOrderByClause OptionalClusterOrDistributeBy LimitClause_EDIT OptionalOffsetClause
- | OptionalWhereClause OptionalGroupByClause OptionalHavingClause OptionalWindowClause OrderByClause error OptionalClusterOrDistributeBy LimitClause_EDIT OptionalOffsetClause
+ : WhereClause error GroupByClause_EDIT OptionalHavingClause OptionalOrderByClause OptionalLimitClause
+ | WhereClause error OptionalGroupByClause HavingClause_EDIT OptionalOrderByClause OptionalLimitClause
+ | WhereClause error OptionalGroupByClause OptionalHavingClause OrderByClause_EDIT OptionalLimitClause
+ | WhereClause error OptionalGroupByClause OptionalHavingClause OptionalOrderByClause LimitClause_EDIT
+ | OptionalWhereClause GroupByClause error HavingClause_EDIT OptionalOrderByClause OptionalLimitClause
+ | OptionalWhereClause GroupByClause error OptionalHavingClause OrderByClause_EDIT OptionalLimitClause
+ | OptionalWhereClause GroupByClause error OptionalHavingClause OptionalOrderByClause LimitClause_EDIT
+ | OptionalWhereClause OptionalGroupByClause HavingClause error OrderByClause_EDIT OptionalLimitClause
+ | OptionalWhereClause OptionalGroupByClause HavingClause error OptionalOrderByClause LimitClause_EDIT
+ | OptionalWhereClause OptionalGroupByClause OptionalHavingClause OrderByClause error LimitClause_EDIT
  ;
 
 DatabaseDefinition_EDIT

+ 0 - 519
desktop/core/src/desktop/js/parse/jison/generic/sql_grant.jison

@@ -1,519 +0,0 @@
-// Licensed to Cloudera, Inc. under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  Cloudera, Inc. licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-DataDefinition
- : GrantStatement
- | RevokeStatement
- ;
-
-DataDefinition_EDIT
- : GrantStatement_EDIT
- | RevokeStatement_EDIT
- ;
-
-GrantStatement
- : '<hive>GRANT' HivePrivilegeTypeList OptionalOnSpecification 'TO' PrincipalSpecificationList OptionalWithGrantOption
- | '<hive>GRANT' UserOrRoleList 'TO' PrincipalSpecificationList OptionalWithAdminOption
- | '<hive>GRANT' '<hive>ROLE' UserOrRoleList 'TO' PrincipalSpecificationList OptionalWithAdminOption
- | '<impala>GRANT' '<impala>ROLE' RegularOrBacktickedIdentifier 'TO' '<impala>GROUP' RegularOrBacktickedIdentifier
- | '<impala>GRANT' ImpalaPrivilegeType 'ON' ImpalaObjectSpecification 'TO' RegularOrBacktickedIdentifier OptionalWithGrantOption
- | '<impala>GRANT' ImpalaPrivilegeType 'ON' ImpalaObjectSpecification 'TO' '<impala>ROLE' RegularOrBacktickedIdentifier OptionalWithGrantOption
- ;
-
-GrantStatement_EDIT
- : '<hive>GRANT' 'CURSOR'
-   {
-     parser.suggestKeywords(['ALL', 'ALTER', 'CREATE', 'DELETE', 'DROP', 'INDEX', 'INSERT', 'LOCK', 'ROLE', 'SELECT', 'UPDATE']);
-   }
- | '<hive>GRANT' HivePrivilegeTypeList_EDIT OptionalOnSpecification
- | '<hive>GRANT' HivePrivilegeTypeList OnSpecification_EDIT
- | '<hive>GRANT' HivePrivilegeTypeList OptionalOnSpecification 'CURSOR'
-   {
-     if (!$3) {
-       parser.suggestKeywords(['ON', 'TO']);
-     } else {
-       parser.suggestKeywords(['TO']);
-     }
-   }
- | '<hive>GRANT' HivePrivilegeTypeList OptionalOnSpecification 'TO' 'CURSOR'
-   {
-     parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
-   }
- | '<hive>GRANT' HivePrivilegeTypeList OptionalOnSpecification 'TO' PrincipalSpecificationList_EDIT
- | '<hive>GRANT' HivePrivilegeTypeList OptionalOnSpecification 'TO' PrincipalSpecificationList OptionalWithGrantOption 'CURSOR'
-   {
-     if (!$6) {
-       parser.suggestKeywords(['WITH GRANT OPTION']);
-     }
-   }
- | '<hive>GRANT' HivePrivilegeTypeList OptionalOnSpecification 'TO' PrincipalSpecificationList WithGrantOption_EDIT
- | '<hive>GRANT' UserOrRoleList 'CURSOR'
-   {
-     parser.suggestKeywords(['TO']);
-   }
- | '<hive>GRANT' UserOrRoleList 'TO' 'CURSOR'
-   {
-     parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
-   }
- | '<hive>GRANT' UserOrRoleList 'TO' PrincipalSpecificationList_EDIT
- | '<hive>GRANT' UserOrRoleList 'TO' PrincipalSpecificationList OptionalWithAdminOption 'CURSOR'
-   {
-     if (!$5) {
-       parser.suggestKeywords(['WITH ADMIN OPTION']);
-     }
-   }
- | '<hive>GRANT' UserOrRoleList 'TO' PrincipalSpecificationList WithAdminOption_EDIT
- | '<hive>GRANT' '<hive>ROLE' UserOrRoleList 'TO' 'CURSOR'
-   {
-     parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
-   }
- | '<hive>GRANT' '<hive>ROLE' UserOrRoleList 'TO' PrincipalSpecificationList_EDIT
- | '<hive>GRANT' '<hive>ROLE' UserOrRoleList 'TO' PrincipalSpecificationList OptionalWithAdminOption 'CURSOR'
-   {
-     if (!$6) {
-       parser.suggestKeywords(['WITH ADMIN OPTION']);
-     }
-   }
- | '<hive>GRANT' '<hive>ROLE' UserOrRoleList 'TO' PrincipalSpecificationList WithAdminOption_EDIT
- | '<impala>GRANT' 'CURSOR'
-   {
-     parser.suggestKeywords(['ALL', 'ALTER', 'CREATE', 'DROP', 'INSERT', 'REFRESH', 'ROLE', 'SELECT']);
-   }
- | '<impala>GRANT' '<impala>ROLE' RegularOrBacktickedIdentifier 'CURSOR'
-   {
-     parser.suggestKeywords(['TO GROUP']);
-   }
- | '<impala>GRANT' '<impala>ROLE' RegularOrBacktickedIdentifier 'TO' 'CURSOR'
-   {
-     parser.suggestKeywords(['GROUP']);
-   }
- | '<impala>GRANT' ImpalaPrivilegeType_EDIT
- | '<impala>GRANT' ImpalaPrivilegeType 'CURSOR'
-   {
-     if ($2.isCreate) {
-       parser.suggestKeywords(['ON DATABASE', 'ON SERVER']);
-     } else {
-       parser.suggestKeywords(['ON DATABASE', 'ON SERVER', 'ON TABLE', 'ON URI']);
-     }
-   }
- | '<impala>GRANT' ImpalaPrivilegeType 'ON' 'CURSOR'
-   {
-     if ($2.isCreate) {
-        parser.suggestKeywords(['DATABASE', 'SERVER']);
-     } else {
-        parser.suggestKeywords(['DATABASE', 'SERVER', 'TABLE', 'URI']);
-     }
-   }
- | '<impala>GRANT' ImpalaPrivilegeType 'ON' ImpalaObjectSpecification_EDIT
- | '<impala>GRANT' ImpalaPrivilegeType 'ON' ImpalaObjectSpecification 'CURSOR'
-   {
-     parser.suggestKeywords(['TO']);
-   }
- | '<impala>GRANT' ImpalaPrivilegeType 'ON' ImpalaObjectSpecification 'TO' 'CURSOR'
-   {
-     parser.suggestKeywords(['ROLE']);
-   }
- | '<impala>GRANT' ImpalaPrivilegeType 'ON' ImpalaObjectSpecification 'TO' RegularOrBacktickedIdentifier OptionalWithGrantOption 'CURSOR'
-   {
-     if (!$7) {
-       parser.suggestKeywords(['WITH GRANT OPTION']);
-     }
-   }
- | '<impala>GRANT' ImpalaPrivilegeType 'ON' ImpalaObjectSpecification 'TO' RegularOrBacktickedIdentifier WithGrantOption_EDIT
- | '<impala>GRANT' ImpalaPrivilegeType 'ON' ImpalaObjectSpecification 'TO' '<impala>ROLE' RegularOrBacktickedIdentifier OptionalWithGrantOption 'CURSOR'
-   {
-     if (!$8) {
-       parser.suggestKeywords(['WITH GRANT OPTION']);
-     }
-   }
- | '<impala>GRANT' ImpalaPrivilegeType 'ON' ImpalaObjectSpecification 'TO' '<impala>ROLE' RegularOrBacktickedIdentifier WithGrantOption_EDIT
- ;
-
-OptionalOnSpecification
- :
- | 'ON' HiveObjectSpecification
- ;
-
-OnSpecification_EDIT
- : 'ON' 'CURSOR'
-   {
-     parser.suggestKeywords(['DATABASE', 'TABLE']);
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-   }
- | 'ON' HiveObjectSpecification_EDIT
- ;
-
-HiveObjectSpecification
- : 'DATABASE' RegularOrBacktickedIdentifier
- | '<hive>TABLE' SchemaQualifiedTableIdentifier
-   {
-     parser.addTablePrimary($2);
-   }
- | SchemaQualifiedTableIdentifier
-   {
-     parser.addTablePrimary($1);
-   }
- ;
-
-HiveObjectSpecification_EDIT
- : 'DATABASE' 'CURSOR'
-   {
-     parser.suggestDatabases();
-   }
- | '<hive>TABLE' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-   }
- | '<hive>TABLE' SchemaQualifiedTableIdentifier_EDIT
- | SchemaQualifiedTableIdentifier_EDIT
- ;
-
-ImpalaObjectSpecification
- : 'DATABASE' RegularOrBacktickedIdentifier
-   {
-     parser.addDatabaseLocation(@2, [ { name: $2 } ]);
-   }
- | '<impala>TABLE' SchemaQualifiedTableIdentifier
-   {
-     parser.addTablePrimary($2);
-   }
- | '<impala>SERVER' RegularOrBacktickedIdentifier
- | '<impala>URI' RegularOrBacktickedIdentifier
- ;
-
-ImpalaObjectSpecification_EDIT
- : 'DATABASE' 'CURSOR'
-   {
-     parser.suggestDatabases();
-   }
- | '<impala>TABLE' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-   }
- | '<impala>TABLE' SchemaQualifiedTableIdentifier_EDIT
- ;
-
-HivePrivilegeTypeList
- : HivePrivilegeTypeWithOptionalColumn
-   {
-     if ($1.toUpperCase() === 'ALL') {
-       $$ = { singleAll: true };
-     }
-   }
- | HivePrivilegeTypeList ',' HivePrivilegeTypeWithOptionalColumn
- ;
-
-HivePrivilegeTypeList_EDIT
- : HivePrivilegeTypeWithOptionalColumn_EDIT
- | HivePrivilegeTypeList ',' HivePrivilegeTypeWithOptionalColumn_EDIT
- | HivePrivilegeTypeWithOptionalColumn_EDIT ',' HivePrivilegeTypeList
- | HivePrivilegeTypeList ',' HivePrivilegeTypeWithOptionalColumn_EDIT ',' HivePrivilegeTypeList
- | 'CURSOR' ',' HivePrivilegeTypeList
-   {
-     parser.suggestKeywords(['ALL', 'ALTER', 'CREATE', 'DELETE', 'DROP', 'INDEX', 'INSERT', 'LOCK', 'SELECT', 'SHOW_DATABASE', 'UPDATE']);
-   }
- | HivePrivilegeTypeList ',' 'CURSOR'
-   {
-     parser.suggestKeywords(['ALL', 'ALTER', 'CREATE', 'DELETE', 'DROP', 'INDEX', 'INSERT', 'LOCK', 'SELECT', 'SHOW_DATABASE', 'UPDATE']);
-   }
- | HivePrivilegeTypeList ',' 'CURSOR' ',' HivePrivilegeTypeList
-   {
-     parser.suggestKeywords(['ALL', 'ALTER', 'CREATE', 'DELETE', 'DROP', 'INDEX', 'INSERT', 'LOCK', 'SELECT', 'SHOW_DATABASE', 'UPDATE']);
-   }
- ;
-
-HivePrivilegeTypeWithOptionalColumn
- : HivePrivilegeType OptionalParenthesizedColumnList
- ;
-
-HivePrivilegeTypeWithOptionalColumn_EDIT
- : HivePrivilegeType ParenthesizedColumnList_EDIT
- ;
-
-HivePrivilegeType
- : '<hive>INSERT'
- | 'SELECT'
- | 'UPDATE'
- | '<hive>DELETE'
- | 'ALTER'
- | '<hive>CREATE'
- | 'DROP'
- | '<hive>INDEX'
- | '<hive>LOCK'
- | '<hive>SHOW_DATABASE'
- | '<hive>ALL'
- ;
-
-ImpalaPrivilegeType
- : 'ALL'
- | 'ALTER'
- | '<impala>CREATE'  --> { isCreate: true }
- | 'DROP'
- | '<impala>INSERT'
- | '<impala>REFRESH'
- | 'SELECT' OptionalParenthesizedColumnList
- ;
-
-ImpalaPrivilegeType_EDIT
- : 'SELECT' ParenthesizedColumnList_EDIT
- ;
-
-PrincipalSpecificationList
- : PrincipalSpecification
- | PrincipalSpecificationList ',' PrincipalSpecification
- ;
-
-PrincipalSpecificationList_EDIT
- : PrincipalSpecificationList ',' 'CURSOR'
-   {
-     parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
-   }
- | 'CURSOR' ',' PrincipalSpecificationList
-   {
-     parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
-   }
- | PrincipalSpecificationList ',' 'CURSOR' ',' PrincipalSpecificationList
-   {
-     parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
-   }
- ;
-
-PrincipalSpecification
- : '<hive>USER' RegularOrBacktickedIdentifier
- | 'GROUP' RegularOrBacktickedIdentifier
- | '<hive>ROLE' RegularOrBacktickedIdentifier
- ;
-
-PrincipalSpecification_EDIT
- : '<hive>USER' 'CURSOR'
- | 'GROUP' 'CURSOR'
- | '<hive>ROLE' 'CURSOR'
- ;
-
-UserOrRoleList
- : RegularOrBacktickedIdentifier
- | UserOrRoleList ',' RegularOrBacktickedIdentifier
- ;
-
-OptionalWithGrantOption
- :
- | '<hive>WITH' '<hive>GRANT' 'OPTION'
- | '<impala>WITH' '<impala>GRANT' 'OPTION'
- ;
-
-WithGrantOption_EDIT
- : 'WITH' 'CURSOR'
-   {
-     parser.suggestKeywords(['GRANT OPTION']);
-   }
- | '<hive>WITH' '<hive>GRANT' 'CURSOR'
-   {
-     parser.suggestKeywords(['OPTION']);
-   }
- | '<impala>WITH' '<impala>GRANT' 'CURSOR'
-   {
-     parser.suggestKeywords(['OPTION']);
-   }
- ;
-
-OptionalWithAdminOption
- :
- | '<hive>WITH' '<hive>ADMIN' 'OPTION'
- ;
-
-WithAdminOption_EDIT
- : '<hive>WITH' 'CURSOR'
-   {
-     parser.suggestKeywords(['ADMIN OPTION']);
-   }
- | '<hive>WITH' '<hive>ADMIN' 'CURSOR'
-   {
-     parser.suggestKeywords(['OPTION']);
-   }
- ;
-
-RevokeStatement
- : '<hive>REVOKE' HivePrivilegeTypeList OptionalOnSpecification 'FROM' PrincipalSpecificationList
- | '<hive>REVOKE' '<hive>GRANT' 'OPTION' '<hive>FOR' HivePrivilegeTypeList OptionalOnSpecification 'FROM' PrincipalSpecificationList
- | '<hive>REVOKE' UserOrRoleList 'FROM' PrincipalSpecificationList
- | '<hive>REVOKE' '<hive>ROLE' UserOrRoleList 'FROM' PrincipalSpecificationList
- | '<hive>REVOKE' '<hive>ADMIN' 'OPTION' '<hive>FOR' UserOrRoleList 'FROM' PrincipalSpecificationList
- | '<hive>REVOKE' '<hive>ADMIN' 'OPTION' '<hive>FOR' '<hive>ROLE' UserOrRoleList 'FROM' PrincipalSpecificationList
- | '<hive>REVOKE' '<hive>ALL' PrivilegesOrGrantOption 'FROM' UserOrRoleList
- | '<impala>REVOKE' '<impala>ROLE' RegularOrBacktickedIdentifier 'FROM' '<impala>GROUP' RegularOrBacktickedIdentifier
- | '<impala>REVOKE' ImpalaPrivilegeType 'ON' ImpalaObjectSpecification 'FROM' RegularOrBacktickedIdentifier
- | '<impala>REVOKE' ImpalaPrivilegeType 'ON' ImpalaObjectSpecification 'FROM' '<impala>ROLE' RegularOrBacktickedIdentifier
- ;
-
-RevokeStatement_EDIT
- : '<hive>REVOKE' 'CURSOR'
-   {
-     parser.suggestKeywords(['ADMIN OPTION FOR', 'ALL', 'ALL GRANT OPTION FROM', 'ALL PRIVILEGES FROM', 'ALTER', 'CREATE', 'DELETE', 'DROP', 'GRANT OPTION FOR', 'INDEX', 'INSERT', 'LOCK', 'ROLE', 'SELECT', 'UPDATE']);
-   }
- | '<hive>REVOKE' HivePrivilegeTypeList_EDIT
- | '<hive>REVOKE' HivePrivilegeTypeList OnSpecification_EDIT
- | '<hive>REVOKE' HivePrivilegeTypeList OptionalOnSpecification 'CURSOR'
-   {
-     if (!$3) {
-       if ($2.singleAll) {
-         parser.suggestKeywords(['FROM', 'GRANT OPTION', 'ON', 'PRIVILEGES FROM']);
-       } else {
-         parser.suggestKeywords(['FROM', 'ON']);
-       }
-     } else {
-       parser.suggestKeywords(['FROM']);
-     }
-   }
- | '<hive>REVOKE' HivePrivilegeTypeList OptionalOnSpecification 'FROM' 'CURSOR'
-   {
-     parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
-   }
- | '<hive>REVOKE' HivePrivilegeTypeList OptionalOnSpecification 'FROM' PrincipalSpecificationList_EDIT
- | '<hive>REVOKE' '<hive>GRANT' 'CURSOR'
-   {
-     parser.suggestKeywords(['OPTION FOR']);
-   }
- | '<hive>REVOKE' '<hive>GRANT' 'OPTION' 'CURSOR'
-   {
-     parser.suggestKeywords(['FOR']);
-   }
- | '<hive>REVOKE' '<hive>GRANT' 'OPTION' '<hive>FOR' 'CURSOR'
-   {
-     parser.suggestKeywords(['ALL', 'ALTER', 'CREATE', 'DELETE', 'DROP', 'INDEX', 'INSERT', 'LOCK', 'SELECT', 'SHOW_DATABASE', 'UPDATE']);
-   }
- | '<hive>REVOKE' '<hive>GRANT' 'OPTION' '<hive>FOR' HivePrivilegeTypeList_EDIT
- | '<hive>REVOKE' '<hive>GRANT' 'OPTION' '<hive>FOR' HivePrivilegeTypeList OnSpecification_EDIT
- | '<hive>REVOKE' '<hive>GRANT' 'OPTION' '<hive>FOR' HivePrivilegeTypeList OptionalOnSpecification 'CURSOR'
-   {
-     if (!$6) {
-       parser.suggestKeywords(['FROM', 'ON']);
-     } else {
-       parser.suggestKeywords(['FROM']);
-     }
-   }
- | '<hive>REVOKE' '<hive>GRANT' 'OPTION' '<hive>FOR' HivePrivilegeTypeList OptionalOnSpecification 'FROM' 'CURSOR'
-   {
-     parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
-   }
- | '<hive>REVOKE' '<hive>GRANT' 'OPTION' '<hive>FOR' HivePrivilegeTypeList OptionalOnSpecification 'FROM' PrincipalSpecificationList_EDIT
- | '<hive>REVOKE' UserOrRoleList 'CURSOR'
-   {
-     if ($2.toUpperCase() === 'ADMIN') {
-       parser.suggestKeywords(['FROM', 'OPTION FOR']);
-     } else {
-       parser.suggestKeywords(['FROM']);
-     }
-   }
- | '<hive>REVOKE' UserOrRoleList 'FROM' 'CURSOR'
-   {
-     parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
-   }
- | '<hive>REVOKE' UserOrRoleList 'FROM' PrincipalSpecificationList_EDIT
- | '<hive>REVOKE' '<hive>ROLE' UserOrRoleList 'CURSOR'
-   {
-     parser.suggestKeywords(['FROM']);
-   }
- | '<hive>REVOKE' '<hive>ROLE' UserOrRoleList 'FROM' 'CURSOR'
-   {
-     parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
-   }
- | '<hive>REVOKE' '<hive>ROLE' UserOrRoleList 'FROM' PrincipalSpecificationList_EDIT
-
- | '<hive>REVOKE' '<hive>ADMIN' 'OPTION' 'CURSOR'
-   {
-     parser.suggestKeywords(['FOR']);
-   }
- | '<hive>REVOKE' '<hive>ADMIN' 'OPTION' '<hive>FOR' 'CURSOR'
-   {
-     parser.suggestKeywords(['ROLE']);
-   }
- | '<hive>REVOKE' '<hive>ADMIN' 'OPTION' '<hive>FOR' UserOrRoleList 'CURSOR'
-   {
-     parser.suggestKeywords(['FROM']);
-   }
- | '<hive>REVOKE' '<hive>ADMIN' 'OPTION' '<hive>FOR' UserOrRoleList 'FROM' 'CURSOR'
-   {
-     parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
-   }
- | '<hive>REVOKE' '<hive>ADMIN' 'OPTION' '<hive>FOR' UserOrRoleList 'FROM' PrincipalSpecificationList_EDIT
- | '<hive>REVOKE' '<hive>ADMIN' 'OPTION' '<hive>FOR' '<hive>ROLE' UserOrRoleList 'CURSOR'
-   {
-     parser.suggestKeywords(['FROM']);
-   }
- | '<hive>REVOKE' '<hive>ADMIN' 'OPTION' '<hive>FOR' '<hive>ROLE' UserOrRoleList 'FROM' 'CURSOR'
-   {
-     parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
-   }
- | '<hive>REVOKE' '<hive>ADMIN' 'OPTION' '<hive>FOR' '<hive>ROLE' UserOrRoleList 'FROM' PrincipalSpecificationList_EDIT
- | '<hive>REVOKE' '<hive>ALL' PrivilegesOrGrantOption_EDIT
- | '<hive>REVOKE' '<hive>ALL' PrivilegesOrGrantOption 'CURSOR'
-   {
-     parser.suggestKeywords(['FROM']);
-   }
- | '<impala>REVOKE' 'CURSOR'
-   {
-     parser.suggestKeywords(['ALL', 'ALTER', 'CREATE', 'DROP', 'INSERT', 'REFRESH', 'ROLE', 'SELECT']);
-   }
- | '<impala>REVOKE' '<impala>ROLE' RegularOrBacktickedIdentifier 'CURSOR'
-   {
-     parser.suggestKeywords(['FROM GROUP']);
-   }
- | '<impala>REVOKE' '<impala>ROLE' RegularOrBacktickedIdentifier 'FROM' 'CURSOR'
-   {
-     parser.suggestKeywords(['GROUP']);
-   }
- | '<impala>REVOKE' ImpalaPrivilegeType_EDIT
- | '<impala>REVOKE' ImpalaPrivilegeType 'CURSOR'
-   {
-     if ($2.isCreate) {
-       parser.suggestKeywords(['ON DATABASE', 'ON SERVER']);
-     } else {
-       parser.suggestKeywords(['ON DATABASE', 'ON SERVER', 'ON TABLE', 'ON URI']);
-     }
-   }
- | '<impala>REVOKE' ImpalaPrivilegeType 'ON' 'CURSOR'
-   {
-     if ($2.isCreate) {
-       parser.suggestKeywords(['DATABASE', 'SERVER']);
-     } else {
-       parser.suggestKeywords(['DATABASE', 'SERVER', 'TABLE', 'URI']);
-     }
-   }
- | '<impala>REVOKE' ImpalaPrivilegeType 'ON' ImpalaObjectSpecification_EDIT
- | '<impala>REVOKE' ImpalaPrivilegeType 'ON' ImpalaObjectSpecification 'CURSOR'
-   {
-     parser.suggestKeywords(['FROM']);
-   }
- | '<impala>REVOKE' ImpalaPrivilegeType 'ON' ImpalaObjectSpecification 'FROM' 'CURSOR'
-   {
-     parser.suggestKeywords(['ROLE']);
-   }
- ;
-
-PrivilegesOrGrantOption
- : '<hive>PRIVILEGES'
- | '<hive>GRANT' 'OPTION'
- ;
-
-PrivilegesOrGrantOption_EDIT
- : '<hive>GRANT' 'CURSOR'
-   {
-     parser.suggestKeywords(['OPTION']);
-   }
- ;

+ 3 - 676
desktop/core/src/desktop/js/parse/jison/generic/sql_insert.jison

@@ -19,249 +19,15 @@ DataManipulation
  ;
 
 InsertStatement
- : HiveInsertStatement
- | InsertValuesStatement
- | ImpalaInsertOrUpsertStatement
- | CommonTableExpression HiveInsertStatement
- | CommonTableExpression ImpalaInsertOrUpsertStatement
- | HiveMergeStatement
+ : InsertValuesStatement
  ;
 
 DataManipulation_EDIT
- : HiveInsertStatement_EDIT
- | InsertValuesStatement_EDIT
- | ImpalaInsertOrUpsertStatement_EDIT
- | CommonTableExpression HiveInsertStatement_EDIT
-   {
-     parser.addCommonTableExpressions($1);
-   }
- | CommonTableExpression_EDIT HiveInsertStatement
- | CommonTableExpression ImpalaInsertOrUpsertStatement_EDIT
-   {
-     parser.addCommonTableExpressions($1);
-   }
- | CommonTableExpression_EDIT ImpalaInsertOrUpsertStatement
- | HiveMergeStatement_EDIT
- ;
-
-HiveInsertStatement
- : HiveInsertWithoutQuery QuerySpecification
- | FromClause HiveInserts
- | FromClause SelectWithoutTableExpression OptionalSelectConditions
- ;
-
-HiveInsertStatement_EDIT
- : HiveInsertWithoutQuery_EDIT
- | HiveInsertWithoutQuery 'CURSOR'
-   {
-     var keywords = [];
-     if ($1.suggestKeywords) {
-       keywords = parser.createWeightedKeywords($1.suggestKeywords, 2).concat([{ value: 'SELECT', weight: 1}]);
-     } else {
-       keywords = ['SELECT'];
-     }
-     if ($1.addValues) {
-       keywords.push({ weight: 1.1, value: 'VALUES' });
-     }
-     if (keywords.length > 0) {
-       parser.suggestKeywords(keywords);
-     }
-   }
- | HiveInsertWithoutQuery_EDIT QuerySpecification
- | HiveInsertWithoutQuery QuerySpecification_EDIT
- | FromClause HiveInserts_EDIT
-   {
-     if (!$2.keepTables) {
-       delete parser.yy.result.suggestTables;
-       delete parser.yy.result.suggestDatabases;
-     }
-   }
- | FromClause_EDIT
- | FromClause_EDIT HiveInserts
- | FromClause_EDIT SelectWithoutTableExpression OptionalSelectConditions
- | FromClause 'CURSOR'
-   {
-     parser.suggestKeywords(['INSERT INTO', 'INSERT OVERWRITE', 'SELECT']);
-   }
- | FromClause SelectWithoutTableExpression_EDIT OptionalSelectConditions
-   {
-     if ($2.cursorAtEnd) {
-       parser.checkForSelectListKeywords($2);
-       var keywords = parser.yy.result.suggestKeywords || [];
-       if ($3.suggestKeywords) {
-         keywords = keywords.concat($3.suggestKeywords);
-       }
-       if (keywords.length > 0) {
-         parser.suggestKeywords(keywords);
-       }
-     }
-     delete parser.yy.result.suggestTables;
-     delete parser.yy.result.suggestDatabases;
-   }
- | FromClause SelectWithoutTableExpression OptionalSelectConditions_EDIT
-   {
-     if ($3.cursorAtStart) {
-       parser.checkForSelectListKeywords($2.tableExpression);
-     }
-   }
- ;
-
-HiveInsertWithoutQuery
- : '<hive>INSERT' '<hive>OVERWRITE' OptionalHiveTable SchemaQualifiedTableIdentifier OptionalPartitionSpec OptionalIfNotExists
-   {
-     $4.owner = 'insert';
-     parser.addTablePrimary($4);
-     if (!$5 && !$6) {
-       $$ = { suggestKeywords: ['PARTITION'] }
-     } else if (!$6) {
-       $$ = { suggestKeywords: ['IF NOT EXISTS'] }
-     }
-   }
- | '<hive>INSERT' '<hive>OVERWRITE' '<hive>LOCAL' '<hive>DIRECTORY' HdfsPath OptionalInsertRowFormat
-   {
-     if (!$6) {
-       $$ = { suggestKeywords: [{ value: 'ROW FORMAT', weight: 2 }] };
-     }
-   }
- | '<hive>INSERT' '<hive>OVERWRITE_DIRECTORY' HdfsPath OptionalInsertRowFormat
-    {
-      if (!$4) {
-        $$ = { suggestKeywords: [{ value: 'ROW FORMAT', weight: 2 }] };
-      }
-    }
-  | '<hive>INSERT' 'INTO' OptionalHiveTable SchemaQualifiedTableIdentifier OptionalPartitionSpec OptionalParenthesizedColumnList
-   {
-     $4.owner = 'insert';
-     parser.addTablePrimary($4);
-     if (!$5 && !$6) {
-       $$ = { suggestKeywords: ['PARTITION'], addValues: true };
-     } else if (!$6) {
-       $$ = { addValues: true };
-     }
-   }
- ;
-
-HiveInsertWithoutQuery_EDIT
- : '<hive>INSERT' 'CURSOR'
-   {
-     parser.suggestKeywords(['OVERWRITE', 'INTO']);
-   }
- | '<hive>INSERT' '<hive>OVERWRITE' OptionalHiveTable 'CURSOR'
-   {
-     if (!$3) {
-       parser.suggestKeywords(['DIRECTORY', 'LOCAL DIRECTORY', 'TABLE']);
-     }
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-     $$ = { keepTables: true }
-   }
- | '<hive>INSERT' '<hive>OVERWRITE' OptionalHiveTable SchemaQualifiedTableIdentifier_EDIT OptionalPartitionSpec OptionalParenthesizedColumnList
-   {
-     $$ = { keepTables: true }
-   }
- | '<hive>INSERT' '<hive>OVERWRITE' OptionalHiveTable SchemaQualifiedTableIdentifier OptionalPartitionSpec_EDIT OptionalIfNotExists
-   {
-     $4.owner = 'insert';
-     parser.addTablePrimary($4);
-     if (parser.yy.result.suggestColumns) {
-       parser.yy.result.suggestColumns.owner = 'insert';
-     }
-   }
- | '<hive>INSERT' '<hive>OVERWRITE' OptionalHiveTable SchemaQualifiedTableIdentifier OptionalPartitionSpec OptionalIfNotExists_EDIT
-   {
-     $4.owner = 'insert';
-     parser.addTablePrimary($4);
-   }
- | '<hive>INSERT' '<hive>OVERWRITE' '<hive>LOCAL' 'CURSOR'
-   {
-     parser.suggestKeywords(['DIRECTORY']);
-   }
- | '<hive>INSERT' '<hive>OVERWRITE' '<hive>LOCAL' '<hive>DIRECTORY' HdfsPath_EDIT OptionalInsertRowFormat
- | '<hive>INSERT' '<hive>OVERWRITE' '<hive>LOCAL' '<hive>DIRECTORY' HdfsPath OptionalInsertRowFormat_EDIT
- | '<hive>INSERT' '<hive>OVERWRITE_DIRECTORY' HdfsPath_EDIT OptionalInsertRowFormat
- | '<hive>INSERT' '<hive>OVERWRITE_DIRECTORY' HdfsPath OptionalInsertRowFormat_EDIT
- | '<hive>INSERT' 'INTO' OptionalHiveTable 'CURSOR'
-   {
-     if (!$3) {
-       parser.suggestKeywords(['TABLE']);
-     }
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-     $$ = { keepTables: true }
-   }
- | '<hive>INSERT' 'INTO' OptionalHiveTable SchemaQualifiedTableIdentifier_EDIT OptionalPartitionSpec OptionalParenthesizedColumnList
-   {
-     $$ = { keepTables: true }
-   }
- | '<hive>INSERT' 'INTO' OptionalHiveTable SchemaQualifiedTableIdentifier OptionalPartitionSpec_EDIT OptionalParenthesizedColumnList
-   {
-     $4.owner = 'insert';
-     parser.addTablePrimary($4);
-     if (parser.yy.result.suggestColumns) {
-       parser.yy.result.suggestColumns.owner = 'insert';
-     }
-   }
- | '<hive>INSERT' 'INTO' OptionalHiveTable SchemaQualifiedTableIdentifier OptionalPartitionSpec OptionalParenthesizedColumnList_EDIT
-   {
-     $4.owner = 'insert';
-     parser.addTablePrimary($4);
-     if (parser.yy.result.suggestColumns) {
-       parser.yy.result.suggestColumns.owner = 'insert';
-     }
-   }
- ;
-
-HiveInserts
- : HiveInsert
- | HiveInserts HiveInsert
- ;
-
-HiveInserts_EDIT
- : HiveInsert_EDIT
- | HiveInserts HiveInsert_EDIT
- | HiveInsert_EDIT HiveInserts
- | HiveInserts HiveInsert_EDIT HiveInserts
- ;
-
-// TODO: Verify Hive unions in insert
-HiveInsert
- : HiveInsertWithoutQuery SelectWithoutTableExpression OptionalSelectConditions
- ;
-
-HiveInsert_EDIT
- : HiveInsertWithoutQuery_EDIT
- | HiveInsertWithoutQuery_EDIT SelectWithoutTableExpression OptionalSelectConditions
- | HiveInsertWithoutQuery 'CURSOR'
-   {
-     if ($1.suggestKeywords) {
-       parser.suggestKeywords(parser.createWeightedKeywords($1.suggestKeywords, 2).concat([{ value: 'SELECT', weight: 1}]));
-     } else {
-       parser.suggestKeywords(['SELECT']);
-     }
-   }
- | HiveInsertWithoutQuery SelectWithoutTableExpression_EDIT OptionalSelectConditions
-   {
-     if ($2.cursorAtEnd) {
-       parser.checkForSelectListKeywords($2);
-       var keywords = parser.yy.result.suggestKeywords || [];
-       if ($3.suggestKeywords) {
-         keywords = keywords.concat($3.suggestKeywords);
-       }
-       if (keywords.length > 0) {
-         parser.suggestKeywords(keywords);
-       }
-     }
-   }
- | HiveInsertWithoutQuery SelectWithoutTableExpression OptionalSelectConditions_EDIT
+ : InsertValuesStatement_EDIT
  ;
 
 InsertValuesStatement
- : '<hive>INSERT' 'INTO' OptionalHiveTable SchemaQualifiedTableIdentifier OptionalPartitionSpec 'VALUES' InsertValuesList
-   {
-     $4.owner = 'insert';
-     parser.addTablePrimary($4);
-   }
- | 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier 'VALUES' InsertValuesList
+ : 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier 'VALUES' InsertValuesList
    {
      $4.owner = 'insert';
      parser.addTablePrimary($4);
@@ -304,442 +70,3 @@ OptionalTable
  :
  | 'TABLE'
  ;
-
-OptionalInsertRowFormat
- ;
-
-OptionalInsertRowFormat_EDIT
- ;
-
-SelectWithoutTableExpression
- : 'SELECT' OptionalAllOrDistinct OptionalStraightJoin SelectList  -> { selectList: $4 }
- ;
-
-SelectWithoutTableExpression_EDIT
- : 'SELECT' OptionalAllOrDistinct OptionalStraightJoin SelectList 'CURSOR'
-   {
-     $$ = $4;
-     $$.cursorAtEnd = true;
-   }
- | 'SELECT' OptionalAllOrDistinct OptionalStraightJoin SelectList_EDIT
-   {
-     parser.selectListNoTableSuggest($4, $2);
-   }
- | 'SELECT' OptionalAllOrDistinct OptionalStraightJoin 'CURSOR'
-   {
-     var keywords = parser.getSelectListKeywords();
-     if (!$2 || $2 === 'ALL') {
-       parser.suggestAggregateFunctions();
-       parser.suggestAnalyticFunctions();
-     }
-     if (!$3 && !$2) {
-       keywords.push({ value: 'ALL', weight: 2 });
-       keywords.push({ value: 'DISTINCT', weight: 2 });
-     }
-     if (parser.isImpala() && !$3) {
-       keywords.push({ value: 'STRAIGHT_JOIN', weight: 1 });
-     }
-     parser.suggestKeywords(keywords);
-     parser.suggestFunctions();
-     parser.suggestColumns();
-   }
- ;
-
-OptionalHiveTable
- :
- | '<hive>TABLE'
- ;
-
-ImpalaInsertOrUpsertStatement
- : ImpalaInsertOrUpsertStatementWithoutCTE
- ;
-
-ImpalaInsertOrUpsertStatement_EDIT
- : ImpalaInsertOrUpsertStatementWithoutCTE_EDIT
- ;
-
-ImpalaInsertOrUpsertStatementWithoutCTE
- : ImpalaInsertOrUpsertLeftPart OptionalImpalaShuffleOrNoShuffle SelectStatement OptionalUnions
- | ImpalaInsertOrUpsertLeftPart 'VALUES' ImpalaRowValuesLists
- ;
-
-ImpalaInsertOrUpsertStatementWithoutCTE_EDIT
- : ImpalaInsertOrUpsertLeftPart_EDIT
- | ImpalaInsertOrUpsertLeftPart OptionalImpalaShuffleOrNoShuffle 'CURSOR'
-   {
-     var keywords = $1.suggestKeywords && !$2 ? parser.createWeightedKeywords($1.suggestKeywords, 2) : [];
-     if (!$2) {
-       keywords = keywords.concat(['[NOSHUFFLE]', '[SHUFFLE]', 'SELECT', 'VALUES'])
-     } else {
-       keywords = keywords.concat(['SELECT'])
-     }
-     parser.suggestKeywords(keywords);
-   }
- | ImpalaInsertOrUpsertLeftPart_EDIT OptionalImpalaShuffleOrNoShuffle SelectStatement OptionalUnions
- | ImpalaInsertOrUpsertLeftPart OptionalImpalaShuffleOrNoShuffle SelectStatement_EDIT OptionalUnions
- | ImpalaInsertOrUpsertLeftPart OptionalImpalaShuffleOrNoShuffle SelectStatement OptionalUnions_EDIT
- | ImpalaInsertOrUpsertLeftPart_EDIT 'VALUES' ImpalaRowValuesLists
- | ImpalaInsertOrUpsertLeftPart 'VALUES' ImpalaRowValuesLists_EDIT
- ;
-
-ImpalaInsertOrUpsertLeftPart
- : ImpalaUpsertStatementLeftPart
- | ImpalaInsertLeftPart
- ;
-
-ImpalaInsertOrUpsertLeftPart_EDIT
- : ImpalaUpsertStatementLeftPart_EDIT
- | ImpalaInsertLeftPart_EDIT
- ;
-
-ImpalaUpsertStatementLeftPart
- : '<impala>UPSERT' 'INTO' OptionalImpalaTable SchemaQualifiedTableIdentifier OptionalParenthesizedColumnList
-   {
-     $4.owner = 'upsert';
-     parser.addTablePrimary($4);
-   }
- ;
-
-ImpalaUpsertStatementLeftPart_EDIT
- : '<impala>UPSERT' 'CURSOR'
-   {
-     parser.suggestKeywords(['INTO']);
-   }
- | '<impala>UPSERT' 'INTO' OptionalImpalaTable 'CURSOR'
-   {
-     if (!$3) {
-       parser.suggestKeywords(['TABLE']);
-     }
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-   }
- | '<impala>UPSERT' 'INTO' OptionalImpalaTable 'CURSOR' SchemaQualifiedTableIdentifier OptionalParenthesizedColumnList
-   {
-     if (!$3) {
-       parser.suggestKeywords(['TABLE']);
-     }
-     $5.owner = 'upsert';
-     parser.addTablePrimary($5);
-   }
- | '<impala>UPSERT' 'INTO' OptionalImpalaTable SchemaQualifiedTableIdentifier_EDIT OptionalParenthesizedColumnList
- | '<impala>UPSERT' 'INTO' OptionalImpalaTable SchemaQualifiedTableIdentifier OptionalParenthesizedColumnList_EDIT
-   {
-     $4.owner = 'upsert';
-     parser.addTablePrimary($4);
-     if (parser.yy.result.suggestColumns) {
-       parser.yy.result.suggestColumns.owner = 'upsert';
-     }
-   }
- ;
-
-
-ImpalaInsertLeftPart
- : '<impala>INSERT' IntoOrOverwrite OptionalImpalaTable SchemaQualifiedTableIdentifier OptionalParenthesizedColumnList OptionalPartitionSpec
-   {
-     $4.owner = 'insert';
-     parser.addTablePrimary($4);
-     if (!$6) {
-       $$ = { suggestKeywords: ['PARTITION'] };
-     }
-   }
- ;
-
-ImpalaInsertLeftPart_EDIT
- : '<impala>INSERT' 'CURSOR'
-   {
-     parser.suggestKeywords(['INTO', 'OVERWRITE']);
-   }
- | '<impala>INSERT' IntoOrOverwrite OptionalImpalaTable 'CURSOR'
-   {
-     if (!$3) {
-       parser.suggestKeywords(['TABLE']);
-     }
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-   }
- | '<impala>INSERT' IntoOrOverwrite OptionalImpalaTable 'CURSOR' SchemaQualifiedTableIdentifier OptionalParenthesizedColumnList OptionalPartitionSpec
-   {
-     if (!$3) {
-       parser.suggestKeywords(['TABLE']);
-     }
-     $5.owner = 'insert';
-     parser.addTablePrimary($5);
-   }
- | '<impala>INSERT' IntoOrOverwrite OptionalImpalaTable SchemaQualifiedTableIdentifier_EDIT OptionalParenthesizedColumnList OptionalPartitionSpec
- | '<impala>INSERT' IntoOrOverwrite OptionalImpalaTable SchemaQualifiedTableIdentifier OptionalParenthesizedColumnList_EDIT OptionalPartitionSpec
-   {
-     $4.owner = 'insert';
-     parser.addTablePrimary($4);
-     if (parser.yy.result.suggestColumns) {
-       parser.yy.result.suggestColumns.owner = 'insert';
-     }
-   }
- | '<impala>INSERT' IntoOrOverwrite OptionalImpalaTable SchemaQualifiedTableIdentifier OptionalParenthesizedColumnList OptionalPartitionSpec_EDIT
-   {
-     $4.owner = 'insert';
-     parser.addTablePrimary($4);
-     if (parser.yy.result.suggestColumns) {
-       parser.yy.result.suggestColumns.owner = 'insert';
-     }
-   }
- ;
-
-IntoOrOverwrite
- : 'INTO'
- | '<impala>OVERWRITE'
- ;
-
-OptionalImpalaTable
- :
- | '<impala>TABLE'
- ;
-
-OptionalImpalaShuffleOrNoShuffle
- :
- | '<impala>SHUFFLE'
- | '<impala>NOSHUFFLE'
- ;
-
-ImpalaRowValuesLists
- : ParenthesizedImpalaRowValuesList
- | ImpalaRowValuesLists ',' ParenthesizedImpalaRowValuesList
- ;
-
-ImpalaRowValuesLists_EDIT
- : ParenthesizedImpalaRowValuesList_EDIT
- | ImpalaRowValuesLists ',' ParenthesizedImpalaRowValuesList_EDIT
- | ImpalaRowValuesLists ',' ParenthesizedImpalaRowValuesList_EDIT ',' ImpalaRowValuesLists
- | ParenthesizedImpalaRowValuesList_EDIT ',' ImpalaRowValuesLists
- ;
-
-ParenthesizedImpalaRowValuesList
- : '(' ValueExpressionList ')'
- ;
-
-ParenthesizedImpalaRowValuesList_EDIT
- : '(' AnyCursor RightParenthesisOrError
-   {
-     parser.suggestFunctions();
-   }
- | '(' ValueExpressionList_EDIT RightParenthesisOrError
- ;
-
-HiveMergeStatement
- : HiveMergeStatementLeftPart 'ON' ValueExpression WhenList
- ;
-
-HiveMergeStatement_EDIT
- : HiveMergeStatementLeftPart_EDIT
- | HiveMergeStatementLeftPart 'CURSOR'
-   {
-     parser.suggestKeywords(['ON']);
-   }
- | HiveMergeStatementLeftPart 'ON' 'CURSOR'
-   {
-     parser.valueExpressionSuggest();
-   }
- | HiveMergeStatementLeftPart 'ON' ValueExpression_EDIT
- | HiveMergeStatementLeftPart 'ON' ValueExpression 'CURSOR'
-   {
-     parser.suggestValueExpressionKeywords($3, [{ value: 'WHEN', weight: 2 }]);
-   }
- | HiveMergeStatementLeftPart 'ON' ValueExpression WhenList_EDIT
- ;
-
-HiveMergeStatementLeftPart
- : '<hive>MERGE' 'INTO' SchemaQualifiedTableIdentifier '<hive>AS' RegularIdentifier '<hive>USING' MergeSource '<hive>AS' RegularIdentifier
-   {
-     $3.alias = $5;
-     parser.addTablePrimary($3);
-     if ($7.subQuery) {
-       parser.addTablePrimary({ subQueryAlias: $9 });
-     } else {
-       $7.alias = $9;
-     }
-   }
- ;
-
-HiveMergeStatementLeftPart_EDIT
- : '<hive>MERGE' 'CURSOR'
-   {
-     parser.suggestKeywords(['INTO']);
-   }
- | '<hive>MERGE' 'INTO' 'CURSOR'
-   {
-     parser.suggestDatabases({ appendDot: true });
-     parser.suggestTables();
-   }
- | '<hive>MERGE' 'INTO' SchemaQualifiedTableIdentifier_EDIT
- | '<hive>MERGE' 'INTO' SchemaQualifiedTableIdentifier 'CURSOR'
-   {
-     parser.addTablePrimary($3);
-     parser.suggestKeywords(['AS T USING']);
-   }
- | '<hive>MERGE' 'INTO' SchemaQualifiedTableIdentifier '<hive>AS' 'CURSOR'
-   {
-     parser.addTablePrimary($3);
-     parser.suggestKeywords(['T USING']);
-   }
- | '<hive>MERGE' 'INTO' SchemaQualifiedTableIdentifier '<hive>AS' RegularIdentifier 'CURSOR'
-   {
-     $3.alias = $5;
-     parser.addTablePrimary($3);
-     parser.suggestKeywords(['USING']);
-   }
- | '<hive>MERGE' 'INTO' SchemaQualifiedTableIdentifier '<hive>AS' RegularIdentifier '<hive>USING' 'CURSOR'
-   {
-     $3.alias = $5;
-     parser.addTablePrimary($3);
-     parser.suggestDatabases({ appendDot: true });
-     parser.suggestTables();
-   }
- | '<hive>MERGE' 'INTO' SchemaQualifiedTableIdentifier '<hive>AS' RegularIdentifier '<hive>USING' MergeSource_EDIT
-   {
-     $3.alias = $5;
-     parser.addTablePrimary($3);
-   }
- | '<hive>MERGE' 'INTO' SchemaQualifiedTableIdentifier '<hive>AS' RegularIdentifier '<hive>USING' MergeSource 'CURSOR'
-   {
-     $3.alias = $5;
-     parser.addTablePrimary($3);
-     parser.suggestKeywords(['AS S ON']);
-   }
- | '<hive>MERGE' 'INTO' SchemaQualifiedTableIdentifier '<hive>AS' RegularIdentifier '<hive>USING' MergeSource '<hive>AS' 'CURSOR'
-   {
-     $3.alias = $5;
-     parser.addTablePrimary($3);
-     parser.suggestKeywords(['S ON']);
-   }
- ;
-
-MergeSource
- : '(' TableSubQueryInner ')'  --> $2
- | SchemaQualifiedTableIdentifier
-   {
-     parser.addTablePrimary($1);
-   }
- ;
-
-MergeSource_EDIT
- : '(' 'CURSOR' RightParenthesisOrError
-   {
-     parser.suggestKeywords(['SELECT']);
-   }
- | '(' TableSubQueryInner_EDIT RightParenthesisOrError
- | SchemaQualifiedTableIdentifier_EDIT
- ;
-
-WhenList
- : WhenClause
- | WhenClause WhenClause
- | WhenClause WhenClause WhenClause
- ;
-
-WhenList_EDIT
- : WhenClause_EDIT
-   {
-     if ($1.suggestThenKeywords) {
-       parser.suggestKeywords(['DELETE', 'INSERT VALUES', 'UPDATE SET']);
-     }
-   }
- | WhenClause 'CURSOR'
-   {
-     if (!$1.notPresent) {
-       parser.suggestKeywords(['WHEN']);
-     }
-   }
- | WhenClause WhenClause_EDIT
-  {
-     if (!$1.notPresent && $2.suggestThenKeywords) {
-       var keywords = [];
-       if (!$1.isDelete) {
-         keywords.push('DELETE');
-       }
-       if (!$1.isInsert) {
-         keywords.push('INSERT VALUES');
-       }
-       if (!$1.isUpdate) {
-         keywords.push('UPDATE SET');
-       }
-       parser.suggestKeywords(keywords);
-     }
-   }
- | WhenClause WhenClause 'CURSOR'
-   {
-     if (!$2.notPresent) {
-       parser.suggestKeywords(['WHEN']);
-     }
-   }
- | WhenClause WhenClause WhenClause_EDIT
-   {
-     if (!$2.notPresent && $3.suggestThenKeywords) {
-       var keywords = [];
-       if (!$1.isDelete && !$2.isDelete) {
-         keywords.push('DELETE');
-       }
-       if (!$1.isInsert && !$2.isInsert) {
-         keywords.push('INSERT VALUES');
-       }
-       if (!$1.isUpdate && !$2.isUpdate) {
-         keywords.push('UPDATE SET');
-       }
-       parser.suggestKeywords(keywords);
-     }
-   }
- ;
-
-WhenClause
- : 'WHEN' OptionalNot '<hive>MATCHED' OptionalMatchCondition 'THEN' UpdateDeleteOrInsert  --> { notPresent: !!$2, isDelete: $6.isDelete, isInsert: $6.isInsert, isUpdate: $6.isUpdate }
- ;
-
-WhenClause_EDIT
- : 'WHEN' OptionalNot 'CURSOR'
-   {
-     if (!$2) {
-       parser.suggestKeywords(['NOT MATCHED', 'MATCHED']);
-     } else {
-       parser.suggestKeywords(['MATCHED']);
-     }
-   }
- | 'WHEN' OptionalNot '<hive>MATCHED' OptionalMatchCondition 'CURSOR'
-   {
-     if (!$4) {
-       parser.suggestKeywords(['AND', 'THEN']);
-     } else {
-       parser.suggestValueExpressionKeywords($4, [{ value: 'THEN', weight: 2 }]);
-     }
-   }
- | 'WHEN' OptionalNot '<hive>MATCHED' MatchCondition_EDIT
- | 'WHEN' OptionalNot '<hive>MATCHED' OptionalMatchCondition 'THEN' 'CURSOR' --> { suggestThenKeywords: true }
- | 'WHEN' OptionalNot '<hive>MATCHED' OptionalMatchCondition 'THEN' UpdateDeleteOrInsert_EDIT
- ;
-
-OptionalMatchCondition
- :
- | 'AND' ValueExpression --> $2
- ;
-
-MatchCondition_EDIT
- : 'AND' 'CURSOR'
-   {
-     parser.valueExpressionSuggest();
-   }
- ;
-
-UpdateDeleteOrInsert
- : 'UPDATE' 'SET' SetClauseList              --> { isUpdate: true }
- | '<hive>DELETE'                            --> { isDelete: true }
- | '<hive>INSERT' 'VALUES' InsertValuesList  --> { isInsert: true }
- ;
-
-UpdateDeleteOrInsert_EDIT
- : 'UPDATE' 'CURSOR'
-   {
-     parser.suggestKeywords(['SET']);
-   }
- | 'UPDATE' 'SET' SetClauseList_EDIT
- | '<hive>INSERT' 'CURSOR'
-   {
-     parser.suggestKeywords(['VALUES']);
-   }
- ;

+ 0 - 290
desktop/core/src/desktop/js/parse/jison/generic/sql_load.jison

@@ -1,290 +0,0 @@
-// Licensed to Cloudera, Inc. under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  Cloudera, Inc. licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-DataManipulation
- : LoadStatement
- | ImportStatement
- | ExportStatement
- ;
-
-DataManipulation_EDIT
- : LoadStatement_EDIT
- | ImportStatement_EDIT
- | ExportStatement_EDIT
- ;
-
-LoadStatement
- : AnyLoad AnyData OptionalHiveLocal AnyInpath HdfsPath OptionalOverwrite 'INTO' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec
-   {
-     parser.addTablePrimary($9);
-   }
- ;
-
-LoadStatement_EDIT
- : AnyLoad 'CURSOR'
-   {
-     if (parser.isHive()) {
-       parser.suggestKeywords(['DATA LOCAL INPATH', 'DATA INPATH']);
-     } else if (parser.isImpala()) {
-       parser.suggestKeywords(['DATA INPATH']);
-     }
-   }
- | AnyLoad AnyData OptionalHiveLocal 'CURSOR'
-   {
-     if (parser.isHive() && !$3) {
-       parser.suggestKeywords(['INPATH', 'LOCAL INPATH']);
-     } else {
-       parser.suggestKeywords(['INPATH']);
-     }
-   }
- | AnyLoad AnyData OptionalHiveLocal AnyInpath HdfsPath_EDIT OptionalOverwrite
- | AnyLoad AnyData OptionalHiveLocal AnyInpath HdfsPath OptionalOverwrite 'CURSOR'
-   {
-     if (!$6) {
-       parser.suggestKeywords(['OVERWRITE INTO TABLE', 'INTO TABLE']);
-     } else {
-       parser.suggestKeywords(['INTO TABLE']);
-     }
-   }
- | AnyLoad AnyData OptionalHiveLocal AnyInpath HdfsPath OptionalOverwrite 'INTO' 'CURSOR'
-   {
-     parser.suggestKeywords([ 'TABLE' ]);
-   }
- | AnyLoad AnyData OptionalHiveLocal AnyInpath HdfsPath OptionalOverwrite 'INTO' 'TABLE' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-   }
- | AnyLoad AnyData OptionalHiveLocal AnyInpath HdfsPath OptionalOverwrite 'INTO' 'TABLE' SchemaQualifiedTableIdentifier_EDIT OptionalPartitionSpec
- | AnyLoad AnyData OptionalHiveLocal AnyInpath HdfsPath OptionalOverwrite 'INTO' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'CURSOR'
-   {
-     parser.addTablePrimary($9);
-     if (!$10) {
-       parser.suggestKeywords(['PARTITION']);
-     }
-   }
- | AnyLoad AnyData OptionalHiveLocal AnyInpath HdfsPath OptionalOverwrite 'INTO' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec_EDIT
-   {
-     parser.addTablePrimary($9);
-   }
- | AnyLoad AnyData OptionalHiveLocal AnyInpath HdfsPath_EDIT OptionalOverwrite 'INTO' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec
-   {
-     parser.addTablePrimary($9);
-   }
- ;
-
-OptionalOverwrite
- :
- | '<hive>OVERWRITE'
- | '<impala>OVERWRITE'
- ;
-
-OptionalHiveLocal
- :
- | '<hive>LOCAL'
- ;
-
-AnyLoad
- : '<hive>LOAD'
- | '<impala>LOAD'
- ;
-
-AnyData
- : '<hive>DATA'
- | '<impala>DATA'
- ;
-
-AnyInpath
- : '<hive>INPATH'
- | '<impala>INPATH'
- ;
-
-ImportStatement
- : '<hive>IMPORT' OptionalTableWithPartition PushHdfsLexerState 'FROM' HdfsPath OptionalHdfsLocation
- ;
-
-ImportStatement_EDIT
- : '<hive>IMPORT' 'CURSOR' OptionalTableWithPartition
-   {
-     if (!$3) {
-       parser.suggestKeywords(['EXTERNAL TABLE', 'FROM', 'TABLE']);
-     } else if (!$3.hasExternal) {
-       parser.suggestKeywords(['EXTERNAL']);
-     }
-   }
- | '<hive>IMPORT' TableWithPartition 'CURSOR'
-   {
-     if ($2.suggestKeywords) {
-        parser.suggestKeywords(parser.createWeightedKeywords($2.suggestKeywords, 2).concat(['FROM']));
-      } else {
-        parser.suggestKeywords(['FROM']);
-      }
-   }
- | '<hive>IMPORT' TableWithPartition_EDIT
- | '<hive>IMPORT' OptionalTableWithPartition PushHdfsLexerState 'FROM' HdfsPath_EDIT OptionalHdfsLocation
- | '<hive>IMPORT' OptionalTableWithPartition PushHdfsLexerState 'FROM' HdfsPath OptionalHdfsLocation 'CURSOR'
-   {
-     if (!$6) {
-       parser.suggestKeywords(['LOCATION']);
-     }
-   }
- | '<hive>IMPORT' 'CURSOR' OptionalTableWithPartition PushHdfsLexerState 'FROM' HdfsPath OptionalHdfsLocation
-   {
-     if (!$3) {
-       parser.suggestKeywords(['EXTERNAL TABLE', 'TABLE']);
-     } else if (!$3.hasExternal) {
-       parser.suggestKeywords(['EXTERNAL']);
-     }
-   }
-| '<hive>IMPORT' TableWithPartition_EDIT PushHdfsLexerState 'FROM' HdfsPath OptionalHdfsLocation
- | '<hive>IMPORT' TableWithPartition 'CURSOR' PushHdfsLexerState 'FROM' HdfsPath OptionalHdfsLocation
-    {
-      if ($2.suggestKeywords) {
-        parser.suggestKeywords(parser.createWeightedKeywords($2.suggestKeywords, 2).concat(['FROM']));
-      }
-    }
- ;
-
-OptionalTableWithPartition
- :
- | TableWithPartition
- ;
-
-TableWithPartition
- : '<hive>EXTERNAL' '<hive>TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec
-   {
-     parser.addTablePrimary($3);
-     if (!$4) {
-       $$ = { hasExternal: true, suggestKeywords: ['PARTITION'] };
-     } else {
-       $$ = { hasExternal: true }
-     }
-   }
- | '<hive>TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec
-   {
-     parser.addTablePrimary($2);
-     if (!$3) {
-       $$ = { suggestKeywords: ['PARTITION'] };
-     }
-   }
- ;
-
-TableWithPartition_EDIT
- : '<hive>EXTERNAL' 'CURSOR'
-   {
-     parser.suggestKeywords(['TABLE']);
-   }
- | '<hive>EXTERNAL' '<hive>TABLE' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-   }
- | '<hive>EXTERNAL' '<hive>TABLE' SchemaQualifiedTableIdentifier_EDIT OptionalPartitionSpec
- | '<hive>EXTERNAL' '<hive>TABLE' SchemaQualifiedTableIdentifier PartitionSpec_EDIT
-   {
-     parser.addTablePrimary($3);
-   }
- | '<hive>TABLE' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-   }
-
- | '<hive>TABLE' SchemaQualifiedTableIdentifier_EDIT OptionalPartitionSpec
- | '<hive>TABLE' SchemaQualifiedTableIdentifier PartitionSpec_EDIT
-   {
-     parser.addTablePrimary($3);
-   }
- ;
-
-ExportStatement
- : '<hive>EXPORT' '<hive>TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec PushHdfsLexerState 'TO' HdfsPath
-   {
-     parser.addTablePrimary($3);
-   }
- | '<hive>EXPORT' '<hive>TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec PushHdfsLexerState 'TO' HdfsPath '<hive>FOR' '<hive>REPLICATION' '(' QuotedValue ')'
-   {
-     parser.addTablePrimary($3);
-   }
- ;
-
-ExportStatement_EDIT
- : '<hive>EXPORT' 'CURSOR'
-   {
-     parser.suggestKeywords(['TABLE']);
-   }
- | '<hive>EXPORT' '<hive>TABLE' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-   }
- | '<hive>EXPORT' '<hive>TABLE' SchemaQualifiedTableIdentifier_EDIT
- | '<hive>EXPORT' '<hive>TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'CURSOR'
-   {
-     parser.addTablePrimary($3);
-     if (!$4) {
-       parser.suggestKeywords([{ weight: 2, value: 'PARTITION' }, { weight: 1, value: 'TO' }]);
-     } else {
-       parser.suggestKeywords([ 'TO' ]);
-     }
-   }
- | '<hive>EXPORT' '<hive>TABLE' SchemaQualifiedTableIdentifier PartitionSpec_EDIT
-   {
-     parser.addTablePrimary($3);
-   }
- | '<hive>EXPORT' '<hive>TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec PushHdfsLexerState 'TO' HdfsPath_EDIT
-   {
-     parser.addTablePrimary($3);
-   }
- | '<hive>EXPORT' '<hive>TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec PushHdfsLexerState 'TO' HdfsPath 'CURSOR'
-   {
-     parser.addTablePrimary($3);
-     parser.suggestKeywords(['FOR replication()']);
-   }
- | '<hive>EXPORT' '<hive>TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec PushHdfsLexerState 'TO' HdfsPath '<hive>FOR' 'CURSOR'
-   {
-     parser.addTablePrimary($3);
-     parser.suggestKeywords(['replication()']);
-   }
- | '<hive>EXPORT' '<hive>TABLE' SchemaQualifiedTableIdentifier_EDIT OptionalPartitionSpec PushHdfsLexerState 'TO' HdfsPath
- | '<hive>EXPORT' '<hive>TABLE' SchemaQualifiedTableIdentifier_EDIT OptionalPartitionSpec PushHdfsLexerState 'TO' HdfsPath '<hive>FOR' '<hive>REPLICATION' '(' QuotedValue ')'
- | '<hive>EXPORT' '<hive>TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'CURSOR' PushHdfsLexerState 'TO' HdfsPath
-   {
-     parser.addTablePrimary($3);
-     if (!$4) {
-       parser.suggestKeywords(['PARTITION']);
-     }
-   }
- | '<hive>EXPORT' '<hive>TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'CURSOR' PushHdfsLexerState 'TO' HdfsPath '<hive>FOR' '<hive>REPLICATION' '(' QuotedValue ')'
-   {
-     parser.addTablePrimary($3);
-     if (!$4) {
-       parser.suggestKeywords(['PARTITION']);
-     }
-   }
- | '<hive>EXPORT' '<hive>TABLE' SchemaQualifiedTableIdentifier PartitionSpec_EDIT PushHdfsLexerState 'TO' HdfsPath
-   {
-     parser.addTablePrimary($3);
-   }
- | '<hive>EXPORT' '<hive>TABLE' SchemaQualifiedTableIdentifier PartitionSpec_EDIT PushHdfsLexerState 'TO' HdfsPath '<hive>FOR' '<hive>REPLICATION' '(' QuotedValue ')'
-   {
-     parser.addTablePrimary($3);
-   }
- | '<hive>EXPORT' '<hive>TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec PushHdfsLexerState 'TO' HdfsPath_EDIT '<hive>FOR' '<hive>REPLICATION' '(' QuotedValue ')'
-   {
-     parser.addTablePrimary($3);
-   }
- ;

+ 115 - 243
desktop/core/src/desktop/js/parse/jison/generic/sql_main.jison

@@ -73,21 +73,11 @@ SqlStatement
 SqlStatement_EDIT
  : AnyCursor
    {
-     if (parser.isHive()) {
-       parser.suggestDdlAndDmlKeywords(['EXPLAIN', 'FROM']);
-     } else if (parser.isImpala()) {
-       parser.suggestDdlAndDmlKeywords(['EXPLAIN']);
-     } else {
-       parser.suggestDdlAndDmlKeywords();
-     }
+     parser.suggestDdlAndDmlKeywords();
    }
  | CommonTableExpression 'CURSOR'
    {
-     if (parser.isHive() || parser.isImpala()) {
-       parser.suggestKeywords(['INSERT', 'SELECT']);
-     } else {
-       parser.suggestKeywords(['SELECT']);
-     }
+     parser.suggestKeywords(['SELECT']);
    }
  | DataDefinition_EDIT
  | DataManipulation_EDIT
@@ -270,27 +260,6 @@ QuotedValue_EDIT
  | DoubleQuotedValue_EDIT
  ;
 
-OptionalAggregateOrAnalytic
- ;
-
-OptionalHiveExtended
- ;
-
-OptionalHiveExtendedOrFormatted
- ;
-
-OptionalExternal
- ;
-
-OptionalImpalaExtendedOrFormatted
- ;
-
-OptionallyFormattedIndex
- ;
-
-OptionallyFormattedIndex_EDIT
- ;
-
 OptionalFromDatabase
  :
  | FromOrIn DatabaseIdentifier
@@ -506,7 +475,6 @@ SchemaQualifiedTableIdentifier_EDIT
    }
  | RegularOrBacktickedIdentifier '.' PartialBacktickedOrPartialCursor
    {
-     // In Impala you can have statements like 'SELECT ... FROM testTable t, t.|'
      parser.suggestTablesOrColumns($1);
    }
  ;
@@ -554,7 +522,6 @@ PartitionSpecList_EDIT
 
 PartitionExpression
  : ColumnIdentifier '=' ValueExpression
- | ColumnIdentifier // Hive allows partial partition specs in some cases
  ;
 
 PartitionExpression_EDIT
@@ -756,7 +723,6 @@ PartialBacktickedIdentifierOrPartialCursor
  | 'PARTIAL_CURSOR'
  ;
 
-
 PrimitiveType
  : 'BIGINT'
  | 'BOOLEAN'
@@ -812,15 +778,15 @@ QuerySpecification_EDIT
  ;
 
 SelectStatement
- : 'SELECT' OptionalAllOrDistinct OptionalStraightJoin SelectList
+ : 'SELECT' OptionalAllOrDistinct SelectList
    {
-     parser.addClauseLocation('selectList', parser.firstDefined($3, @3, $2, @2, $1, @1), @4);
-     $$ = { selectList: $4 };
+     parser.addClauseLocation('selectList', parser.firstDefined($2, @2, $1, @1), @3);
+     $$ = { selectList: $3 };
    }
- | 'SELECT' OptionalAllOrDistinct OptionalStraightJoin SelectList TableExpression
+ | 'SELECT' OptionalAllOrDistinct SelectList TableExpression
    {
-     parser.addClauseLocation('selectList', parser.firstDefined($3, @3, $2, @2, $1, @1), @4);
-     $$ = { selectList: $4, tableExpression: $5 }
+     parser.addClauseLocation('selectList', parser.firstDefined($2, @2, $1, @1), @3);
+     $$ = { selectList: $3, tableExpression: $4 }
    }
  ;
 
@@ -862,107 +828,98 @@ UnionClause_EDIT
  ;
 
 SelectStatement_EDIT
- : 'SELECT' OptionalAllOrDistinct OptionalStraightJoin SelectList_EDIT
+ : 'SELECT' OptionalAllOrDistinct SelectList_EDIT
    {
-     parser.addClauseLocation('selectList', parser.firstDefined($3, @3, $2, @2, $1, @1), @4);
-     if ($4.cursorAtStart) {
+     parser.addClauseLocation('selectList', parser.firstDefined($2, @2, $1, @1), @3);
+     if ($3.cursorAtStart) {
        var keywords = parser.getSelectListKeywords();
-       if (!$3 && !$2) {
+       if (!$2) {
          keywords.push({ value: 'ALL', weight: 2 });
          keywords.push({ value: 'DISTINCT', weight: 2 });
        }
-       if (parser.isImpala() && !$3) {
-         keywords.push({ value: 'STRAIGHT_JOIN', weight: 1 });
-       }
        parser.suggestKeywords(keywords);
      } else {
        parser.checkForSelectListKeywords($4);
      }
-     if ($4.suggestFunctions) {
+     if ($3.suggestFunctions) {
        parser.suggestFunctions();
      }
-     if ($4.suggestColumns) {
+     if ($3.suggestColumns) {
        parser.suggestColumns({ identifierChain: [], source: 'select' });
      }
-     if ($4.suggestTables) {
+     if ($3.suggestTables) {
        parser.suggestTables({ prependQuestionMark: true, prependFrom: true });
      }
-     if ($4.suggestDatabases) {
+     if ($3.suggestDatabases) {
        parser.suggestDatabases({ prependQuestionMark: true, prependFrom: true, appendDot: true });
      }
-     if ($4.suggestAggregateFunctions && (!$2 || $2 === 'ALL')) {
+     if ($3.suggestAggregateFunctions && (!$2 || $2 === 'ALL')) {
        parser.suggestAggregateFunctions();
        parser.suggestAnalyticFunctions();
      }
    }
- | 'SELECT' OptionalAllOrDistinct OptionalStraightJoin 'CURSOR'
+ | 'SELECT' OptionalAllOrDistinct 'CURSOR'
    {
-     parser.addClauseLocation('selectList', parser.firstDefined($3, @3, $2, @2, $1, @1), @4, true);
+     parser.addClauseLocation('selectList', parser.firstDefined($2, @2, $1, @1), @3, true);
      var keywords = parser.getSelectListKeywords();
      if (!$2 || $2 === 'ALL') {
        parser.suggestAggregateFunctions();
        parser.suggestAnalyticFunctions();
      }
-     if (!$3 && !$2) {
+     if (!$2) {
        keywords.push({ value: 'ALL', weight: 2 });
        keywords.push({ value: 'DISTINCT', weight: 2 });
      }
-     if (parser.isImpala() && !$3) {
-       keywords.push({ value: 'STRAIGHT_JOIN', weight: 1 });
-     }
      parser.suggestKeywords(keywords);
      parser.suggestFunctions();
      parser.suggestColumns({ identifierChain: [], source: 'select' });
      parser.suggestTables({ prependQuestionMark: true, prependFrom: true });
      parser.suggestDatabases({ prependQuestionMark: true, prependFrom: true, appendDot: true });
    }
- | 'SELECT' OptionalAllOrDistinct OptionalStraightJoin SelectList TableExpression_EDIT
+ | 'SELECT' OptionalAllOrDistinct SelectList TableExpression_EDIT
    {
-     parser.addClauseLocation('selectList', parser.firstDefined($3, @3, $2, @2, $1, @1), @4);
+     parser.addClauseLocation('selectList', parser.firstDefined($2, @2, $1, @1), @3);
    }
- | 'SELECT' OptionalAllOrDistinct OptionalStraightJoin SelectList_EDIT TableExpression
+ | 'SELECT' OptionalAllOrDistinct SelectList_EDIT TableExpression
    {
-     parser.addClauseLocation('selectList', parser.firstDefined($3, @3, $2, @2, $1, @1), @4);
-     parser.selectListNoTableSuggest($4, $2);
+     parser.addClauseLocation('selectList', parser.firstDefined($2, @2, $1, @1), @3);
+     parser.selectListNoTableSuggest($3, $2);
      if (parser.yy.result.suggestColumns) {
        parser.yy.result.suggestColumns.source = 'select';
      }
    }
- | 'SELECT' OptionalAllOrDistinct OptionalStraightJoin 'CURSOR' TableExpression
+ | 'SELECT' OptionalAllOrDistinct 'CURSOR' TableExpression
    {
-     parser.addClauseLocation('selectList', parser.firstDefined($3, @3, $2, @2, $1, @1), @4, true);
+     parser.addClauseLocation('selectList', parser.firstDefined($2, @2, $1, @1), @3, true);
      var keywords = parser.getSelectListKeywords();
      if (!$2 || $2 === 'ALL') {
        parser.suggestAggregateFunctions();
        parser.suggestAnalyticFunctions();
      }
-     if (!$3 && !$2) {
+     if (!$2) {
        keywords.push({ value: 'ALL', weight: 2 });
        keywords.push({ value: 'DISTINCT', weight: 2 });
      }
-     if (parser.isImpala() && !$3) {
-       keywords.push({ value: 'STRAIGHT_JOIN', weight: 1 });
-     }
      parser.suggestKeywords(keywords);
      parser.suggestFunctions();
      parser.suggestColumns({ identifierChain: [], source: 'select' });
      parser.suggestTables({ prependQuestionMark: true, prependFrom: true });
      parser.suggestDatabases({ prependQuestionMark: true, prependFrom: true, appendDot: true });
    }
- | 'SELECT' OptionalAllOrDistinct OptionalStraightJoin SelectList 'CURSOR' TableExpression
+ | 'SELECT' OptionalAllOrDistinct SelectList 'CURSOR' TableExpression
    {
-     parser.addClauseLocation('selectList', parser.firstDefined($3, @3, $2, @2, $1, @1), @4);
-     parser.checkForSelectListKeywords($4);
+     parser.addClauseLocation('selectList', parser.firstDefined($2, @2, $1, @1), @3);
+     parser.checkForSelectListKeywords($3);
    }
- | 'SELECT' OptionalAllOrDistinct OptionalStraightJoin SelectList 'CURSOR' ',' TableExpression
+ | 'SELECT' OptionalAllOrDistinct SelectList 'CURSOR' ',' TableExpression
    {
-     parser.addClauseLocation('selectList', parser.firstDefined($3, @3, $2, @2, $1, @1), @4);
-     parser.checkForSelectListKeywords($4);
+     parser.addClauseLocation('selectList', parser.firstDefined($2, @2, $1, @1), @3);
+     parser.checkForSelectListKeywords($3);
    }
- | 'SELECT' OptionalAllOrDistinct OptionalStraightJoin SelectList 'CURSOR'
+ | 'SELECT' OptionalAllOrDistinct SelectList 'CURSOR'
    {
-     parser.addClauseLocation('selectList', parser.firstDefined($3, @3, $2, @2, $1, @1), @4);
-     parser.checkForSelectListKeywords($4);
+     parser.addClauseLocation('selectList', parser.firstDefined($2, @2, $1, @1), @3);
+     parser.checkForSelectListKeywords($3);
      var keywords = ['FROM'];
      if (parser.yy.result.suggestKeywords) {
        keywords = parser.yy.result.suggestKeywords.concat(keywords);
@@ -1050,9 +1007,6 @@ TableExpression_EDIT
      if ($1) {
        if (!$1.hasLateralViews && typeof $1.tableReferenceList.hasJoinCondition !== 'undefined' && !$1.tableReferenceList.hasJoinCondition) {
          keywords.push({ value: 'ON', weight: 3 });
-         if (parser.isImpala()) {
-           keywords.push({ value: 'USING', weight: 3 });
-         }
        }
        if ($1.suggestKeywords) {
          keywords = parser.createWeightedKeywords($1.suggestKeywords, 3);
@@ -1085,14 +1039,7 @@ TableExpression_EDIT
      }
 
      if ($3.empty && $4 && $4.joinType.toUpperCase() === 'JOIN') {
-       keywords = keywords.concat(['FULL', 'FULL OUTER', 'LEFT', 'LEFT OUTER', 'RIGHT', 'RIGHT OUTER']);
-       if (parser.isHive()) {
-         keywords = keywords.concat(['CROSS', 'INNER', 'LEFT SEMI']);
-       } else if (parser.isImpala()) {
-         keywords = keywords.concat(['ANTI', 'CROSS', 'INNER', 'LEFT ANTI', 'LEFT INNER', 'LEFT SEMI', 'OUTER', 'RIGHT ANTI', 'RIGHT INNER', 'RIGHT SEMI', 'SEMI']);
-       } else {
-         keywords.push('INNER');
-       }
+       keywords = keywords.concat(['FULL', 'FULL OUTER', 'INNER', 'LEFT', 'LEFT OUTER', 'RIGHT', 'RIGHT OUTER']);
        parser.suggestKeywords(keywords);
        return;
      }
@@ -1118,34 +1065,13 @@ TableExpression_EDIT
      keywords = keywords.concat([
        { value: 'FULL JOIN', weight: 1 },
        { value: 'FULL OUTER JOIN', weight: 1 },
+       { value: 'INNER 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 (parser.isHive()) {
-       keywords = keywords.concat([
-         { value: 'CROSS JOIN', weight: 1 },
-         { value: 'INNER JOIN', weight: 1 },
-         { value: 'LEFT SEMI JOIN', weight: 1 }
-       ]);
-     } else if (parser.isImpala()) {
-       keywords = keywords.concat([
-         { value: 'ANTI JOIN', weight: 1 },
-         { value: 'INNER JOIN', weight: 1 },
-         { value: 'LEFT ANTI JOIN', weight: 1 },
-         { value: 'LEFT INNER JOIN', weight: 1 },
-         { value: 'LEFT SEMI JOIN', weight: 1 },
-         { value: 'OUTER JOIN', weight: 1 },
-         { value: 'RIGHT ANTI JOIN', weight: 1 },
-         { value: 'RIGHT INNER JOIN', weight: 1 },
-         { value: 'RIGHT SEMI JOIN', weight: 1 },
-         { value: 'SEMI JOIN', weight: 1 }
-       ]);
-     } else {
-       keywords.push({ value: 'INNER JOIN', weight: 1 });
-     }
      parser.suggestKeywords(keywords);
   }
  | FromClause OptionalSelectConditions_EDIT OptionalJoins
@@ -1205,89 +1131,89 @@ FromClause_EDIT
  ;
 
 OptionalSelectConditions
- : OptionalWhereClause OptionalGroupByClause OptionalHavingClause OptionalWindowClause OptionalOrderByClause OptionalClusterOrDistributeBy OptionalLimitClause OptionalOffsetClause
+ : OptionalWhereClause OptionalGroupByClause OptionalHavingClause OptionalOrderByClause OptionalLimitClause
    {
      var keywords = parser.getKeywordsForOptionalsLR(
-       [$1, $2, $3, $4, $5, $6, $6, $7, $8],
-       [{ value: 'WHERE', weight: 9 }, { value: 'GROUP BY', weight: 8 }, { value: 'HAVING', weight: 7 }, { value: 'WINDOW', weight: 6 }, { value: 'ORDER BY', weight: 5 }, [{ value: 'CLUSTER BY', weight: 4 }, { value: 'DISTRIBUTE BY', weight: 4 }], { value: 'SORT BY', weight: 4 }, { value: 'LIMIT', weight: 3 }, { value: 'OFFSET', weight: 2 }],
-       [true, true, true, parser.isHive(), true, parser.isHive(), parser.isHive() && !$5, true, parser.isImpala()]);
+       [$1, $2, $3, $4, $5],
+       [{ value: 'WHERE', weight: 7 }, { value: 'GROUP BY', weight: 6 }, { value: 'HAVING', weight: 5 }, { value: 'ORDER BY', weight: 4 }, { value: 'LIMIT', weight: 3 }],
+       [true, true, true, true, true]);
 
      if (keywords.length > 0) {
-       $$ = { suggestKeywords: keywords, empty: !$1 && !$2 && !$3 && !$4 && !$5 && !$6 && !$7 && !$8 };
+       $$ = { suggestKeywords: keywords, empty: !$1 && !$2 && !$3 && !$4 && !$5 };
      } else {
        $$ = {};
      }
 
      $$.whereClauseLocation = $1 ? @1 : undefined;
-     $$.limitClausePreceding = parser.firstDefined($6, @6, $5, @5, $4, @4, $3, @3, $2, @2, $1, @1);
-     $$.limitClauseLocation = $7 ? @7 : undefined;
+     $$.limitClausePreceding = parser.firstDefined($4, @4, $3, @3, $2, @2, $1, @1);
+     $$.limitClauseLocation = $5 ? @5 : undefined;
 
-     if (!$1 && !$2 && !$3 && !$4 && !$5 && !$6 && !$7 && !$8) {
+     if (!$1 && !$2 && !$3 && !$4 && !$5) {
        $$.suggestFilters = { prefix: 'WHERE', tablePrimaries: parser.yy.latestTablePrimaries.concat() };
      }
-     if (!$2 && !$3 && !$4 && !$5 && !$6 && !$7 && !$8) {
+     if (!$2 && !$3 && !$4 && !$5) {
        $$.suggestGroupBys = { prefix: 'GROUP BY', tablePrimaries: parser.yy.latestTablePrimaries.concat() };
      }
-     if (!$5 && !$6 && !$7 && !$8) {
+     if (!$4 && !$5) {
        $$.suggestOrderBys = { prefix: 'ORDER BY', tablePrimaries: parser.yy.latestTablePrimaries.concat() };
      }
    }
  ;
 
 OptionalSelectConditions_EDIT
- : WhereClause_EDIT OptionalGroupByClause OptionalHavingClause OptionalWindowClause OptionalOrderByClause OptionalClusterOrDistributeBy OptionalLimitClause OptionalOffsetClause
+ : WhereClause_EDIT OptionalGroupByClause OptionalHavingClause OptionalOrderByClause OptionalLimitClause
    {
      if (parser.yy.result.suggestColumns) {
        parser.yy.result.suggestColumns.source = 'where';
      }
    }
- | OptionalWhereClause GroupByClause_EDIT OptionalHavingClause OptionalWindowClause OptionalOrderByClause OptionalClusterOrDistributeBy OptionalLimitClause OptionalOffsetClause
+ | OptionalWhereClause GroupByClause_EDIT OptionalHavingClause OptionalOrderByClause OptionalLimitClause
    {
      if (parser.yy.result.suggestColumns) {
        parser.yy.result.suggestColumns.source = 'group by';
      }
    }
- | OptionalWhereClause OptionalGroupByClause HavingClause_EDIT OptionalWindowClause OptionalOrderByClause OptionalClusterOrDistributeBy OptionalLimitClause OptionalOffsetClause
- | OptionalWhereClause OptionalGroupByClause OptionalHavingClause OptionalWindowClause OrderByClause_EDIT OptionalClusterOrDistributeBy OptionalLimitClause OptionalOffsetClause
+ | OptionalWhereClause OptionalGroupByClause HavingClause_EDIT OptionalOrderByClause OptionalLimitClause
+ | OptionalWhereClause OptionalGroupByClause OptionalHavingClause OrderByClause_EDIT OptionalLimitClause
    {
      if (parser.yy.result.suggestColumns) {
        parser.yy.result.suggestColumns.source = 'order by';
      }
    }
- | OptionalWhereClause OptionalGroupByClause OptionalHavingClause OptionalWindowClause OptionalOrderByClause OptionalClusterOrDistributeBy LimitClause_EDIT OptionalOffsetClause
+ | OptionalWhereClause OptionalGroupByClause OptionalHavingClause OptionalOrderByClause LimitClause_EDIT
  ;
 
 OptionalSelectConditions_EDIT
- : WhereClause 'CURSOR' OptionalGroupByClause OptionalHavingClause OptionalWindowClause OptionalOrderByClause OptionalClusterOrDistributeBy OptionalLimitClause OptionalOffsetClause
+ : WhereClause 'CURSOR' OptionalGroupByClause OptionalHavingClause OptionalOrderByClause OptionalLimitClause
    {
      var keywords = parser.getKeywordsForOptionalsLR(
-       [$3, $4, $5, $6, $7, $7, $8, $9],
-       [{ value: 'GROUP BY', weight: 8 }, { value: 'HAVING', weight: 7 }, { value: 'WINDOW', weight: 6 }, { value: 'ORDER BY', weight: 5 }, [{ value: 'CLUSTER BY', weight: 4 }, { value: 'DISTRIBUTE BY', weight: 4 }], { value: 'SORT BY', weight: 4 }, { value: 'LIMIT', weight: 3 }, { value: 'OFFSET', weight: 2 }],
-       [true, true, parser.isHive(), true, parser.isHive(), parser.isHive() && !$6, true, parser.isImpala()]);
+       [$3, $4, $5, $6],
+       [{ value: 'GROUP BY', weight: 8 }, { value: 'HAVING', weight: 7 }, { value: 'ORDER BY', weight: 5 }, { value: 'LIMIT', weight: 3 }],
+       [true, true, true, true]);
      if ($1.suggestKeywords) {
        keywords = keywords.concat(parser.createWeightedKeywords($1.suggestKeywords, 1));
      }
      $$ = parser.getValueExpressionKeywords($1, keywords);
-     $$.cursorAtEnd = !$3 && !$4 && !$5 && !$6 && !$7 && !$8 && !$9;
+     $$.cursorAtEnd = !$3 && !$4 && !$5 && !$6;
      if ($1.columnReference) {
        $$.columnReference = $1.columnReference;
      }
      if (!$3) {
        parser.suggestGroupBys({ prefix: 'GROUP BY', tablePrimaries: parser.yy.latestTablePrimaries.concat() });
      }
-     if (!$3 && !$4 && !$5 && !$6) {
+     if (!$3 && !$4 && !$5) {
        parser.suggestOrderBys({ prefix: 'ORDER BY', tablePrimaries: parser.yy.latestTablePrimaries.concat() });
      }
      $$.whereClauseLocation = $1 ? @1 : undefined;
-     $$.limitClausePreceding = parser.firstDefined($7, @7, $6, @6, $5, @5, $4, @4, $3, @3, $1, @1);
-     $$.limitClauseLocation = $8 ? @8 : undefined;
+     $$.limitClausePreceding = parser.firstDefined($5, @5, $4, @4, $3, @3, $1, @1);
+     $$.limitClauseLocation = $6 ? @6 : undefined;
    }
- | OptionalWhereClause GroupByClause 'CURSOR' OptionalHavingClause OptionalWindowClause OptionalOrderByClause OptionalClusterOrDistributeBy OptionalLimitClause OptionalOffsetClause
+ | OptionalWhereClause GroupByClause 'CURSOR' OptionalHavingClause OptionalOrderByClause OptionalLimitClause
    {
      var keywords = parser.getKeywordsForOptionalsLR(
-       [$4, $5, $6, $7, $7, $8, $9],
-       [{ value: 'HAVING', weight: 7 }, { value: 'WINDOW', weight: 6 }, { value: 'ORDER BY', weight: 5 }, [{ value: 'CLUSTER BY', weight: 4 }, { value: 'DISTRIBUTE BY', weight: 4 }], { value: 'SORT BY', weight: 4 }, { value: 'LIMIT', weight: 3 }, { value: 'OFFSET', weight: 2 }],
-       [true, parser.isHive(), true, parser.isHive(), parser.isHive() && !$6, true, parser.isImpala()]);
+       [$4, $5, $6],
+       [{ value: 'HAVING', weight: 7 }, { value: 'ORDER BY', weight: 5 }, { value: 'LIMIT', weight: 3 }],
+       [true, true, true]);
      if ($2.suggestKeywords) {
        keywords = keywords.concat(parser.createWeightedKeywords($2.suggestKeywords, 8));
      }
@@ -1299,46 +1225,48 @@ OptionalSelectConditions_EDIT
      } else {
        $$ = { suggestKeywords: keywords };
      }
-     $$.cursorAtEnd = !$4 && !$5 && !$6 && !$7 && !$8 && !$9;
-     if (!$4 && !$5 && !$6) {
+     $$.cursorAtEnd = !$4 && !$5 && !$6;
+     if (!$4 && !$5) {
        parser.suggestOrderBys({ prefix: 'ORDER BY', tablePrimaries: parser.yy.latestTablePrimaries.concat() });
      }
      $$.whereClauseLocation = $1 ? @1 : undefined;
-     $$.limitClausePreceding = parser.firstDefined($7, @7, $6, @6, $5, @5, $4, @4, $2, @2);
-     $$.limitClauseLocation = $8 ? @8 : undefined;
+     $$.limitClausePreceding = parser.firstDefined($5, @5, $4, @4, $2, @2);
+     $$.limitClauseLocation = $6 ? @6 : undefined;
    }
- | OptionalWhereClause OptionalGroupByClause HavingClause 'CURSOR' OptionalWindowClause OptionalOrderByClause OptionalClusterOrDistributeBy OptionalLimitClause OptionalOffsetClause
+ | OptionalWhereClause OptionalGroupByClause HavingClause 'CURSOR' OptionalOrderByClause OptionalLimitClause
    {
      var keywords = parser.getKeywordsForOptionalsLR(
-       [$5, $6, $7, $7, $8, $9],
-       [{ value: 'WINDOW', weight: 6 }, { value: 'ORDER BY', weight: 5 }, [{ value: 'CLUSTER BY', weight: 4 }, { value: 'DISTRIBUTE BY', weight: 4 }], { value: 'SORT BY', weight: 4 }, { value: 'LIMIT', weight: 3 }, { value: 'OFFSET', weight: 2 }],
-       [parser.isHive(), true, parser.isHive(), parser.isHive() && !$6, true, parser.isImpala()]);
-     $$ = { suggestKeywords: keywords, cursorAtEnd: !$5 && !$6 && !$7 && !$8 && !$9 };
-     if (!$5 && !$6) {
+       [$5, $6],
+       [{ value: 'ORDER BY', weight: 5 }, { value: 'LIMIT', weight: 3 }],
+       [true, true]);
+     $$ = { suggestKeywords: keywords, cursorAtEnd: !$5 && !$6 };
+     if (!$5) {
        parser.suggestOrderBys({ prefix: 'ORDER BY', tablePrimaries: parser.yy.latestTablePrimaries.concat() });
      }
      $$.whereClauseLocation = $1 ? @1 : undefined;
-     $$.limitClausePreceding = parser.firstDefined($7, @7, $6, @6, $5, @5, $3, @3);
-     $$.limitClauseLocation = $8 ? @8 : undefined;
+     $$.limitClausePreceding = parser.firstDefined($5, @5, $3, @3);
+     $$.limitClauseLocation = $6 ? @6 : undefined;
    }
- | OptionalWhereClause OptionalGroupByClause OptionalHavingClause OptionalWindowClause OrderByClause 'CURSOR' OptionalClusterOrDistributeBy OptionalLimitClause OptionalOffsetClause
+ | OptionalWhereClause OptionalGroupByClause OptionalHavingClause OrderByClause 'CURSOR' OptionalLimitClause
    {
-     var keywords = parser.getKeywordsForOptionalsLR([$7, $8, $9], [[{ value: 'CLUSTER BY', weight: 4 }, { value: 'DISTRIBUTE BY', weight: 4 }], { value: 'LIMIT', weight: 3 }, { value: 'OFFSET', weight: 2 }], [parser.isHive(), true, parser.isImpala()]);
-     if ($5.suggestKeywords) {
-       keywords = keywords.concat(parser.createWeightedKeywords($5.suggestKeywords, 5));
+     var keywords = parser.getKeywordsForOptionalsLR(
+       [$6],
+       [{ value: 'LIMIT', weight: 3 }],
+       [true]);
+     if ($4.suggestKeywords) {
+       keywords = keywords.concat(parser.createWeightedKeywords($4.suggestKeywords, 4));
      }
-     $$ = { suggestKeywords: keywords, cursorAtEnd: !$7 && !$8 && !$9 };
+     $$ = { suggestKeywords: keywords, cursorAtEnd: !$6 };
      $$.whereClauseLocation = $1 ? @1 : undefined;
-     $$.limitClausePreceding = parser.firstDefined($7, @7, $5, @5);
-     $$.limitClauseLocation = $8 ? @8 : undefined;
+     $$.limitClausePreceding = parser.firstDefined($4, @4);
+     $$.limitClauseLocation = $6 ? @6 : undefined;
    }
- | OptionalWhereClause OptionalGroupByClause OptionalHavingClause OptionalWindowClause OptionalOrderByClause OptionalClusterOrDistributeBy LimitClause 'CURSOR' OptionalOffsetClause
+ | OptionalWhereClause OptionalGroupByClause OptionalHavingClause OptionalOrderByClause LimitClause 'CURSOR'
    {
-     var keywords = parser.getKeywordsForOptionalsLR([$9], [{ value: 'OFFSET', weight: 2 }], [parser.isImpala()]);
-     $$ = { suggestKeywords: keywords, cursorAtEnd: !$9 };
+     $$ = { suggestKeywords: [], true };
      $$.whereClauseLocation = $1 ? @1 : undefined;
-     $$.limitClausePreceding = parser.firstDefined($6, @6, $5, @5, $4, @4, $3, @3, $2, @2, $1, @1);
-     $$.limitClauseLocation = $7 ? @7 : undefined;
+     $$.limitClausePreceding = parser.firstDefined($4, @4, $3, @3, $2, @2, $1, @1);
+     $$.limitClauseLocation = @5;
    }
  ;
 
@@ -1557,11 +1485,7 @@ ValueExpression_EDIT
 ValueExpression_EDIT
  : ValueExpression 'NOT' 'CURSOR'
    {
-     if (parser.isImpala()) {
-       parser.suggestKeywords(['BETWEEN', 'EXISTS', 'IN', 'ILIKE', 'IREGEXP', 'LIKE', 'REGEXP', 'RLIKE']);
-     } else {
-       parser.suggestKeywords(['BETWEEN', 'EXISTS', 'IN', 'LIKE', 'REGEXP', 'RLIKE']);
-     }
+     parser.suggestKeywords(['BETWEEN', 'EXISTS', 'IN', 'LIKE', 'REGEXP', 'RLIKE']);
      $$ = { types: [ 'BOOLEAN' ] };
    }
  ;
@@ -1980,36 +1904,36 @@ JoinedTable_EDIT
  ;
 
 Joins
- : JoinType OptionalImpalaBroadcastOrShuffle TablePrimary OptionalJoinCondition
+ : JoinType TablePrimary OptionalJoinCondition
    {
-     if ($4 && $4.valueExpression) {
-       $$ = $4.valueExpression;
+     if ($3 && $3.valueExpression) {
+       $$ = $3.valueExpression;
      } else {
        $$ = {};
      }
      $$.joinType = $1;
-     if ($4.noJoinCondition) {
+     if ($3.noJoinCondition) {
        $$.suggestJoinConditions = { prependOn: true, tablePrimaries: parser.yy.latestTablePrimaries.concat() }
      }
-     if ($4.suggestKeywords) {
+     if ($3.suggestKeywords) {
        $$.suggestKeywords = $4.suggestKeywords;
      }
      if (parser.yy.latestTablePrimaries.length > 0) {
         parser.yy.latestTablePrimaries[parser.yy.latestTablePrimaries.length - 1].join = true;
      }
    }
- | Joins JoinType OptionalImpalaBroadcastOrShuffle TablePrimary OptionalJoinCondition
+ | Joins JoinType TablePrimary OptionalJoinCondition
    {
-     if ($5 && $5.valueExpression) {
-       $$ = $5.valueExpression;
+     if ($4 && $4.valueExpression) {
+       $$ = $4.valueExpression;
      } else {
        $$ = {};
      }
      $$.joinType = $1;
-     if ($5.noJoinCondition) {
+     if ($4.noJoinCondition) {
        $$.suggestJoinConditions = { prependOn: true, tablePrimaries: parser.yy.latestTablePrimaries.concat() }
      }
-     if ($5.suggestKeywords) {
+     if ($4.suggestKeywords) {
        $$.suggestKeywords = $5.suggestKeywords;
      }
      if (parser.yy.latestTablePrimaries.length > 0) {
@@ -2019,31 +1943,28 @@ Joins
  ;
 
 Joins_INVALID
- : JoinType OptionalImpalaBroadcastOrShuffle                                           -> { joinType: $1 }
- | JoinType OptionalImpalaBroadcastOrShuffle Joins                                     -> { joinType: $1 }
+ : JoinType                                           -> { joinType: $1 }
+ | JoinType Joins                                     -> { joinType: $1 }
  ;
 
 Join_EDIT
- : JoinType_EDIT OptionalImpalaBroadcastOrShuffle TablePrimary OptionalJoinCondition
+ : JoinType_EDIT TablePrimary OptionalJoinCondition
    {
      if ($1.suggestKeywords) {
        parser.suggestKeywords($1.suggestKeywords);
      }
    }
- | JoinType_EDIT OptionalImpalaBroadcastOrShuffle
+ | JoinType_EDIT
    {
      if ($1.suggestKeywords) {
        parser.suggestKeywords($1.suggestKeywords);
      }
    }
- | JoinType OptionalImpalaBroadcastOrShuffle TablePrimary_EDIT OptionalJoinCondition
- | JoinType OptionalImpalaBroadcastOrShuffle TablePrimary JoinCondition_EDIT
- | JoinType OptionalImpalaBroadcastOrShuffle 'CURSOR' OptionalJoinCondition
+ | JoinType TablePrimary_EDIT OptionalJoinCondition
+ | JoinType TablePrimary JoinCondition_EDIT
+ | JoinType 'CURSOR' OptionalJoinCondition
    {
-     if (!$2 && parser.isImpala()) {
-       parser.suggestKeywords(['[BROADCAST]', '[SHUFFLE]']);
-     }
-     if (!$2 && parser.yy.latestTablePrimaries.length > 0) {
+     if (parser.yy.latestTablePrimaries.length > 0) {
        var idx = parser.yy.latestTablePrimaries.length - 1;
        var tables = [];
        do {
@@ -2099,12 +2020,12 @@ JoinType_EDIT
  | 'FULL' 'CURSOR' 'JOIN'           -> { suggestKeywords: ['OUTER'] }
  | 'FULL' 'OUTER' 'CURSOR'          -> { suggestKeywords: ['JOIN'] }
  | 'INNER' 'CURSOR'                 -> { suggestKeywords: ['JOIN'] }
- | 'LEFT' 'CURSOR' 'JOIN'           -> { suggestKeywords: parser.isImpala() ? ['ANTI', 'INNER', 'OUTER', 'SEMI'] : parser.isHive() ? ['OUTER', 'SEMI'] : ['OUTER'] }
+ | 'LEFT' 'CURSOR' 'JOIN'           -> { suggestKeywords: ['OUTER'] }
  | 'LEFT' 'INNER' 'CURSOR'          -> { suggestKeywords: ['JOIN'] }
  | 'LEFT' 'OUTER' 'CURSOR'          -> { suggestKeywords: ['JOIN'] }
  | 'LEFT' 'SEMI' 'CURSOR'           -> { suggestKeywords: ['JOIN'] }
  | 'OUTER' 'CURSOR'                 -> { suggestKeywords: ['JOIN'] }
- | 'RIGHT' 'CURSOR' 'JOIN'          -> { suggestKeywords: parser.isImpala() ? ['ANTI', 'INNER', 'OUTER', 'SEMI'] : ['OUTER'] }
+ | 'RIGHT' 'CURSOR' 'JOIN'          -> { suggestKeywords: ['OUTER'] }
  | 'RIGHT' 'INNER' 'CURSOR'         -> { suggestKeywords: ['JOIN'] }
  | 'RIGHT' 'OUTER' 'CURSOR'         -> { suggestKeywords: ['JOIN'] }
  | 'RIGHT' 'SEMI' 'CURSOR'          -> { suggestKeywords: ['JOIN'] }
@@ -2112,7 +2033,7 @@ JoinType_EDIT
  ;
 
 OptionalJoinCondition
- :                                       -> { noJoinCondition: true, suggestKeywords: parser.isImpala() ? ['ON', 'USING'] : ['ON'] }
+ :                                       -> { noJoinCondition: true, ['ON'] }
  | 'ON' ValueExpression                  -> { valueExpression: $2 }
  ;
 
@@ -2583,7 +2504,7 @@ WindowSpec
 WindowSpec_EDIT
  : RowsOrRange 'CURSOR'
    {
-     parser.suggestKeywords(parser.isHive() ? ['BETWEEN', 'UNBOUNDED'] : ['BETWEEN']);
+     parser.suggestKeywords(['BETWEEN']);
    }
  | RowsOrRange 'BETWEEN' PopLexerState OptionalCurrentOrPreceding OptionalAndFollowing 'CURSOR'
    {
@@ -2596,11 +2517,6 @@ WindowSpec_EDIT
  | RowsOrRange 'BETWEEN' PopLexerState OptionalCurrentOrPreceding_EDIT OptionalAndFollowing
  | RowsOrRange 'BETWEEN' PopLexerState OptionalCurrentOrPreceding OptionalAndFollowing_EDIT
  | RowsOrRange 'UNBOUNDED' PopLexerState OptionalCurrentOrPreceding 'CURSOR'
-   {
-     if (!$4 && parser.isHive()) {
-       parser.suggestKeywords(['PRECEDING']);
-     }
-   }
  | RowsOrRange 'UNBOUNDED' PopLexerState OptionalCurrentOrPreceding_EDIT
  ;
 
@@ -2775,9 +2691,6 @@ CountFunction_EDIT
      var keywords = parser.getSelectListKeywords();
      if (!$3) {
        keywords.push('DISTINCT');
-       if (parser.isImpala()) {
-         keywords.push('ALL');
-       }
        if (parser.yy.result.suggestKeywords) {
          keywords = parser.yy.result.suggestKeywords.concat(keywords);
        }
@@ -2796,9 +2709,6 @@ CountFunction_EDIT
        var keywords = parser.getSelectListKeywords();
        if (!$3) {
          keywords.push('DISTINCT');
-         if (parser.isImpala()) {
-           keywords.push('ALL');
-         }
        }
        parser.suggestKeywords(keywords);
      }
@@ -2819,9 +2729,6 @@ OtherAggregateFunction_EDIT
      if (!$3) {
        if ($1.toLowerCase() === 'group_concat') {
          keywords.push('ALL');
-       } else if (parser.isImpala()) {
-         keywords.push('ALL');
-         keywords.push('DISTINCT');
        } else {
          keywords.push('DISTINCT');
        }
@@ -2845,9 +2752,6 @@ OtherAggregateFunction_EDIT
        if (!$3) {
          if ($1.toLowerCase() === 'group_concat') {
            keywords.push('ALL');
-         } else if (parser.isImpala()) {
-           keywords.push('ALL');
-           keywords.push('DISTINCT');
          } else {
            keywords.push('DISTINCT');
          }
@@ -2893,9 +2797,6 @@ SumFunction_EDIT
      var keywords = parser.getSelectListKeywords(true);
      if (!$3) {
        keywords.push('DISTINCT');
-       if (parser.isImpala()) {
-         keywords.push('ALL');
-       }
      }
      if (parser.yy.result.suggestKeywords) {
        keywords = parser.yy.result.suggestKeywords.concat(keywords);
@@ -2916,32 +2817,3 @@ SumFunction_EDIT
      $$ = { types: parser.findReturnTypes($1) };
    }
  ;
-
-OptionalOuter
- :
- | 'OUTER'
- ;
-
-OptionalWindowClause
- ;
-
-OptionalImpalaBroadcastOrShuffle
- ;
-
-OptionalOffsetClause
- ;
-
-OptionalClusterOrDistributeBy
- ;
-
-OptionalStraightJoin
- ;
-
-OptionalHdfsLocation
- ;
-
-OptionalPartitionOperations
- ;
-
-OptionalPartitionOperations_EDIT
- ;

+ 2 - 23
desktop/core/src/desktop/js/parse/jison/generic/sql_set.jison

@@ -15,21 +15,13 @@
 // limitations under the License.
 
 DataDefinition
- : SetRoleStatement
- | SetSpecification
+ : SetSpecification
  ;
 
 DataDefinition_EDIT
- : SetRoleStatement_EDIT
- | 'SET' 'CURSOR'
+ : 'SET' 'CURSOR'
    {
      parser.suggestSetOptions();
-     if (parser.isHive()) {
-       parser.suggestKeywords(['ROLE']);
-     }
-     if (parser.isImpala()) {
-       parser.suggestKeywords(['ALL']);
-     }
    }
  ;
 
@@ -52,16 +44,3 @@ SetValue
  | 'FALSE'
  | 'NULL'
  ;
-
-SetRoleStatement
- : 'SET' '<hive>ROLE' RegularIdentifier
- | 'SET' '<hive>ROLE' '<hive>ALL'
- | 'SET' '<hive>ROLE' '<hive>NONE'
- ;
-
-SetRoleStatement_EDIT
- : 'SET' '<hive>ROLE' 'CURSOR'
-   {
-     parser.suggestKeywords(['ALL', 'NONE']);
-   }
- ;

+ 0 - 610
desktop/core/src/desktop/js/parse/jison/generic/sql_show.jison

@@ -1,610 +0,0 @@
-// Licensed to Cloudera, Inc. under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  Cloudera, Inc. licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-DataDefinition
- : ShowStatement
- ;
-
-DataDefinition_EDIT
- : ShowStatement_EDIT
- ;
-
-ShowStatement
- : ShowColumnStatsStatement
- | ShowColumnsStatement
- | ShowCompactionsStatement
- | ShowConfStatement
- | ShowCreateTableStatement
- | ShowCurrentRolesStatement
- | ShowDatabasesStatement
- | ShowFilesStatement
- | ShowFunctionsStatement
- | ShowGrantStatement
- | ShowIndexStatement
- | ShowLocksStatement
- | ShowPartitionsStatement
- | ShowRoleStatement
- | ShowRolesStatement
- | ShowTableStatement
- | ShowTblPropertiesStatement
- | ShowTransactionsStatement
- | ShowViewsStatement
- ;
-
-AnyShow
- : 'SHOW'
- | '<hive>SHOW'
- ;
-
-ShowStatement_EDIT
- : AnyShow 'CURSOR'
-   {
-     if (parser.isHive()) {
-       parser.suggestKeywords(['COLUMNS', 'COMPACTIONS', 'CONF', 'CREATE TABLE', 'CURRENT ROLES', 'DATABASES', 'FORMATTED', 'FUNCTIONS', 'GRANT', 'INDEX', 'INDEXES', 'LOCKS', 'PARTITIONS', 'PRINCIPALS', 'ROLE GRANT', 'ROLES', 'SCHEMAS', 'TABLE EXTENDED', 'TABLES', 'TBLPROPERTIES', 'TRANSACTIONS', 'VIEWS']);
-     } else if (parser.isImpala()) {
-       parser.suggestKeywords(['AGGREGATE FUNCTIONS', 'ANALYTIC FUNCTIONS', 'COLUMN STATS', 'CREATE TABLE', 'CURRENT ROLES', 'CREATE VIEW', 'DATABASES', 'FILES IN', 'FUNCTIONS', 'GRANT ROLE', 'GRANT USER', 'PARTITIONS', 'RANGE PARTITIONS', 'ROLE GRANT GROUP', 'ROLES', 'SCHEMAS', 'TABLE STATS', 'TABLES']);
-     } else {
-       parser.suggestKeywords(['COLUMNS', 'DATABASES', 'TABLES']);
-     }
-   }
- | AnyShow 'CURSOR' RegularOrBackTickedSchemaQualifiedName
-   {
-     // ROLES is considered a non-reserved keywords so we can't match it in ShowCurrentRolesStatement_EDIT
-     if (!parser.isImpala() && $3.identifierChain && $3.identifierChain.length === 1 && $3.identifierChain[0].name.toLowerCase() === 'roles') {
-       parser.suggestKeywords(['CURRENT']);
-       parser.yy.locations.pop();
-     } else {
-       parser.addTablePrimary($3);
-       if (parser.isImpala()) {
-         parser.suggestKeywords(['COLUMN STATS', 'CREATE TABLE', 'CREATE VIEW', 'FILES IN', 'PARTITIONS', 'RANGE PARTITIONS', 'TABLE STATS']);
-       }
-     }
-   }
- | AnyShow 'CURSOR' LIKE SingleQuotedValue
-   {
-     if (parser.isImpala()) {
-       parser.suggestKeywords(['AGGREGATE FUNCTIONS', 'ANALYTIC FUNCTIONS', 'DATABASES', 'FUNCTIONS', 'SCHEMAS', 'TABLES']);
-     } else if (parser.isHive()) {
-       parser.suggestKeywords(['DATABASES', 'SCHEMAS', 'TABLE EXTENDED']);
-     }
-   }
- | ShowColumnStatsStatement_EDIT
- | ShowColumnsStatement_EDIT
- | ShowCreateTableStatement_EDIT
- | ShowCurrentRolesStatement_EDIT
- | ShowDatabasesStatement_EDIT
- | ShowFilesStatement_EDIT
- | ShowFunctionsStatement_EDIT
- | ShowGrantStatement_EDIT
- | ShowIndexStatement_EDIT
- | ShowLocksStatement_EDIT
- | ShowPartitionsStatement_EDIT
- | ShowRoleStatement_EDIT
- | ShowTableStatement_EDIT
- | ShowTblPropertiesStatement_EDIT
- | ShowViewsStatement_EDIT
- ;
-
-ShowColumnStatsStatement
- : AnyShow '<impala>COLUMN' '<impala>STATS' RegularOrBackTickedSchemaQualifiedName
-   {
-     parser.addTablePrimary($4);
-   }
- ;
-
-ShowColumnStatsStatement_EDIT
- : AnyShow '<impala>COLUMN' 'CURSOR'
-   {
-     parser.suggestKeywords(['STATS']);
-   }
- | AnyShow '<impala>COLUMN' '<impala>STATS' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({
-       appendDot: true
-     });
-   }
- | AnyShow '<impala>COLUMN' '<impala>STATS' RegularOrBackTickedSchemaQualifiedName_EDIT
- ;
-
-ShowColumnsStatement
- : AnyShow '<hive>COLUMNS' FromOrIn RegularOrBacktickedIdentifier
- | AnyShow '<hive>COLUMNS' FromOrIn RegularOrBacktickedIdentifier FromOrIn RegularOrBacktickedIdentifier
- ;
-
-ShowColumnsStatement_EDIT
- : AnyShow '<hive>COLUMNS' 'CURSOR'
-   {
-     parser.suggestKeywords(['FROM', 'IN']);
-   }
- | AnyShow '<hive>COLUMNS' 'CURSOR' RegularOrBacktickedIdentifier
-   {
-     parser.suggestKeywords(['FROM', 'IN']);
-   }
- | AnyShow '<hive>COLUMNS' FromOrIn 'CURSOR'
-   {
-     parser.suggestTables();
-   }
- | AnyShow '<hive>COLUMNS' FromOrIn 'CURSOR' FromOrIn
-   {
-     parser.suggestTables();
-   }
- | AnyShow '<hive>COLUMNS' FromOrIn 'CURSOR' FromOrIn RegularOrBacktickedIdentifier
-   {
-     parser.suggestTables();
-   }
- | AnyShow '<hive>COLUMNS' FromOrIn RegularOrBacktickedIdentifier 'CURSOR'
-   {
-     parser.suggestKeywords(['FROM', 'IN']);
-   }
- | AnyShow '<hive>COLUMNS' FromOrIn RegularOrBacktickedIdentifier 'CURSOR' RegularOrBacktickedIdentifier
-   {
-     parser.suggestKeywords(['FROM', 'IN']);
-   }
- | AnyShow '<hive>COLUMNS' FromOrIn RegularOrBacktickedIdentifier FromOrIn 'CURSOR'
-   {
-     parser.suggestDatabases();
-   }
- ;
-
-ShowCompactionsStatement
- : AnyShow '<hive>COMPACTIONS'
- ;
-
-ShowConfStatement
- : AnyShow '<hive>CONF' ConfigurationName
- ;
-
-ShowCreateTableStatement
- ;
-
-ShowCreateTableStatement_EDIT
- ;
-
-AnyTableOrView
- : 'TABLE'
- | 'VIEW'   --> { isView: true }
- ;
-
-ShowCurrentRolesStatement
- : AnyShow '<hive>CURRENT' '<hive>ROLES'
- | AnyShow '<impala>CURRENT' '<impala>ROLES'
- ;
-
-ShowCurrentRolesStatement_EDIT
- : AnyShow '<hive>CURRENT' 'CURSOR'
-   {
-     parser.suggestKeywords([ 'ROLES' ]);
-   }
- | AnyShow '<impala>CURRENT' 'CURSOR'
-   {
-     parser.suggestKeywords([ 'ROLES' ]);
-   }
- | AnyShow 'CURSOR' '<impala>ROLES'
-   {
-     parser.suggestKeywords([ 'CURRENT' ]);
-   }
- ;
-
-ShowDatabasesStatement
- ;
-
-ShowDatabasesStatement_EDIT
- ;
-
-ShowFilesStatement
- : AnyShow '<impala>FILES' 'IN' RegularOrBackTickedSchemaQualifiedName OptionalPartitionSpec
-   {
-     parser.addTablePrimary($4);
-   }
- ;
-
-ShowFilesStatement_EDIT
- : AnyShow '<impala>FILES' 'CURSOR'
-   {
-     parser.suggestKeywords(['IN']);
-   }
- | AnyShow '<impala>FILES' 'IN' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({
-       appendDot: true
-     });
-   }
- | AnyShow '<impala>FILES' 'IN' RegularOrBackTickedSchemaQualifiedName_EDIT OptionalPartitionSpec
- | AnyShow '<impala>FILES' 'IN' RegularOrBackTickedSchemaQualifiedName OptionalPartitionSpec 'CURSOR'
-   {
-     parser.addTablePrimary($4);
-     if (!$5) {
-       parser.suggestKeywords(['PARTITION']);
-     }
-   }
- | AnyShow '<impala>FILES' 'IN' RegularOrBackTickedSchemaQualifiedName OptionalPartitionSpec_EDIT
- | AnyShow '<impala>FILES' 'CURSOR' RegularOrBackTickedSchemaQualifiedName OptionalPartitionSpec
-   {
-     parser.addTablePrimary($4);
-     parser.suggestKeywords(['IN']);
-   }
- ;
-
-ShowFunctionsStatement
- : AnyShow '<hive>FUNCTIONS'
- | AnyShow '<hive>FUNCTIONS' DoubleQuotedValue
- | AnyShow OptionalAggregateOrAnalytic '<impala>FUNCTIONS' OptionalInDatabase
- | AnyShow OptionalAggregateOrAnalytic '<impala>FUNCTIONS' OptionalInDatabase 'LIKE' QuotedValue
- ;
-
-ShowFunctionsStatement_EDIT
- | AnyShow 'CURSOR' '<impala>FUNCTIONS' OptionalInDatabase
-   {
-     parser.suggestKeywords(['AGGREGATE', 'ANALYTICAL']);
-   }
- | AnyShow OptionalAggregateOrAnalytic '<impala>FUNCTIONS' OptionalInDatabase 'CURSOR'
-   {
-     if (!$4) {
-       parser.suggestKeywords(['IN', 'LIKE']);
-     } else {
-       parser.suggestKeywords(['LIKE']);
-     }
-   }
- | AnyShow 'CURSOR' '<impala>FUNCTIONS' OptionalInDatabase 'LIKE' QuotedValue
-   {
-     parser.suggestKeywords(['AGGREGATE', 'ANALYTICAL']);
-   }
- | AnyShow OptionalAggregateOrAnalytic '<impala>FUNCTIONS' OptionalInDatabase 'CURSOR' QuotedValue
-   {
-     if (!$4) {
-       parser.suggestKeywords([{ value: 'IN', weight: 2 }, { value: 'LIKE', weight: 1 }]);
-     } else {
-       parser.suggestKeywords(['LIKE']);
-     }
-   }
- ;
-
-ShowGrantStatement
- : AnyShow '<hive>GRANT' OptionalPrincipalName
- | AnyShow '<hive>GRANT' OptionalPrincipalName 'ON' '<hive>ALL'
- | AnyShow '<hive>GRANT' OptionalPrincipalName 'ON' SchemaQualifiedTableIdentifier
- | AnyShow '<hive>GRANT' OptionalPrincipalName 'ON' 'TABLE' SchemaQualifiedTableIdentifier
- ;
-
-ShowGrantStatement_EDIT
- : AnyShow '<hive>GRANT' OptionalPrincipalName_EDIT
-   {
-     parser.suggestKeywords(['ON']);
-   }
- | AnyShow '<hive>GRANT' OptionalPrincipalName_EDIT 'ON' '<hive>ALL'
- | AnyShow '<hive>GRANT' OptionalPrincipalName 'ON' 'CURSOR'
-   {
-     parser.suggestKeywords(['ALL', 'TABLE']);
-     parser.suggestTables();
-   }
- | AnyShow '<hive>GRANT' OptionalPrincipalName 'ON' SchemaQualifiedTableIdentifier_EDIT
- | AnyShow  '<hive>GRANT' OptionalPrincipalName 'ON' 'TABLE' 'CURSOR'
-   {
-     parser.suggestTables();
-   }
- | AnyShow '<hive>GRANT' OptionalPrincipalName 'ON' 'CURSOR' SchemaQualifiedTableIdentifier
-   {
-     parser.suggestKeywords(['TABLE']);
-   }
- | AnyShow '<hive>GRANT' OptionalPrincipalName 'ON' 'CURSOR' SchemaQualifiedTableIdentifier_EDIT
- | AnyShow '<impala>GRANT' 'CURSOR'
-   {
-     parser.suggestKeywords(['ROLE', 'USER']);
-   }
- ;
-
-OptionalPrincipalName
- :
- | RegularIdentifier
- ;
-
-OptionalPrincipalName_EDIT
- : 'CURSOR'
- | RegularIdentifier 'CURSOR'
- ;
-
-ShowIndexStatement
- : AnyShow OptionallyFormattedIndex 'ON' RegularOrBacktickedIdentifier
- | AnyShow OptionallyFormattedIndex 'ON' RegularOrBacktickedIdentifier FromOrIn RegularOrBacktickedIdentifier
- ;
-
-ShowIndexStatement_EDIT
- : AnyShow OptionallyFormattedIndex
- | AnyShow OptionallyFormattedIndex_EDIT
- | AnyShow OptionallyFormattedIndex_EDIT 'ON' RegularOrBacktickedIdentifier
- | AnyShow OptionallyFormattedIndex_EDIT 'ON' RegularOrBacktickedIdentifier FromOrIn RegularOrBacktickedIdentifier
- | AnyShow OptionallyFormattedIndex 'CURSOR'
-   {
-     parser.suggestKeywords(['ON']);
-   }
- | AnyShow OptionallyFormattedIndex 'ON' 'CURSOR'
-   {
-     parser.suggestTables();
-   }
- | AnyShow OptionallyFormattedIndex 'CURSOR' RegularOrBacktickedIdentifier
-   {
-     parser.suggestKeywords(['ON']);
-   }
- | AnyShow OptionallyFormattedIndex 'ON' RegularOrBacktickedIdentifier 'CURSOR'
-   {
-     parser.suggestKeywords(['FROM', 'IN']);
-   }
- | AnyShow OptionallyFormattedIndex 'ON' RegularOrBacktickedIdentifier 'CURSOR' RegularOrBacktickedIdentifier
-   {
-     parser.suggestKeywords(['FROM', 'IN']);
-   }
- | AnyShow OptionallyFormattedIndex 'ON' RegularOrBacktickedIdentifier FromOrIn 'CURSOR'
-   {
-     parser.suggestDatabases();
-   }
- | AnyShow OptionallyFormattedIndex 'ON' 'CURSOR' FromOrIn RegularOrBacktickedIdentifier
-   {
-     parser.suggestTables({identifierChain: [{name: $6}]});
-   }
- ;
-
-ShowLocksStatement
- : AnyShow '<hive>LOCKS' RegularOrBackTickedSchemaQualifiedName
-   {
-     parser.addTablePrimary($3);
-   }
- | AnyShow '<hive>LOCKS' RegularOrBackTickedSchemaQualifiedName '<hive>EXTENDED'
-   {
-     parser.addTablePrimary($3);
-   }
- | AnyShow '<hive>LOCKS' RegularOrBackTickedSchemaQualifiedName PartitionSpec
-   {
-     parser.addTablePrimary($3);
-   }
- | AnyShow '<hive>LOCKS' RegularOrBackTickedSchemaQualifiedName PartitionSpec '<hive>EXTENDED'
-   {
-     parser.addTablePrimary($3);
-   }
- | AnyShow '<hive>LOCKS' DatabaseOrSchema RegularOrBacktickedIdentifier
- ;
-
-ShowLocksStatement_EDIT
- : AnyShow '<hive>LOCKS' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({
-       appendDot: true
-     });
-     parser.suggestKeywords(['DATABASE', 'SCHEMA']);
-   }
- | AnyShow '<hive>LOCKS' RegularOrBackTickedSchemaQualifiedName_EDIT
- | AnyShow '<hive>LOCKS' RegularOrBackTickedSchemaQualifiedName 'CURSOR'
-    {
-      parser.addTablePrimary($3);
-      parser.suggestKeywords(['EXTENDED', 'PARTITION']);
-    }
- | AnyShow '<hive>LOCKS' RegularOrBackTickedSchemaQualifiedName_EDIT '<hive>EXTENDED'
- | AnyShow '<hive>LOCKS' RegularOrBackTickedSchemaQualifiedName_EDIT PartitionSpec
- | AnyShow '<hive>LOCKS' RegularOrBackTickedSchemaQualifiedName PartitionSpec 'CURSOR'
-   {
-     parser.addTablePrimary($3);
-     parser.suggestKeywords(['EXTENDED']);
-   }
- | AnyShow '<hive>LOCKS' RegularOrBackTickedSchemaQualifiedName_EDIT PartitionSpec '<hive>EXTENDED'
- | AnyShow '<hive>LOCKS' DatabaseOrSchema 'CURSOR'
-   {
-     parser.suggestDatabases();
-   }
- ;
-
-ShowPartitionsStatement
- : AnyShow '<hive>PARTITIONS' RegularOrBackTickedSchemaQualifiedName
-   {
-     parser.addTablePrimary($3);
-   }
- | AnyShow '<hive>PARTITIONS' RegularOrBackTickedSchemaQualifiedName PartitionSpec
-   {
-     parser.addTablePrimary($3);
-   }
- | AnyShow '<impala>PARTITIONS' RegularOrBackTickedSchemaQualifiedName
-   {
-     parser.addTablePrimary($3);
-   }
- | AnyShow '<impala>RANGE' '<impala>PARTITIONS' RegularOrBackTickedSchemaQualifiedName
-   {
-     parser.addTablePrimary($3);
-   }
- ;
-
-ShowPartitionsStatement_EDIT
- : AnyShow '<hive>PARTITIONS' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({
-       appendDot: true
-     });
-   }
- | AnyShow '<hive>PARTITIONS' RegularOrBackTickedSchemaQualifiedName_EDIT
- | AnyShow '<hive>PARTITIONS' RegularOrBackTickedSchemaQualifiedName 'CURSOR'
-   {
-     parser.addTablePrimary($3);
-     parser.suggestKeywords(['PARTITION']);
-   }
- | AnyShow '<hive>PARTITIONS' RegularOrBackTickedSchemaQualifiedName_EDIT PartitionSpec
- | AnyShow '<impala>PARTITIONS' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({
-       appendDot: true
-     });
-   }
- | AnyShow '<impala>PARTITIONS' RegularOrBackTickedSchemaQualifiedName_EDIT
- | AnyShow '<impala>RANGE' '<impala>PARTITIONS' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({
-       appendDot: true
-     });
-   }
- | AnyShow '<impala>RANGE' '<impala>PARTITIONS' RegularOrBackTickedSchemaQualifiedName_EDIT
- ;
-
-ShowRoleStatement
- ;
-
-ShowRoleStatement_EDIT
- ;
-
-ShowRolesStatement
- : AnyShow '<impala>ROLES'
- | AnyShow '<hive>ROLES'
- ;
-
-ShowTableStatement
- : AnyShow '<hive>TABLE' '<hive>EXTENDED' OptionalFromDatabase 'LIKE' SingleQuotedValue
- | AnyShow '<hive>TABLE' '<hive>EXTENDED' OptionalFromDatabase 'LIKE' SingleQuotedValue PartitionSpec
- ;
-
-ShowTableStatement_EDIT
- : AnyShow '<hive>TABLE' 'CURSOR'
-   {
-     parser.suggestKeywords(['EXTENDED']);
-   }
- | AnyShow '<hive>TABLE' '<hive>EXTENDED' OptionalFromDatabase
- | AnyShow '<hive>TABLE' '<hive>EXTENDED' OptionalFromDatabase_EDIT
- | AnyShow '<hive>TABLE' '<hive>EXTENDED' OptionalFromDatabase 'CURSOR'
-    {
-      if ($4) {
-        parser.suggestKeywords(['LIKE']);
-      } else {
-        parser.suggestKeywords(['FROM', 'IN', 'LIKE']);
-      }
-    }
- | AnyShow '<hive>TABLE' '<hive>EXTENDED' OptionalFromDatabase_EDIT 'LIKE' SingleQuotedValue
- | AnyShow '<hive>TABLE' 'CURSOR' OptionalFromDatabase 'LIKE' SingleQuotedValue
-    {
-      if (parser.isHive()) {
-        parser.suggestKeywords(['EXTENDED']);
-      }
-    }
- | AnyShow '<hive>TABLE' '<hive>EXTENDED' OptionalFromDatabase 'CURSOR' SingleQuotedValue
-    {
-      parser.suggestKeywords(['LIKE']);
-    }
- | AnyShow '<hive>TABLE' '<hive>EXTENDED' OptionalFromDatabase 'LIKE' SingleQuotedValue 'CURSOR'
-    {
-      parser.suggestKeywords(['PARTITION']);
-    }
- | AnyShow '<hive>TABLE' '<hive>EXTENDED' OptionalFromDatabase_EDIT 'LIKE' SingleQuotedValue PartitionSpec
- | AnyShow '<hive>TABLE' 'CURSOR' OptionalFromDatabase 'LIKE' SingleQuotedValue PartitionSpec
-   {
-     parser.suggestKeywords(['EXTENDED']);
-   }
- | AnyShow '<hive>TABLE' '<hive>EXTENDED' OptionalFromDatabase 'CURSOR' SingleQuotedValue PartitionSpec
-   {
-     parser.suggestKeywords(['LIKE']);
-   }
- | AnyShow '<hive>TABLE' '<hive>EXTENDED' OptionalFromDatabase 'LIKE' SingleQuotedValue 'CURSOR' PartitionSpecList
-   {
-     parser.suggestKeywords(['PARTITION']);
-   }
- | AnyShow '<impala>TABLE' 'CURSOR'
-   {
-     parser.suggestKeywords(['STATS']);
-   }
- | AnyShow '<impala>TABLE' '<impala>STATS' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({
-       appendDot: true
-     });
-   }
- | AnyShow '<impala>TABLE' '<impala>STATS' RegularOrBackTickedSchemaQualifiedName
-    {
-      parser.addTablePrimary($4);
-    }
- | AnyShow '<impala>TABLE' '<impala>STATS' RegularOrBackTickedSchemaQualifiedName_EDIT
- ;
-
-ShowTblPropertiesStatement
- : AnyShow '<hive>TBLPROPERTIES' RegularOrBackTickedSchemaQualifiedName
-   {
-     parser.addTablePrimary($3);
-   }
- | AnyShow '<hive>TBLPROPERTIES' RegularOrBackTickedSchemaQualifiedName '(' QuotedValue ')'
-   {
-     parser.addTablePrimary($3);
-   }
- ;
-
-ShowTblPropertiesStatement_EDIT
- : AnyShow '<hive>TBLPROPERTIES' RegularOrBackTickedSchemaQualifiedName_EDIT
- | AnyShow '<hive>TBLPROPERTIES' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({ prependDot: true });
-   }
- ;
-
-ShowTransactionsStatement
- : AnyShow '<hive>TRANSACTIONS'
- ;
-
-ShowViewsStatement
- : AnyShow '<hive>VIEWS' OptionalInOrFromDatabase OptionalLike
- ;
-
-ShowViewsStatement_EDIT
- : AnyShow '<hive>VIEWS' OptionalInOrFromDatabase OptionalLike 'CURSOR'
-   {
-     if (!$4 && !$3) {
-       parser.suggestKeywords([{ value: 'IN', weight: 2 }, { value: 'FROM', weight: 2 }, { value: 'LIKE', weight: 1 }]);
-     } else if (!$4) {
-       parser.suggestKeywords(['LIKE']);
-     }
-   }
- | AnyShow '<hive>VIEWS' InOrFromDatabase_EDIT OptionalLike
- | AnyShow '<hive>VIEWS' OptionalInOrFromDatabase Like_EDIT
- ;
-
-OptionalInOrFromDatabase
- :
- | 'IN' RegularOrBacktickedIdentifier
-   {
-     parser.addDatabaseLocation(@2, [ { name: $2 } ]);
-   }
- | 'FROM' RegularOrBacktickedIdentifier
-   {
-     parser.addDatabaseLocation(@2, [ { name: $2 } ]);
-   }
- ;
-
-InOrFromDatabase_EDIT
- : 'IN' 'CURSOR'
-   {
-     parser.suggestDatabases();
-   }
- | 'FROM' 'CURSOR'
-   {
-     parser.suggestDatabases();
-   }
- ;
-
-OptionalLike
- :
- | 'LIKE' SingleQuotedValue
- ;
-
-Like_EDIT
- : 'LIKE' 'CURSOR'
- ;

+ 1 - 17
desktop/core/src/desktop/js/parse/jison/generic/sql_update.jison

@@ -33,23 +33,7 @@ UpdateStatement_EDIT
  | 'UPDATE' TargetTable 'SET' SetClauseList OptionalFromJoinedTable WhereClause_EDIT
  | 'UPDATE' TargetTable 'SET' SetClauseList OptionalFromJoinedTable OptionalWhereClause 'CURSOR'
    {
-     if (parser.isImpala() && !$6 && !$5) {
-       parser.suggestKeywords([{ value: 'FROM', weight: 2 }, { value: 'WHERE', weight: 1 }]);
-     } else if (parser.isImpala() && !$6 && $5) {
-       var keywords = [{ value: 'FULL JOIN', weight: 2 }, { value: 'FULL OUTER JOIN', weight: 2 }, { value: 'JOIN', weight: 2 }, { value: 'LEFT JOIN', weight: 2 }, { value: 'LEFT OUTER JOIN', weight: 2 }, { value: 'RIGHT JOIN', weight: 2 }, { value: 'RIGHT OUTER JOIN', weight: 2 }, { value: 'INNER JOIN', weight: 2 },  { value: 'LEFT ANTI JOIN', weight: 2 }, { value: 'LEFT SEMI JOIN', weight: 2 }, { value: 'RIGHT ANTI JOIN', weight: 2 }, { value: 'RIGHT SEMI JOIN', weight: 2 }, { value: 'WHERE', weight: 1 }];
-       if ($5.suggestJoinConditions) {
-         parser.suggestJoinConditions($5.suggestJoinConditions);
-       }
-       if ($5.suggestJoins) {
-         parser.suggestJoins($5.suggestJoins);
-       }
-       if ($5.suggestKeywords) {
-         keywords = keywords.concat(parser.createWeightedKeywords($5.suggestKeywords, 3));
-       }
-       parser.suggestKeywords(keywords);
-     } else if (!$6) {
-       parser.suggestKeywords([ 'WHERE' ]);
-     }
+     parser.suggestKeywords([ 'WHERE' ]);
    }
  | 'UPDATE' TargetTable 'CURSOR'
    {

+ 2 - 10
desktop/core/src/desktop/js/parse/jison/generic/sql_use.jison

@@ -22,13 +22,8 @@ DataDefinition_EDIT
  : UseStatement_EDIT
  ;
 
-AnyUse
- : 'USE'
- | '<hive>USE'
- ;
-
 UseStatement
- : AnyUse RegularIdentifier
+ : 'USE' RegularIdentifier
    {
      if (! parser.yy.cursorFound) {
        parser.yy.result.useDatabase = $2;
@@ -37,11 +32,8 @@ UseStatement
  ;
 
 UseStatement_EDIT
- : AnyUse 'CURSOR'
+ : 'USE' 'CURSOR'
    {
      parser.suggestDatabases();
    }
  ;
-
-
-// ===================================== Fin =====================================

+ 3 - 31
desktop/core/src/desktop/js/parse/jison/generic/sql_valueExpression.jison

@@ -35,7 +35,6 @@ ValueExpression
  | ValueExpression 'IS' OptionalNot 'NULL'                             -> { types: [ 'BOOLEAN' ] }
  | ValueExpression 'IS' OptionalNot 'TRUE'                             -> { types: [ 'BOOLEAN' ] }
  | ValueExpression 'IS' OptionalNot 'FALSE'                            -> { types: [ 'BOOLEAN' ] }
- | ValueExpression 'IS' OptionalNot '<impala>UNKNOWN'                  -> { types: [ 'BOOLEAN' ] }
  | ValueExpression 'IS' OptionalNot 'DISTINCT' 'FROM' ValueExpression  -> { types: [ 'BOOLEAN' ] }
  ;
 
@@ -77,27 +76,16 @@ ValueExpression_EDIT
    }
  | ValueExpression 'IS' 'CURSOR'
    {
-     var keywords = ['FALSE', 'NOT NULL', 'NOT TRUE', 'NOT FALSE', 'NULL', 'TRUE'];
-     if (parser.isImpala()) {
-       keywords = keywords.concat(['DISTINCT FROM', 'NOT DISTINCT FROM', 'NOT UNKNOWN', 'UNKNOWN']);
-     }
-     parser.suggestKeywords(keywords);
+     parser.suggestKeywords(['FALSE', 'NOT NULL', 'NOT TRUE', 'NOT FALSE', 'NULL', 'TRUE']);
      $$ = { types: [ 'BOOLEAN' ] };
    }
  | ValueExpression 'IS' 'NOT' 'CURSOR'
    {
-     var keywords = ['FALSE', 'NULL', 'TRUE'];
-     if (parser.isImpala()) {
-       keywords = keywords.concat(['DISTINCT FROM', 'UNKNOWN']);
-     }
-     parser.suggestKeywords(keywords);
+     parser.suggestKeywords(['FALSE', 'NULL', 'TRUE']);
      $$ = { types: [ 'BOOLEAN' ] };
    }
  | ValueExpression 'IS' OptionalNot 'DISTINCT' 'CURSOR'
    {
-     if (parser.isImpala()) {
-       parser.suggestKeywords(['FROM']);
-     }
      $$ = { types: [ 'BOOLEAN' ] };
    }
  | ValueExpression 'IS' 'CURSOR' 'NULL'
@@ -592,16 +580,12 @@ ValueExpression
 
 LikeRightPart
  : 'LIKE' ValueExpression             -> { suggestKeywords: ['NOT'] }
- | '<impala>ILIKE' ValueExpression    -> { suggestKeywords: ['NOT'] }
- | '<impala>IREGEXP' ValueExpression  -> { suggestKeywords: ['NOT'] }
  | 'RLIKE' ValueExpression            -> { suggestKeywords: ['NOT'] }
  | 'REGEXP' ValueExpression           -> { suggestKeywords: ['NOT'] }
  ;
 
 LikeRightPart_EDIT
  : 'LIKE' ValueExpression_EDIT
- | '<impala>ILIKE' ValueExpression_EDIT
- | '<impala>IREGEXP' ValueExpression_EDIT
  | 'RLIKE' ValueExpression_EDIT
  | 'REGEXP' ValueExpression_EDIT
  | 'LIKE' PartialBacktickedOrCursor
@@ -610,18 +594,6 @@ LikeRightPart_EDIT
      parser.suggestColumns({ types: [ 'STRING' ] });
      $$ = { types: ['BOOLEAN'] }
    }
- | '<impala>ILIKE' PartialBacktickedOrCursor
-   {
-     parser.suggestFunctions({ types: [ 'STRING' ] });
-     parser.suggestColumns({ types: [ 'STRING' ] });
-     $$ = { types: ['BOOLEAN'] }
-   }
- | '<impala>IREGEXP' PartialBacktickedOrCursor
-   {
-     parser.suggestFunctions({ types: [ 'STRING' ] });
-     parser.suggestColumns({ types: [ 'STRING' ] });
-     $$ = { types: ['BOOLEAN'] }
-   }
  | 'RLIKE' PartialBacktickedOrCursor
    {
      parser.suggestFunctions({ types: [ 'STRING' ] });
@@ -864,4 +836,4 @@ CaseWhenThenListPartTwo_EDIT
      parser.valueExpressionSuggest();
      $$ = { caseTypes: [{ types: ['T'] }] };
    }
- ;
+ ;