You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by jc...@apache.org on 2020/07/17 15:16:18 UTC

[hive] branch master updated: HIVE-23869: Move alter statements in parser to new file (Jesus Camacho Rodriguez, reviewed by Miklos Gergely)

This is an automated email from the ASF dual-hosted git repository.

jcamacho pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new 635e24d  HIVE-23869: Move alter statements in parser to new file (Jesus Camacho Rodriguez, reviewed by Miklos Gergely)
635e24d is described below

commit 635e24dc0d0ea483d831adcc788b4312a713b2c9
Author: Jesús Camacho Rodríguez <jc...@apache.org>
AuthorDate: Fri Jul 17 08:16:09 2020 -0700

    HIVE-23869: Move alter statements in parser to new file (Jesus Camacho Rodriguez, reviewed by Miklos Gergely)
    
    Closes apache/hive#1270
---
 parser/bin/fixHiveParser.sh                        |  33 --
 parser/pom.xml                                     |  16 -
 .../hadoop/hive/ql/parse/AlterClauseParser.g       | 452 +++++++++++++++++++++
 .../org/apache/hadoop/hive/ql/parse/HiveParser.g   | 409 +------------------
 .../hadoop/hive/ql/parse/IdentifiersParser.g       |  15 +-
 5 files changed, 463 insertions(+), 462 deletions(-)

diff --git a/parser/bin/fixHiveParser.sh b/parser/bin/fixHiveParser.sh
deleted file mode 100755
index d469388..0000000
--- a/parser/bin/fixHiveParser.sh
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/bash
-
-# This is a temporary solution for the issue of the "code too large" problem related to HiveParser.java
-# We got to a point where adding anything to the antlr files lead to an issue about having a HiveParser.java that can not be compiled due to the compiled code size limitation in java (maximum 65536 bytes), so to avoid it we temorarly add this script to remove the huge tokenNames array into a separate file.
-# The real solution would be to switch to antlr 4
-
-input="target/generated-sources/antlr3/org/apache/hadoop/hive/ql/parse/HiveParser.java"
-output="target/generated-sources/antlr3/org/apache/hadoop/hive/ql/parse/HiveParser.java-fixed"
-tokenFile="target/generated-sources/antlr3/org/apache/hadoop/hive/ql/parse/HiveParserTokens.java"
-
-# create HiveParserTokens containing the tokenNames 
-
-rm $tokenFile > /dev/null 2>&1
-
-cat <<EOT >> $tokenFile
-package org.apache.hadoop.hive.ql.parse;
-
-public class HiveParserTokens {
-EOT
-
-awk '/tokenNames/ { matched = 1 } matched' $input | awk '{print} /};/ {exit}' >> $tokenFile
-
-echo "}" >> $tokenFile
-
-# remove tokenNames array from the original file
-
-rm $output > /dev/null 2>&1
-
-awk '/tokenNames/ {exit} {print}' $input >> $output
-echo "  public static final String[] tokenNames = HiveParserTokens.tokenNames;" >> $output
-awk 'matched; /};$/ { matched = 1 }' $input >> $output
-
-mv $output $input
diff --git a/parser/pom.xml b/parser/pom.xml
index bdaa5cb..41fee3b 100644
--- a/parser/pom.xml
+++ b/parser/pom.xml
@@ -90,22 +90,6 @@
         </configuration>
       </plugin>
       <plugin>
-        <artifactId>exec-maven-plugin</artifactId>
-        <groupId>org.codehaus.mojo</groupId>
-        <executions>
-          <execution>
-            <id>HiveParser.java fix</id>
-            <phase>generate-sources</phase>
-            <goals>
-              <goal>exec</goal>
-            </goals>
-            <configuration>
-              <executable>${basedir}/bin/fixHiveParser.sh</executable>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-      <plugin>
         <groupId>org.codehaus.mojo</groupId>
         <artifactId>build-helper-maven-plugin</artifactId>
         <executions>
diff --git a/parser/src/java/org/apache/hadoop/hive/ql/parse/AlterClauseParser.g b/parser/src/java/org/apache/hadoop/hive/ql/parse/AlterClauseParser.g
new file mode 100644
index 0000000..cced8bb
--- /dev/null
+++ b/parser/src/java/org/apache/hadoop/hive/ql/parse/AlterClauseParser.g
@@ -0,0 +1,452 @@
+/**
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF 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.
+*/
+parser grammar AlterClauseParser;
+
+options
+{
+output=AST;
+ASTLabelType=ASTNode;
+backtrack=false;
+k=3;
+}
+
+@members {
+  @Override
+  public Object recoverFromMismatchedSet(IntStream input,
+      RecognitionException re, BitSet follow) throws RecognitionException {
+    throw re;
+  }
+  @Override
+  public void displayRecognitionError(String[] tokenNames,
+      RecognitionException e) {
+    gParent.errors.add(new ParseError(gParent, e, tokenNames));
+  }
+}
+
+@rulecatch {
+catch (RecognitionException e) {
+  throw e;
+}
+}
+
+
+alterStatement
+@init { gParent.pushMsg("alter statement", state); }
+@after { gParent.popMsg(state); }
+    : KW_ALTER KW_TABLE tableName alterTableStatementSuffix -> ^(TOK_ALTERTABLE tableName alterTableStatementSuffix)
+    | KW_ALTER KW_VIEW tableName KW_AS? alterViewStatementSuffix -> ^(TOK_ALTERVIEW tableName alterViewStatementSuffix)
+    | KW_ALTER KW_MATERIALIZED KW_VIEW tableNameTree=tableName alterMaterializedViewStatementSuffix[$tableNameTree.tree] -> alterMaterializedViewStatementSuffix
+    | KW_ALTER (KW_DATABASE|KW_SCHEMA) alterDatabaseStatementSuffix -> alterDatabaseStatementSuffix
+    ;
+
+alterTableStatementSuffix
+@init { gParent.pushMsg("alter table statement", state); }
+@after { gParent.popMsg(state); }
+    : (alterStatementSuffixRename[true]) => alterStatementSuffixRename[true]
+    | alterStatementSuffixDropPartitions[true]
+    | alterStatementSuffixAddPartitions[true]
+    | alterStatementSuffixTouch
+    | alterStatementSuffixArchive
+    | alterStatementSuffixUnArchive
+    | alterStatementSuffixProperties
+    | alterStatementSuffixSkewedby
+    | alterStatementSuffixExchangePartition
+    | alterStatementPartitionKeyType
+    | alterStatementSuffixDropConstraint
+    | alterStatementSuffixAddConstraint
+    | alterTblPartitionStatementSuffix[false]
+    | partitionSpec alterTblPartitionStatementSuffix[true] -> alterTblPartitionStatementSuffix partitionSpec
+    | alterStatementSuffixSetOwner
+    ;
+
+alterTblPartitionStatementSuffix[boolean partition]
+@init {gParent.pushMsg("alter table partition statement suffix", state);}
+@after {gParent.popMsg(state);}
+  : alterStatementSuffixFileFormat[partition]
+  | alterStatementSuffixLocation[partition]
+  | alterStatementSuffixMergeFiles[partition]
+  | alterStatementSuffixSerdeProperties[partition]
+  | alterStatementSuffixRenamePart
+  | alterStatementSuffixBucketNum[partition]
+  | alterTblPartitionStatementSuffixSkewedLocation
+  | alterStatementSuffixClusterbySortby
+  | alterStatementSuffixCompact
+  | alterStatementSuffixUpdateStatsCol[partition]
+  | alterStatementSuffixUpdateStats[partition]
+  | alterStatementSuffixRenameCol
+  | alterStatementSuffixAddCol
+  | alterStatementSuffixUpdateColumns
+  ;
+
+alterStatementPartitionKeyType
+@init {gParent.msgs.push("alter partition key type"); }
+@after {gParent.msgs.pop();}
+	: KW_PARTITION KW_COLUMN LPAREN columnNameType RPAREN
+	-> ^(TOK_ALTERTABLE_PARTCOLTYPE columnNameType)
+	;
+
+alterViewStatementSuffix
+@init { gParent.pushMsg("alter view statement", state); }
+@after { gParent.popMsg(state); }
+    : alterViewSuffixProperties
+    | alterStatementSuffixRename[false]
+    | alterStatementSuffixAddPartitions[false]
+    | alterStatementSuffixDropPartitions[false]
+    | selectStatementWithCTE -> ^(TOK_ALTERVIEW_AS selectStatementWithCTE)
+    ;
+
+alterMaterializedViewStatementSuffix[CommonTree tableNameTree]
+@init { gParent.pushMsg("alter materialized view statement", state); }
+@after { gParent.popMsg(state); }
+    : alterMaterializedViewSuffixRewrite[tableNameTree]
+    | alterMaterializedViewSuffixRebuild[tableNameTree]
+    ;
+
+alterMaterializedViewSuffixRewrite[CommonTree tableNameTree]
+@init { gParent.pushMsg("alter materialized view rewrite statement", state); }
+@after { gParent.popMsg(state); }
+    : (mvRewriteFlag=rewriteEnabled | mvRewriteFlag=rewriteDisabled)
+    -> ^(TOK_ALTER_MATERIALIZED_VIEW_REWRITE {$tableNameTree} $mvRewriteFlag)
+    ;
+
+alterMaterializedViewSuffixRebuild[CommonTree tableNameTree]
+@init { gParent.pushMsg("alter materialized view rebuild statement", state); }
+@after { gParent.popMsg(state); }
+    : KW_REBUILD -> ^(TOK_ALTER_MATERIALIZED_VIEW_REBUILD {$tableNameTree})
+    ;
+
+alterDatabaseStatementSuffix
+@init { gParent.pushMsg("alter database statement", state); }
+@after { gParent.popMsg(state); }
+    : alterDatabaseSuffixProperties
+    | alterDatabaseSuffixSetOwner
+    | alterDatabaseSuffixSetLocation
+    ;
+
+alterDatabaseSuffixProperties
+@init { gParent.pushMsg("alter database properties statement", state); }
+@after { gParent.popMsg(state); }
+    : name=identifier KW_SET KW_DBPROPERTIES dbProperties
+    -> ^(TOK_ALTERDATABASE_PROPERTIES $name dbProperties)
+    ;
+
+alterDatabaseSuffixSetOwner
+@init { gParent.pushMsg("alter database set owner", state); }
+@after { gParent.popMsg(state); }
+    : dbName=identifier KW_SET KW_OWNER principalName
+    -> ^(TOK_ALTERDATABASE_OWNER $dbName principalName)
+    ;
+
+alterDatabaseSuffixSetLocation
+@init { gParent.pushMsg("alter database set location", state); }
+@after { gParent.popMsg(state); }
+    : dbName=identifier KW_SET KW_LOCATION newLocation=StringLiteral
+    -> ^(TOK_ALTERDATABASE_LOCATION $dbName $newLocation)
+    | dbName=identifier KW_SET KW_MANAGEDLOCATION newLocation=StringLiteral
+    -> ^(TOK_ALTERDATABASE_MANAGEDLOCATION $dbName $newLocation)
+    ;
+
+alterDatabaseSuffixSetManagedLocation
+@init { gParent.pushMsg("alter database set managed location", state); }
+@after { gParent.popMsg(state); }
+    : dbName=identifier KW_SET KW_MANAGEDLOCATION newLocation=StringLiteral
+    -> ^(TOK_ALTERDATABASE_MANAGEDLOCATION $dbName $newLocation)
+    ;
+
+alterStatementSuffixRename[boolean table]
+@init { gParent.pushMsg("rename statement", state); }
+@after { gParent.popMsg(state); }
+    : KW_RENAME KW_TO tableName
+    -> { table }? ^(TOK_ALTERTABLE_RENAME tableName)
+    ->            ^(TOK_ALTERVIEW_RENAME tableName)
+    ;
+
+alterStatementSuffixAddCol
+@init { gParent.pushMsg("add column statement", state); }
+@after { gParent.popMsg(state); }
+    : (add=KW_ADD | replace=KW_REPLACE) KW_COLUMNS LPAREN columnNameTypeList RPAREN restrictOrCascade?
+    -> {$add != null}? ^(TOK_ALTERTABLE_ADDCOLS columnNameTypeList restrictOrCascade?)
+    ->                 ^(TOK_ALTERTABLE_REPLACECOLS columnNameTypeList restrictOrCascade?)
+    ;
+
+alterStatementSuffixAddConstraint
+@init { gParent.pushMsg("add constraint statement", state); }
+@after { gParent.popMsg(state); }
+   :  KW_ADD (fk=alterForeignKeyWithName | alterConstraintWithName)
+   -> {fk != null}? ^(TOK_ALTERTABLE_ADDCONSTRAINT alterForeignKeyWithName)
+   ->               ^(TOK_ALTERTABLE_ADDCONSTRAINT alterConstraintWithName)
+   ;
+
+alterStatementSuffixUpdateColumns
+@init { gParent.pushMsg("update columns statement", state); }
+@after { gParent.popMsg(state); }
+    : KW_UPDATE KW_COLUMNS restrictOrCascade?
+    -> ^(TOK_ALTERTABLE_UPDATECOLUMNS restrictOrCascade?)
+    ;
+
+alterStatementSuffixDropConstraint
+@init { gParent.pushMsg("drop constraint statement", state); }
+@after { gParent.popMsg(state); }
+   : KW_DROP KW_CONSTRAINT cName=identifier
+   ->^(TOK_ALTERTABLE_DROPCONSTRAINT $cName)
+   ;
+
+alterStatementSuffixRenameCol
+@init { gParent.pushMsg("rename column name", state); }
+@after { gParent.popMsg(state); }
+    : KW_CHANGE KW_COLUMN? oldName=identifier newName=identifier colType alterColumnConstraint[$newName.tree]? (KW_COMMENT comment=StringLiteral)? alterStatementChangeColPosition? restrictOrCascade?
+    ->^(TOK_ALTERTABLE_RENAMECOL $oldName $newName colType $comment? alterColumnConstraint? alterStatementChangeColPosition? restrictOrCascade?)
+    ;
+
+alterStatementSuffixUpdateStatsCol[boolean partition]
+@init { gParent.pushMsg("update column statistics", state); }
+@after { gParent.popMsg(state); }
+    : KW_UPDATE KW_STATISTICS KW_FOR KW_COLUMN? colName=identifier KW_SET tableProperties (KW_COMMENT comment=StringLiteral)?
+    -> {partition}? ^(TOK_ALTERPARTITION_UPDATECOLSTATS $colName tableProperties $comment?)
+    ->              ^(TOK_ALTERTABLE_UPDATECOLSTATS $colName tableProperties $comment?)
+    ;
+
+alterStatementSuffixUpdateStats[boolean partition]
+@init { gParent.pushMsg("update basic statistics", state); }
+@after { gParent.popMsg(state); }
+    : KW_UPDATE KW_STATISTICS KW_SET tableProperties
+    -> {partition}? ^(TOK_ALTERPARTITION_UPDATESTATS tableProperties)
+    ->              ^(TOK_ALTERTABLE_UPDATESTATS tableProperties)
+    ;
+
+alterStatementChangeColPosition
+    : first=KW_FIRST|KW_AFTER afterCol=identifier
+    ->{$first != null}? ^(TOK_ALTERTABLE_CHANGECOL_AFTER_POSITION )
+    -> ^(TOK_ALTERTABLE_CHANGECOL_AFTER_POSITION $afterCol)
+    ;
+
+alterStatementSuffixAddPartitions[boolean table]
+@init { gParent.pushMsg("add partition statement", state); }
+@after { gParent.popMsg(state); }
+    : KW_ADD ifNotExists? alterStatementSuffixAddPartitionsElement+
+    -> { table }? ^(TOK_ALTERTABLE_ADDPARTS ifNotExists? alterStatementSuffixAddPartitionsElement+)
+    ->            ^(TOK_ALTERVIEW_ADDPARTS ifNotExists? alterStatementSuffixAddPartitionsElement+)
+    ;
+
+alterStatementSuffixAddPartitionsElement
+    : partitionSpec partitionLocation?
+    ;
+
+alterStatementSuffixTouch
+@init { gParent.pushMsg("touch statement", state); }
+@after { gParent.popMsg(state); }
+    : KW_TOUCH (partitionSpec)*
+    -> ^(TOK_ALTERTABLE_TOUCH (partitionSpec)*)
+    ;
+
+alterStatementSuffixArchive
+@init { gParent.pushMsg("archive statement", state); }
+@after { gParent.popMsg(state); }
+    : KW_ARCHIVE (partitionSpec)*
+    -> ^(TOK_ALTERTABLE_ARCHIVE (partitionSpec)*)
+    ;
+
+alterStatementSuffixUnArchive
+@init { gParent.pushMsg("unarchive statement", state); }
+@after { gParent.popMsg(state); }
+    : KW_UNARCHIVE (partitionSpec)*
+    -> ^(TOK_ALTERTABLE_UNARCHIVE (partitionSpec)*)
+    ;
+
+partitionLocation
+@init { gParent.pushMsg("partition location", state); }
+@after { gParent.popMsg(state); }
+    :
+      KW_LOCATION locn=StringLiteral -> ^(TOK_PARTITIONLOCATION $locn)
+    ;
+
+alterStatementSuffixDropPartitions[boolean table]
+@init { gParent.pushMsg("drop partition statement", state); }
+@after { gParent.popMsg(state); }
+    : KW_DROP ifExists? KW_PARTITION partitionSelectorSpec (COMMA KW_PARTITION partitionSelectorSpec)* KW_PURGE? replicationClause?
+    -> { table }? ^(TOK_ALTERTABLE_DROPPARTS partitionSelectorSpec+ ifExists? KW_PURGE? replicationClause?)
+    ->            ^(TOK_ALTERVIEW_DROPPARTS partitionSelectorSpec+ ifExists? replicationClause?)
+    ;
+
+alterStatementSuffixProperties
+@init { gParent.pushMsg("alter properties statement", state); }
+@after { gParent.popMsg(state); }
+    : KW_SET KW_TBLPROPERTIES tableProperties
+    -> ^(TOK_ALTERTABLE_PROPERTIES tableProperties)
+    | KW_UNSET KW_TBLPROPERTIES ifExists? tableProperties
+    -> ^(TOK_ALTERTABLE_DROPPROPERTIES tableProperties ifExists?)
+    ;
+
+alterViewSuffixProperties
+@init { gParent.pushMsg("alter view properties statement", state); }
+@after { gParent.popMsg(state); }
+    : KW_SET KW_TBLPROPERTIES tableProperties
+    -> ^(TOK_ALTERVIEW_PROPERTIES tableProperties)
+    | KW_UNSET KW_TBLPROPERTIES ifExists? tableProperties
+    -> ^(TOK_ALTERVIEW_DROPPROPERTIES tableProperties ifExists?)
+    ;
+
+alterStatementSuffixSerdeProperties[boolean partition]
+@init { gParent.pushMsg("alter serde statement", state); }
+@after { gParent.popMsg(state); }
+    : KW_SET KW_SERDE serdeName=StringLiteral (KW_WITH KW_SERDEPROPERTIES tableProperties)?
+    -> {partition}? ^(TOK_ALTERPARTITION_SERIALIZER $serdeName tableProperties?)
+    ->              ^(TOK_ALTERTABLE_SERIALIZER $serdeName tableProperties?)
+    | KW_SET KW_SERDEPROPERTIES tableProperties
+    -> {partition}? ^(TOK_ALTERPARTITION_SETSERDEPROPERTIES tableProperties)
+    ->              ^(TOK_ALTERTABLE_SETSERDEPROPERTIES tableProperties)
+    | KW_UNSET KW_SERDEPROPERTIES tableProperties
+    -> {partition}? ^(TOK_ALTERPARTITION_UNSETSERDEPROPERTIES tableProperties)
+    ->              ^(TOK_ALTERTABLE_UNSETSERDEPROPERTIES tableProperties)
+    ;
+
+tablePartitionPrefix
+@init {gParent.pushMsg("table partition prefix", state);}
+@after {gParent.popMsg(state);}
+  : tableName partitionSpec?
+  ->^(TOK_TABLE_PARTITION tableName partitionSpec?)
+  ;
+
+alterStatementSuffixFileFormat[boolean partition]
+@init {gParent.pushMsg("alter fileformat statement", state); }
+@after {gParent.popMsg(state);}
+  : KW_SET KW_FILEFORMAT fileFormat
+  -> {partition}? ^(TOK_ALTERPARTITION_FILEFORMAT fileFormat)
+  ->              ^(TOK_ALTERTABLE_FILEFORMAT fileFormat)
+  ;
+
+alterStatementSuffixClusterbySortby
+@init {gParent.pushMsg("alter partition cluster by sort by statement", state);}
+@after {gParent.popMsg(state);}
+  : KW_NOT KW_CLUSTERED -> ^(TOK_ALTERTABLE_CLUSTER_SORT TOK_NOT_CLUSTERED)
+  | KW_NOT KW_SORTED -> ^(TOK_ALTERTABLE_CLUSTER_SORT TOK_NOT_SORTED)
+  | tableBuckets -> ^(TOK_ALTERTABLE_CLUSTER_SORT tableBuckets)
+  ;
+
+alterTblPartitionStatementSuffixSkewedLocation
+@init {gParent.pushMsg("alter partition skewed location", state);}
+@after {gParent.popMsg(state);}
+  : KW_SET KW_SKEWED KW_LOCATION skewedLocations
+  -> ^(TOK_ALTERTABLE_SKEWED_LOCATION skewedLocations)
+  ;
+
+skewedLocations
+@init { gParent.pushMsg("skewed locations", state); }
+@after { gParent.popMsg(state); }
+    :
+      LPAREN skewedLocationsList RPAREN -> ^(TOK_SKEWED_LOCATIONS skewedLocationsList)
+    ;
+
+skewedLocationsList
+@init { gParent.pushMsg("skewed locations list", state); }
+@after { gParent.popMsg(state); }
+    :
+      skewedLocationMap (COMMA skewedLocationMap)* -> ^(TOK_SKEWED_LOCATION_LIST skewedLocationMap+)
+    ;
+
+skewedLocationMap
+@init { gParent.pushMsg("specifying skewed location map", state); }
+@after { gParent.popMsg(state); }
+    :
+      key=skewedValueLocationElement EQUAL value=StringLiteral -> ^(TOK_SKEWED_LOCATION_MAP $key $value)
+    ;
+
+alterStatementSuffixLocation[boolean partition]
+@init {gParent.pushMsg("alter location", state);}
+@after {gParent.popMsg(state);}
+  : KW_SET KW_LOCATION newLoc=StringLiteral
+  -> {partition}? ^(TOK_ALTERPARTITION_LOCATION $newLoc)
+  ->              ^(TOK_ALTERTABLE_LOCATION $newLoc)
+  ;
+
+
+alterStatementSuffixSkewedby
+@init {gParent.pushMsg("alter skewed by statement", state);}
+@after{gParent.popMsg(state);}
+	: tableSkewed
+	->^(TOK_ALTERTABLE_SKEWED tableSkewed)
+	|
+	 KW_NOT KW_SKEWED
+	->^(TOK_ALTERTABLE_SKEWED)
+	|
+	 KW_NOT storedAsDirs
+	->^(TOK_ALTERTABLE_SKEWED storedAsDirs)
+	;
+
+alterStatementSuffixExchangePartition
+@init {gParent.pushMsg("alter exchange partition", state);}
+@after{gParent.popMsg(state);}
+    : KW_EXCHANGE partitionSpec KW_WITH KW_TABLE exchangename=tableName
+    -> ^(TOK_ALTERTABLE_EXCHANGEPARTITION partitionSpec $exchangename)
+    ;
+
+alterStatementSuffixRenamePart
+@init { gParent.pushMsg("alter table rename partition statement", state); }
+@after { gParent.popMsg(state); }
+    : KW_RENAME KW_TO partitionSpec
+    ->^(TOK_ALTERTABLE_RENAMEPART partitionSpec)
+    ;
+
+alterStatementSuffixStatsPart
+@init { gParent.pushMsg("alter table stats partition statement", state); }
+@after { gParent.popMsg(state); }
+    : KW_UPDATE KW_STATISTICS KW_FOR KW_COLUMN? colName=identifier KW_SET tableProperties (KW_COMMENT comment=StringLiteral)?
+    ->^(TOK_ALTERTABLE_UPDATECOLSTATS $colName tableProperties $comment?)
+    ;
+
+alterStatementSuffixMergeFiles[boolean partition]
+@init { gParent.pushMsg("", state); }
+@after { gParent.popMsg(state); }
+    : KW_CONCATENATE
+    -> {partition}? ^(TOK_ALTERPARTITION_MERGEFILES)
+    ->              ^(TOK_ALTERTABLE_MERGEFILES)
+    ;
+
+alterStatementSuffixBucketNum[boolean partition]
+@init { gParent.pushMsg("", state); }
+@after { gParent.popMsg(state); }
+    : KW_INTO num=Number KW_BUCKETS
+    -> {partition}? ^(TOK_ALTERPARTITION_BUCKETS $num)
+    ->              ^(TOK_ALTERTABLE_BUCKETS $num)
+    ;
+
+blocking
+  : KW_AND KW_WAIT
+  -> TOK_BLOCKING
+  ;
+
+alterStatementSuffixCompact
+@init { gParent.msgs.push("compaction request"); }
+@after { gParent.msgs.pop(); }
+    : KW_COMPACT compactType=StringLiteral blocking? (KW_WITH KW_OVERWRITE KW_TBLPROPERTIES tableProperties)?
+    -> ^(TOK_ALTERTABLE_COMPACT $compactType blocking? tableProperties?)
+    ;
+
+alterStatementSuffixSetOwner
+@init { gParent.pushMsg("alter table set owner", state); }
+@after { gParent.popMsg(state); }
+    : KW_SET KW_OWNER principalName
+    -> ^(TOK_ALTERTABLE_OWNER principalName)
+    ;
+
+fileFormat
+@init { gParent.pushMsg("file format specification", state); }
+@after { gParent.popMsg(state); }
+    : KW_INPUTFORMAT inFmt=StringLiteral KW_OUTPUTFORMAT outFmt=StringLiteral KW_SERDE serdeCls=StringLiteral (KW_INPUTDRIVER inDriver=StringLiteral KW_OUTPUTDRIVER outDriver=StringLiteral)?
+      -> ^(TOK_TABLEFILEFORMAT $inFmt $outFmt $serdeCls $inDriver? $outDriver?)
+    | genericSpec=identifier -> ^(TOK_FILEFORMAT_GENERIC $genericSpec)
+    ;
diff --git a/parser/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g b/parser/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
index 594d8c6..daf2d65 100644
--- a/parser/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
+++ b/parser/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
@@ -24,7 +24,7 @@ ASTLabelType=ASTNode;
 backtrack=false;
 k=3;
 }
-import SelectClauseParser, FromClauseParser, IdentifiersParser, ResourcePlanParser;
+import AlterClauseParser, SelectClauseParser, FromClauseParser, IdentifiersParser, ResourcePlanParser;
 
 tokens {
 TOK_INSERT;
@@ -1198,413 +1198,6 @@ dropTableStatement
     -> ^(TOK_DROPTABLE tableName ifExists? KW_PURGE? replicationClause?)
     ;
 
-alterStatement
-@init { pushMsg("alter statement", state); }
-@after { popMsg(state); }
-    : KW_ALTER KW_TABLE tableName alterTableStatementSuffix -> ^(TOK_ALTERTABLE tableName alterTableStatementSuffix)
-    | KW_ALTER KW_VIEW tableName KW_AS? alterViewStatementSuffix -> ^(TOK_ALTERVIEW tableName alterViewStatementSuffix)
-    | KW_ALTER KW_MATERIALIZED KW_VIEW tableNameTree=tableName alterMaterializedViewStatementSuffix[$tableNameTree.tree] -> alterMaterializedViewStatementSuffix
-    | KW_ALTER (KW_DATABASE|KW_SCHEMA) alterDatabaseStatementSuffix -> alterDatabaseStatementSuffix
-    ;
-
-alterTableStatementSuffix
-@init { pushMsg("alter table statement", state); }
-@after { popMsg(state); }
-    : (alterStatementSuffixRename[true]) => alterStatementSuffixRename[true]
-    | alterStatementSuffixDropPartitions[true]
-    | alterStatementSuffixAddPartitions[true]
-    | alterStatementSuffixTouch
-    | alterStatementSuffixArchive
-    | alterStatementSuffixUnArchive
-    | alterStatementSuffixProperties
-    | alterStatementSuffixSkewedby
-    | alterStatementSuffixExchangePartition
-    | alterStatementPartitionKeyType
-    | alterStatementSuffixDropConstraint
-    | alterStatementSuffixAddConstraint
-    | alterTblPartitionStatementSuffix[false]
-    | partitionSpec alterTblPartitionStatementSuffix[true] -> alterTblPartitionStatementSuffix partitionSpec
-    | alterStatementSuffixSetOwner
-    ;
-
-alterTblPartitionStatementSuffix[boolean partition]
-@init {pushMsg("alter table partition statement suffix", state);}
-@after {popMsg(state);}
-  : alterStatementSuffixFileFormat[partition]
-  | alterStatementSuffixLocation[partition]
-  | alterStatementSuffixMergeFiles[partition]
-  | alterStatementSuffixSerdeProperties[partition]
-  | alterStatementSuffixRenamePart
-  | alterStatementSuffixBucketNum[partition]
-  | alterTblPartitionStatementSuffixSkewedLocation
-  | alterStatementSuffixClusterbySortby
-  | alterStatementSuffixCompact
-  | alterStatementSuffixUpdateStatsCol[partition]
-  | alterStatementSuffixUpdateStats[partition]
-  | alterStatementSuffixRenameCol
-  | alterStatementSuffixAddCol
-  | alterStatementSuffixUpdateColumns
-  ;
-
-alterStatementPartitionKeyType
-@init {msgs.push("alter partition key type"); }
-@after {msgs.pop();}
-	: KW_PARTITION KW_COLUMN LPAREN columnNameType RPAREN
-	-> ^(TOK_ALTERTABLE_PARTCOLTYPE columnNameType)
-	;
-
-alterViewStatementSuffix
-@init { pushMsg("alter view statement", state); }
-@after { popMsg(state); }
-    : alterViewSuffixProperties
-    | alterStatementSuffixRename[false]
-    | alterStatementSuffixAddPartitions[false]
-    | alterStatementSuffixDropPartitions[false]
-    | selectStatementWithCTE -> ^(TOK_ALTERVIEW_AS selectStatementWithCTE)
-    ;
-
-alterMaterializedViewStatementSuffix[CommonTree tableNameTree]
-@init { pushMsg("alter materialized view statement", state); }
-@after { popMsg(state); }
-    : alterMaterializedViewSuffixRewrite[tableNameTree]
-    | alterMaterializedViewSuffixRebuild[tableNameTree]
-    ;
-
-alterMaterializedViewSuffixRewrite[CommonTree tableNameTree]
-@init { pushMsg("alter materialized view rewrite statement", state); }
-@after { popMsg(state); }
-    : (mvRewriteFlag=rewriteEnabled | mvRewriteFlag=rewriteDisabled)
-    -> ^(TOK_ALTER_MATERIALIZED_VIEW_REWRITE {$tableNameTree} $mvRewriteFlag)
-    ;
-
-alterMaterializedViewSuffixRebuild[CommonTree tableNameTree]
-@init { pushMsg("alter materialized view rebuild statement", state); }
-@after { popMsg(state); }
-    : KW_REBUILD -> ^(TOK_ALTER_MATERIALIZED_VIEW_REBUILD {$tableNameTree})
-    ;
-
-alterDatabaseStatementSuffix
-@init { pushMsg("alter database statement", state); }
-@after { popMsg(state); }
-    : alterDatabaseSuffixProperties
-    | alterDatabaseSuffixSetOwner
-    | alterDatabaseSuffixSetLocation
-    ;
-
-alterDatabaseSuffixProperties
-@init { pushMsg("alter database properties statement", state); }
-@after { popMsg(state); }
-    : name=identifier KW_SET KW_DBPROPERTIES dbProperties
-    -> ^(TOK_ALTERDATABASE_PROPERTIES $name dbProperties)
-    ;
-
-alterDatabaseSuffixSetOwner
-@init { pushMsg("alter database set owner", state); }
-@after { popMsg(state); }
-    : dbName=identifier KW_SET KW_OWNER principalName
-    -> ^(TOK_ALTERDATABASE_OWNER $dbName principalName)
-    ;
-
-alterDatabaseSuffixSetLocation
-@init { pushMsg("alter database set location", state); }
-@after { popMsg(state); }
-    : dbName=identifier KW_SET KW_LOCATION newLocation=StringLiteral
-    -> ^(TOK_ALTERDATABASE_LOCATION $dbName $newLocation)
-    | dbName=identifier KW_SET KW_MANAGEDLOCATION newLocation=StringLiteral
-    -> ^(TOK_ALTERDATABASE_MANAGEDLOCATION $dbName $newLocation)
-    ;
-
-alterDatabaseSuffixSetManagedLocation
-@init { pushMsg("alter database set managed location", state); }
-@after { popMsg(state); }
-    : dbName=identifier KW_SET KW_MANAGEDLOCATION newLocation=StringLiteral
-    -> ^(TOK_ALTERDATABASE_MANAGEDLOCATION $dbName $newLocation)
-    ;
-
-alterStatementSuffixRename[boolean table]
-@init { pushMsg("rename statement", state); }
-@after { popMsg(state); }
-    : KW_RENAME KW_TO tableName
-    -> { table }? ^(TOK_ALTERTABLE_RENAME tableName)
-    ->            ^(TOK_ALTERVIEW_RENAME tableName)
-    ;
-
-alterStatementSuffixAddCol
-@init { pushMsg("add column statement", state); }
-@after { popMsg(state); }
-    : (add=KW_ADD | replace=KW_REPLACE) KW_COLUMNS LPAREN columnNameTypeList RPAREN restrictOrCascade?
-    -> {$add != null}? ^(TOK_ALTERTABLE_ADDCOLS columnNameTypeList restrictOrCascade?)
-    ->                 ^(TOK_ALTERTABLE_REPLACECOLS columnNameTypeList restrictOrCascade?)
-    ;
-
-alterStatementSuffixAddConstraint
-@init { pushMsg("add constraint statement", state); }
-@after { popMsg(state); }
-   :  KW_ADD (fk=alterForeignKeyWithName | alterConstraintWithName)
-   -> {fk != null}? ^(TOK_ALTERTABLE_ADDCONSTRAINT alterForeignKeyWithName)
-   ->               ^(TOK_ALTERTABLE_ADDCONSTRAINT alterConstraintWithName)
-   ;
-
-alterStatementSuffixUpdateColumns
-@init { pushMsg("update columns statement", state); }
-@after { popMsg(state); }
-    : KW_UPDATE KW_COLUMNS restrictOrCascade?
-    -> ^(TOK_ALTERTABLE_UPDATECOLUMNS restrictOrCascade?)
-    ;
-
-alterStatementSuffixDropConstraint
-@init { pushMsg("drop constraint statement", state); }
-@after { popMsg(state); }
-   : KW_DROP KW_CONSTRAINT cName=identifier
-   ->^(TOK_ALTERTABLE_DROPCONSTRAINT $cName)
-   ;
-
-alterStatementSuffixRenameCol
-@init { pushMsg("rename column name", state); }
-@after { popMsg(state); }
-    : KW_CHANGE KW_COLUMN? oldName=identifier newName=identifier colType alterColumnConstraint[$newName.tree]? (KW_COMMENT comment=StringLiteral)? alterStatementChangeColPosition? restrictOrCascade?
-    ->^(TOK_ALTERTABLE_RENAMECOL $oldName $newName colType $comment? alterColumnConstraint? alterStatementChangeColPosition? restrictOrCascade?)
-    ;
-
-alterStatementSuffixUpdateStatsCol[boolean partition]
-@init { pushMsg("update column statistics", state); }
-@after { popMsg(state); }
-    : KW_UPDATE KW_STATISTICS KW_FOR KW_COLUMN? colName=identifier KW_SET tableProperties (KW_COMMENT comment=StringLiteral)?
-    -> {partition}? ^(TOK_ALTERPARTITION_UPDATECOLSTATS $colName tableProperties $comment?)
-    ->              ^(TOK_ALTERTABLE_UPDATECOLSTATS $colName tableProperties $comment?)
-    ;
-
-alterStatementSuffixUpdateStats[boolean partition]
-@init { pushMsg("update basic statistics", state); }
-@after { popMsg(state); }
-    : KW_UPDATE KW_STATISTICS KW_SET tableProperties
-    -> {partition}? ^(TOK_ALTERPARTITION_UPDATESTATS tableProperties)
-    ->              ^(TOK_ALTERTABLE_UPDATESTATS tableProperties)
-    ;
-
-alterStatementChangeColPosition
-    : first=KW_FIRST|KW_AFTER afterCol=identifier
-    ->{$first != null}? ^(TOK_ALTERTABLE_CHANGECOL_AFTER_POSITION )
-    -> ^(TOK_ALTERTABLE_CHANGECOL_AFTER_POSITION $afterCol)
-    ;
-
-alterStatementSuffixAddPartitions[boolean table]
-@init { pushMsg("add partition statement", state); }
-@after { popMsg(state); }
-    : KW_ADD ifNotExists? alterStatementSuffixAddPartitionsElement+
-    -> { table }? ^(TOK_ALTERTABLE_ADDPARTS ifNotExists? alterStatementSuffixAddPartitionsElement+)
-    ->            ^(TOK_ALTERVIEW_ADDPARTS ifNotExists? alterStatementSuffixAddPartitionsElement+)
-    ;
-
-alterStatementSuffixAddPartitionsElement
-    : partitionSpec partitionLocation?
-    ;
-
-alterStatementSuffixTouch
-@init { pushMsg("touch statement", state); }
-@after { popMsg(state); }
-    : KW_TOUCH (partitionSpec)*
-    -> ^(TOK_ALTERTABLE_TOUCH (partitionSpec)*)
-    ;
-
-alterStatementSuffixArchive
-@init { pushMsg("archive statement", state); }
-@after { popMsg(state); }
-    : KW_ARCHIVE (partitionSpec)*
-    -> ^(TOK_ALTERTABLE_ARCHIVE (partitionSpec)*)
-    ;
-
-alterStatementSuffixUnArchive
-@init { pushMsg("unarchive statement", state); }
-@after { popMsg(state); }
-    : KW_UNARCHIVE (partitionSpec)*
-    -> ^(TOK_ALTERTABLE_UNARCHIVE (partitionSpec)*)
-    ;
-
-partitionLocation
-@init { pushMsg("partition location", state); }
-@after { popMsg(state); }
-    :
-      KW_LOCATION locn=StringLiteral -> ^(TOK_PARTITIONLOCATION $locn)
-    ;
-
-alterStatementSuffixDropPartitions[boolean table]
-@init { pushMsg("drop partition statement", state); }
-@after { popMsg(state); }
-    : KW_DROP ifExists? KW_PARTITION partitionSelectorSpec (COMMA KW_PARTITION partitionSelectorSpec)* KW_PURGE? replicationClause?
-    -> { table }? ^(TOK_ALTERTABLE_DROPPARTS partitionSelectorSpec+ ifExists? KW_PURGE? replicationClause?)
-    ->            ^(TOK_ALTERVIEW_DROPPARTS partitionSelectorSpec+ ifExists? replicationClause?)
-    ;
-
-alterStatementSuffixProperties
-@init { pushMsg("alter properties statement", state); }
-@after { popMsg(state); }
-    : KW_SET KW_TBLPROPERTIES tableProperties
-    -> ^(TOK_ALTERTABLE_PROPERTIES tableProperties)
-    | KW_UNSET KW_TBLPROPERTIES ifExists? tableProperties
-    -> ^(TOK_ALTERTABLE_DROPPROPERTIES tableProperties ifExists?)
-    ;
-
-alterViewSuffixProperties
-@init { pushMsg("alter view properties statement", state); }
-@after { popMsg(state); }
-    : KW_SET KW_TBLPROPERTIES tableProperties
-    -> ^(TOK_ALTERVIEW_PROPERTIES tableProperties)
-    | KW_UNSET KW_TBLPROPERTIES ifExists? tableProperties
-    -> ^(TOK_ALTERVIEW_DROPPROPERTIES tableProperties ifExists?)
-    ;
-
-alterStatementSuffixSerdeProperties[boolean partition]
-@init { pushMsg("alter serde statement", state); }
-@after { popMsg(state); }
-    : KW_SET KW_SERDE serdeName=StringLiteral (KW_WITH KW_SERDEPROPERTIES tableProperties)?
-    -> {partition}? ^(TOK_ALTERPARTITION_SERIALIZER $serdeName tableProperties?)
-    ->              ^(TOK_ALTERTABLE_SERIALIZER $serdeName tableProperties?)
-    | KW_SET KW_SERDEPROPERTIES tableProperties
-    -> {partition}? ^(TOK_ALTERPARTITION_SETSERDEPROPERTIES tableProperties)
-    ->              ^(TOK_ALTERTABLE_SETSERDEPROPERTIES tableProperties)
-    | KW_UNSET KW_SERDEPROPERTIES tableProperties
-    -> {partition}? ^(TOK_ALTERPARTITION_UNSETSERDEPROPERTIES tableProperties)
-    ->              ^(TOK_ALTERTABLE_UNSETSERDEPROPERTIES tableProperties)
-    ;
-
-tablePartitionPrefix
-@init {pushMsg("table partition prefix", state);}
-@after {popMsg(state);}
-  : tableName partitionSpec?
-  ->^(TOK_TABLE_PARTITION tableName partitionSpec?)
-  ;
-
-alterStatementSuffixFileFormat[boolean partition]
-@init {pushMsg("alter fileformat statement", state); }
-@after {popMsg(state);}
-  : KW_SET KW_FILEFORMAT fileFormat
-  -> {partition}? ^(TOK_ALTERPARTITION_FILEFORMAT fileFormat)
-  ->              ^(TOK_ALTERTABLE_FILEFORMAT fileFormat)
-  ;
-
-alterStatementSuffixClusterbySortby
-@init {pushMsg("alter partition cluster by sort by statement", state);}
-@after {popMsg(state);}
-  : KW_NOT KW_CLUSTERED -> ^(TOK_ALTERTABLE_CLUSTER_SORT TOK_NOT_CLUSTERED)
-  | KW_NOT KW_SORTED -> ^(TOK_ALTERTABLE_CLUSTER_SORT TOK_NOT_SORTED)
-  | tableBuckets -> ^(TOK_ALTERTABLE_CLUSTER_SORT tableBuckets)
-  ;
-
-alterTblPartitionStatementSuffixSkewedLocation
-@init {pushMsg("alter partition skewed location", state);}
-@after {popMsg(state);}
-  : KW_SET KW_SKEWED KW_LOCATION skewedLocations
-  -> ^(TOK_ALTERTABLE_SKEWED_LOCATION skewedLocations)
-  ;
-
-skewedLocations
-@init { pushMsg("skewed locations", state); }
-@after { popMsg(state); }
-    :
-      LPAREN skewedLocationsList RPAREN -> ^(TOK_SKEWED_LOCATIONS skewedLocationsList)
-    ;
-
-skewedLocationsList
-@init { pushMsg("skewed locations list", state); }
-@after { popMsg(state); }
-    :
-      skewedLocationMap (COMMA skewedLocationMap)* -> ^(TOK_SKEWED_LOCATION_LIST skewedLocationMap+)
-    ;
-
-skewedLocationMap
-@init { pushMsg("specifying skewed location map", state); }
-@after { popMsg(state); }
-    :
-      key=skewedValueLocationElement EQUAL value=StringLiteral -> ^(TOK_SKEWED_LOCATION_MAP $key $value)
-    ;
-
-alterStatementSuffixLocation[boolean partition]
-@init {pushMsg("alter location", state);}
-@after {popMsg(state);}
-  : KW_SET KW_LOCATION newLoc=StringLiteral
-  -> {partition}? ^(TOK_ALTERPARTITION_LOCATION $newLoc)
-  ->              ^(TOK_ALTERTABLE_LOCATION $newLoc)
-  ;
-
-
-alterStatementSuffixSkewedby
-@init {pushMsg("alter skewed by statement", state);}
-@after{popMsg(state);}
-	: tableSkewed
-	->^(TOK_ALTERTABLE_SKEWED tableSkewed)
-	|
-	 KW_NOT KW_SKEWED
-	->^(TOK_ALTERTABLE_SKEWED)
-	|
-	 KW_NOT storedAsDirs
-	->^(TOK_ALTERTABLE_SKEWED storedAsDirs)
-	;
-
-alterStatementSuffixExchangePartition
-@init {pushMsg("alter exchange partition", state);}
-@after{popMsg(state);}
-    : KW_EXCHANGE partitionSpec KW_WITH KW_TABLE exchangename=tableName
-    -> ^(TOK_ALTERTABLE_EXCHANGEPARTITION partitionSpec $exchangename)
-    ;
-
-alterStatementSuffixRenamePart
-@init { pushMsg("alter table rename partition statement", state); }
-@after { popMsg(state); }
-    : KW_RENAME KW_TO partitionSpec
-    ->^(TOK_ALTERTABLE_RENAMEPART partitionSpec)
-    ;
-
-alterStatementSuffixStatsPart
-@init { pushMsg("alter table stats partition statement", state); }
-@after { popMsg(state); }
-    : KW_UPDATE KW_STATISTICS KW_FOR KW_COLUMN? colName=identifier KW_SET tableProperties (KW_COMMENT comment=StringLiteral)?
-    ->^(TOK_ALTERTABLE_UPDATECOLSTATS $colName tableProperties $comment?)
-    ;
-
-alterStatementSuffixMergeFiles[boolean partition]
-@init { pushMsg("", state); }
-@after { popMsg(state); }
-    : KW_CONCATENATE
-    -> {partition}? ^(TOK_ALTERPARTITION_MERGEFILES)
-    ->              ^(TOK_ALTERTABLE_MERGEFILES)
-    ;
-
-alterStatementSuffixBucketNum[boolean partition]
-@init { pushMsg("", state); }
-@after { popMsg(state); }
-    : KW_INTO num=Number KW_BUCKETS
-    -> {partition}? ^(TOK_ALTERPARTITION_BUCKETS $num)
-    ->              ^(TOK_ALTERTABLE_BUCKETS $num)
-    ;
-
-blocking
-  : KW_AND KW_WAIT
-  -> TOK_BLOCKING
-  ;
-
-alterStatementSuffixCompact
-@init { msgs.push("compaction request"); }
-@after { msgs.pop(); }
-    : KW_COMPACT compactType=StringLiteral blocking? (KW_WITH KW_OVERWRITE KW_TBLPROPERTIES tableProperties)?
-    -> ^(TOK_ALTERTABLE_COMPACT $compactType blocking? tableProperties?)
-    ;
-
-alterStatementSuffixSetOwner
-@init { pushMsg("alter table set owner", state); }
-@after { popMsg(state); }
-    : KW_SET KW_OWNER principalName
-    -> ^(TOK_ALTERTABLE_OWNER principalName)
-    ;
-
-fileFormat
-@init { pushMsg("file format specification", state); }
-@after { popMsg(state); }
-    : KW_INPUTFORMAT inFmt=StringLiteral KW_OUTPUTFORMAT outFmt=StringLiteral KW_SERDE serdeCls=StringLiteral (KW_INPUTDRIVER inDriver=StringLiteral KW_OUTPUTDRIVER outDriver=StringLiteral)?
-      -> ^(TOK_TABLEFILEFORMAT $inFmt $outFmt $serdeCls $inDriver? $outDriver?)
-    | genericSpec=identifier -> ^(TOK_FILEFORMAT_GENERIC $genericSpec)
-    ;
-
 inputFileFormat
 @init { pushMsg("Load Data input file format specification", state); }
 @after { popMsg(state); }
diff --git a/parser/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g b/parser/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
index 5ec3de0..783846a 100644
--- a/parser/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
+++ b/parser/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
@@ -606,8 +606,8 @@ precedenceSimilarExpressionAtom[CommonTree t]
 
 precedenceSimilarExpressionQuantifierPredicate[CommonTree t]
     :
-    partitionSelectorOperator quantifierType subQueryExpression
-    -> ^(TOK_SUBQUERY_EXPR ^(TOK_SUBQUERY_OP quantifierType partitionSelectorOperator ) subQueryExpression {$t})
+    subQuerySelectorOperator quantifierType subQueryExpression
+    -> ^(TOK_SUBQUERY_EXPR ^(TOK_SUBQUERY_OP quantifierType subQuerySelectorOperator ) subQueryExpression {$t})
     ;
 
 quantifierType
@@ -730,7 +730,12 @@ partitionSelectorVal
 
 partitionSelectorOperator
     :
-    EQUAL | NOTEQUAL | LESSTHANOREQUALTO | LESSTHAN | GREATERTHANOREQUALTO | GREATERTHAN | KW_LIKE
+    KW_LIKE | subQuerySelectorOperator
+    ;
+
+subQuerySelectorOperator
+    :
+    EQUAL | NOTEQUAL | LESSTHANOREQUALTO | LESSTHAN | GREATERTHANOREQUALTO | GREATERTHAN
     ;
 
 sysFuncNames
@@ -812,7 +817,7 @@ principalIdentifier
 // Here is what you have to do if you would like to add a new keyword.
 // Note that non reserved keywords are basically the keywords that can be used as identifiers.
 // (1) Add a new entry to HiveLexer, e.g., KW_TRUE : 'TRUE';
-// (2) If it is reserved, you do NOT need to change IdentifiersParser.g 
+// (2) If it is reserved, you do NOT need to change IdentifiersParser.g
 //                        because all the KW_* are automatically not only keywords, but also reserved keywords.
 //                        However, you need to add a test to TestSQL11ReservedKeyWordsNegative.java.
 //     Otherwise it is non-reserved, you need to put them in the nonReserved list below.
@@ -823,7 +828,7 @@ nonReserved
     KW_ABORT | KW_ADD | KW_ADMIN | KW_AFTER | KW_ANALYZE | KW_ARCHIVE | KW_ASC | KW_BEFORE | KW_BUCKET | KW_BUCKETS
     | KW_CASCADE | KW_CBO | KW_CHANGE | KW_CHECK | KW_CLUSTER | KW_CLUSTERED | KW_CLUSTERSTATUS | KW_COLLECTION | KW_COLUMNS
     | KW_COMMENT | KW_COMPACT | KW_COMPACTIONS | KW_COMPUTE | KW_CONCATENATE | KW_CONTINUE | KW_COST | KW_DATA | KW_DAY
-    | KW_DATABASES | KW_DATETIME | KW_DBPROPERTIES | KW_DEFERRED | KW_DEFINED | KW_DELIMITED | KW_DEPENDENCY 
+    | KW_DATABASES | KW_DATETIME | KW_DBPROPERTIES | KW_DEFERRED | KW_DEFINED | KW_DELIMITED | KW_DEPENDENCY
     | KW_DESC | KW_DIRECTORIES | KW_DIRECTORY | KW_DISABLE | KW_DISTRIBUTE | KW_DISTRIBUTED | KW_DOW | KW_ELEM_TYPE
     | KW_ENABLE | KW_ENFORCED | KW_ESCAPED | KW_EXCLUSIVE | KW_EXPLAIN | KW_EXPORT | KW_FIELDS | KW_FILE | KW_FILEFORMAT
     | KW_FIRST | KW_FORMAT | KW_FORMATTED | KW_FUNCTIONS | KW_HOLD_DDLTIME | KW_HOUR | KW_IDXPROPERTIES | KW_IGNORE